{"id":662,"date":"2013-04-17T23:06:23","date_gmt":"2013-04-17T21:06:23","guid":{"rendered":"https:\/\/zz-indigo.mavipet.sk\/?p=662"},"modified":"2019-10-29T18:04:57","modified_gmt":"2019-10-29T18:04:57","slug":"usb-i2c-1wire","status":"publish","type":"post","link":"https:\/\/zz-indigo.mavipet.sk\/?p=662","title":{"rendered":"USB -> I2C -> 1Wire"},"content":{"rendered":"<p>Ke\u010f\u017ee u\u017e m\u00e1m HW,FW a aj I2C to 1wire \u0161v\u00e1ba bolo na\u010dase spravi\u0165 kone\u010dn\u00e9 rie\u0161enie.<\/p>\n<p><!--more--><\/p>\n<p>Najprv par fotiek rie\u0161enia:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-663 size-large\" title=\"USB to 1Wire\" src=\"https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0014-1024x683.jpg\" width=\"584\" height=\"390\" srcset=\"https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0014-1024x683.jpg 1024w, https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0014-300x200.jpg 300w, https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0014-768x512.jpg 768w, https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0014-1200x800.jpg 1200w, https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0014.jpg 2048w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-664 size-large\" title=\"USB to 1wire znova.\" src=\"https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0015-1024x683.jpg\" width=\"584\" height=\"390\" srcset=\"https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0015-1024x683.jpg 1024w, https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0015-300x200.jpg 300w, https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0015-768x512.jpg 768w, https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0015-1200x800.jpg 1200w, https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0015.jpg 2048w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/>\u010cidlo<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-665 size-large\" title=\"Cidlo\" src=\"https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0016-1024x683.jpg\" width=\"584\" height=\"390\" srcset=\"https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0016-1024x683.jpg 1024w, https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0016-300x200.jpg 300w, https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0016-768x512.jpg 768w, https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0016-1200x800.jpg 1200w, https:\/\/zz-indigo.mavipet.sk\/wp-content\/uploads\/2013\/04\/IMG_0016.jpg 2048w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/>Ako na to\u00a0 pod Linuxom:<\/p>\n<p>Po zapnut\u00ed by sa malo zariadenie n\u00e1js\u0165 automaticky:<\/p>\n<pre>[182470.820375] usb 4-5: new low-speed USB device number 40 using ohci_hcd\r\n[182470.855874] usb 4-5: New USB device found, idVendor=0403, idProduct=c631\r\n[182470.855892] usb 4-5: New USB device strings: Mfr=1, Product=2, SerialNumber=0\r\n[182470.855903] usb 4-5: Product: i2c-tiny-usb\r\n[182470.855910] usb 4-5: Manufacturer: Till Harbaum\r\n[182470.858023] i2c-tiny-usb 4-5:1.0: version 1.05 found at bus 004 address 040\r\n[182470.860535] i2c i2c-1: connected i2c-tiny-usb device<\/pre>\n<p>Ak nie treba skontrolova\u0165 \u010di m\u00e1me zaveden\u00fd modul i2c_tiny_usb. Na\u00a0 1Wire treba natiahnu\u0165\u00a0 moduly i2c_dev, ds2482, wire. DS2482 sa ale neinicializuje s\u00e1m ale treba ho nakopn\u00fa\u0165.<\/p>\n<p>Najpr si n\u00e1jdeme kde m\u00e1me I2C zbernicu:<\/p>\n<pre># i2cdetect -l\r\ni2c-1\u00a0\u00a0 \u00a0i2c\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0i2c-tiny-usb at bus 004 device 040\u00a0\u00a0 \u00a0I2C adapter\r\ni2c-0\u00a0\u00a0 \u00a0smbus\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0SMBus PIIX4 adapter at 0b00\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0SMBus adapter<\/pre>\n<p>V mojom pr\u00edpade je to i2c-1. Tak si pozrieme \u010di vid\u00edme aj konvertor:<\/p>\n<pre># i2cdetect 1\r\nWARNING! This program can confuse your I2C bus, cause data loss and worse!\r\nI will probe file \/dev\/i2c-1.\r\nI will probe address range 0x03-0x77.\r\nContinue? [Y\/n]\r\n\u00a0\u00a0\u00a0\u00a0 0\u00a0 1\u00a0 2\u00a0 3\u00a0 4\u00a0 5\u00a0 6\u00a0 7\u00a0 8\u00a0 9\u00a0 a\u00a0 b\u00a0 c\u00a0 d\u00a0 e\u00a0 f\r\n00:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 -- -- -- -- -- -- -- -- -- -- -- -- --\r\n10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --\r\n20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\r\n30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\r\n40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\r\n50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\r\n60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\r\n70: -- -- -- -- -- -- -- --<\/pre>\n<p>Konvertory maj\u00fa adresu z rozsahu 0x18 a\u017e 0x1B Ja ho m\u00e1m na adrese 0x18. Tak to linux-u povieme:<\/p>\n<pre>#echo ds2482 0x18 &gt; \/sys\/bus\/i2c\/devices\/i2c-1\/new_device<\/pre>\n<p>Teraz by sa n\u00e1m mala objavi\u0165 1Wire zbernica.<\/p>\n<pre>#ls \/sys\/bus\/w1\/devices\/\r\nw1_bus_master1<\/pre>\n<p>A teraz m\u00f4\u017eeme zisti\u0165 \u010di nejak\u00e9 zariadenia vid\u00edme:<\/p>\n<pre># cat \/sys\/bus\/w1\/devices\/w1_bus_master1\/w1_master_slave_count\r\n0\r\n# cat \/sys\/bus\/w1\/devices\/w1_bus_master1\/w1_master_slave_count\r\n1<\/pre>\n<p>Ak sme nejak\u00e9 zariadenia objav\u00edme tak si m\u00f4\u017eeme pozrie\u0165 ich \u010d\u00edsla<\/p>\n<pre># cat \/sys\/bus\/w1\/devices\/w1_bus_master1\/w1_master_slaves\r\n28-0000019d3c92<\/pre>\n<p>Ke\u010f\u017ee 28 znamen\u00e1 teplomery m\u00f4\u017eeme pou\u017ei\u0165 driver ktor\u00fd n\u00e1m zjednodu\u0161\u00ed pr\u00e1cu <strong>w1_therm<\/strong> t\u00fdm z\u00edskame s\u00fabor w1_slave:<\/p>\n<pre># cat \/sys\/bus\/w1\/devices\/28-0000019d3c92\/w1_slave\r\n60 01 4b 46 7f ff 10 10 b5 : crc=b5 YES\r\n60 01 4b 46 7f ff 10 10 b5 t=22000<\/pre>\n<p>\u010do znemen\u00e1 \u017ee tu m\u00e1m 22 stup\u0148ov presne.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ke\u010f\u017ee u\u017e m\u00e1m HW,FW a aj I2C to 1wire \u0161v\u00e1ba bolo na\u010dase spravi\u0165 kone\u010dn\u00e9 rie\u0161enie.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,3,4,7],"tags":[],"class_list":["post-662","post","type-post","status-publish","format-standard","hentry","category-avr","category-hw-a-sw","category-linux","category-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/zz-indigo.mavipet.sk\/index.php?rest_route=\/wp\/v2\/posts\/662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zz-indigo.mavipet.sk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zz-indigo.mavipet.sk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zz-indigo.mavipet.sk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zz-indigo.mavipet.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=662"}],"version-history":[{"count":1,"href":"https:\/\/zz-indigo.mavipet.sk\/index.php?rest_route=\/wp\/v2\/posts\/662\/revisions"}],"predecessor-version":[{"id":2119,"href":"https:\/\/zz-indigo.mavipet.sk\/index.php?rest_route=\/wp\/v2\/posts\/662\/revisions\/2119"}],"wp:attachment":[{"href":"https:\/\/zz-indigo.mavipet.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zz-indigo.mavipet.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zz-indigo.mavipet.sk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}