{"id":3445,"date":"2018-12-15T09:53:41","date_gmt":"2018-12-15T00:53:41","guid":{"rendered":"http:\/\/fisherman.jp\/23\/?p=3445"},"modified":"2018-12-19T13:42:28","modified_gmt":"2018-12-19T04:42:28","slug":"%e5%ae%9f%e9%a8%93-i2c-%e6%8e%a5%e7%b6%9a-ae-aqm0802%ef%bc%88lcd%ef%bc%89-raspberry-pi-zero-wh","status":"publish","type":"post","link":"http:\/\/fisherman.jp\/23\/3445","title":{"rendered":"\u5b9f\u9a13 I2C \u63a5\u7d9a AE-AQM0802\uff08LCD\uff09 Raspberry Pi Zero WH"},"content":{"rendered":"<p>\u5b9f\u9a13 I2C \u63a5\u7d9a AE-AQM0802\uff08LCD\uff09 Raspberry Pi Zero WH<br \/>\nAQM0802\uff08400Kbit\/s\uff09 +3.3V\u99c6\u52d5 \u53c2\u8003 <a href=\"https:\/\/www.mankier.com\/8\/i2cset\">i2cset<\/a><\/p>\n<p>\u2605\u30b3\u30de\u30f3\u30c9\u304b\u3089I2C\u3078\u30a2\u30af\u30bb\u30b9<br \/>\n$ sudo raspi-config #I2C \u3092\u6709\u52b9\u306b\u3059\u308b<br \/>\n$ i2cdetect -y 1 #I2C bus 1 \u306b\u63a5\u7d9a\u3055\u308c\u3066\u3044\u308b\u30c7\u30d0\u30a4\u30b9\u3092\u8abf\u3079\u308b<br \/>\n$ i2cset -y 1 0x3e 0x00 0x38 0x39 0x14 0x78 0x5f 0x6a i #1=I2C bus 1 -y=no confirmation i=block data(not 1 byte)<br \/>\n$ i2cset -y 1 0x3e 0x00 0x0c 0x01 i<br \/>\n$ i2cset -y 1 0x3e 0x00 0x06 b #b=one byte data<br \/>\n$ i2cset -y 1 0x3e 0x00 0x80 b #1st line<br \/>\n$ i2cset -y 1 0x3e 0x40 0x48 0x65 0x6c 0x6c 0x6f i #&#8217;Hello&#8217;<br \/>\n<a href=\"http:\/\/fisherman.jp\/23\/3445\/screenshot-from-2018-12-15-09-02-00\" rel=\"attachment wp-att-3446\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3446\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-15-09-02-00-80x80.png\" alt=\"\" width=\"80\" height=\"80\" \/><\/a> <a href=\"http:\/\/fisherman.jp\/23\/3445\/screenshot-from-2018-12-15-09-36-32\" rel=\"attachment wp-att-3447\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3447\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-15-09-36-32-80x80.png\" alt=\"\" width=\"80\" height=\"80\" \/><\/a> <a href=\"http:\/\/fisherman.jp\/23\/3445\/screenshot-from-2018-12-15-09-50-15\" rel=\"attachment wp-att-3448\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3448\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-15-09-50-15-80x80.png\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><a href=\"http:\/\/fisherman.jp\/23\/3445\/p1030963\" rel=\"attachment wp-att-3451\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3451\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/P1030963-80x80.jpg\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><a href=\"http:\/\/fisherman.jp\/23\/3445\/p1030964\" rel=\"attachment wp-att-3452\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3452\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/P1030964-80x80.jpg\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><a href=\"http:\/\/fisherman.jp\/23\/3445\/p1030965\" rel=\"attachment wp-att-3453\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3453\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/P1030965-80x80.jpg\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><a href=\"http:\/\/fisherman.jp\/23\/3445\/p1030967\" rel=\"attachment wp-att-3454\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3454\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/P1030967-80x80.jpg\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><\/p>\n<p>\u2605I2C\u901a\u4fe1\u901f\u5ea6\u5909\u66f4 speed \u8981\u518d\u8d77\u52d5<br \/>\n\/boot\/config.txt<br \/>\ndtparam=i2c_baudrate=50000 #50Kbit\/s<br \/>\n<a href=\"http:\/\/fisherman.jp\/23\/3445\/screenshot-from-2018-12-15-15-37-24\" rel=\"attachment wp-att-3462\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3462\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-15-15-37-24-80x80.png\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><\/p>\n<p>\u2605Python3\u304b\u3089I2C\u3078\u30a2\u30af\u30bb\u30b9 \uff08baudrate=400000\uff09 \u52d5\u4f5cOK<\/p>\n<pre>import smbus,time\r\ni2c1=smbus.SMBus(1)\r\ni2c1.write_i2c_block_data(0x3e,0x00,[0x38,0x39,0x14,0x78,0x5f,0x6a])\r\ntime.sleep(0.200) #1=1s 0.001=1ms\r\ni2c1.write_i2c_block_data(0x3e,0x00,[0x0c,0x01])\r\ntime.sleep(0.002) #1=1s 0.001=1ms\r\ni2c1.write_byte_data(0x3e,0x00,0x06)\r\ni2c1.write_byte_data(0x3e,0x00,0x80)\r\ni2c1.write_i2c_block_data(0x3e,0x40,[0x48,0x65,0x6c,0x6c,0x6f]) #'Hello'\r\n<\/pre>\n<p><a href=\"http:\/\/fisherman.jp\/23\/3445\/screenshot-from-2018-12-15-15-49-56\" rel=\"attachment wp-att-3468\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3468\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-15-15-49-56-80x80.png\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><\/p>\n<p>\u2605I2C \u30a8\u30e9\u30fc\u51e6\u7406\u6e96\u5099 \uff08\u901a\u4fe1\u4e2d\u306b SDA,SCL,+3.3V \uff08\u3069\u306e\u4fe1\u53f7\u3067\u3082\uff09\u306e\u969c\u5bb3\u3067\u30a8\u30e9\u30fc\u767a\u751f\uff09<br \/>\n[Errno 121] Remote I\/O error<\/p>\n<pre>import smbus,time\r\n\r\ni2c1=smbus.SMBus(1) #0=(port I2C0), 1=(port I2C1)\r\ni2c1.write_i2c_block_data(0x3e,0x00,[0x38,0x39,0x14,0x78,0x5f,0x6a]); time.sleep(0.200) #200ms\r\ni2c1.write_i2c_block_data(0x3e,0x00,[0x0c,0x01]); time.sleep(0.002) #2ms\r\ni2c1.write_byte_data(0x3e,0x00,0x06)\r\ni2c1.write_byte_data(0x3e,0x00,0x80)\r\ni2c1.write_i2c_block_data(0x3e,0x40,[0x48,0x65,0x6c,0x6c,0x6f]) #'Hello'\r\n\r\nd=1\r\nwhile 1:\r\n    d=0x30+((1+d)%10) #9-0 countdown ascii\r\n    time.sleep(1.000) #1s\r\n    try:\r\n        i2c1.write_byte_data(0x3e,0x00,0xc0) #2nd line\r\n        i2c1.write_byte_data(0x3e,0x40,d)\r\n    except Exception as e:\r\n        pass ;print(e) #error if exist\r\n<\/pre>\n<p><a href=\"http:\/\/fisherman.jp\/23\/3445\/screenshot-from-2018-12-16-07-24-12\" rel=\"attachment wp-att-3473\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3473\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-16-07-24-12-80x80.png\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9f\u9a13 I2C \u63a5\u7d9a AE-AQM0802\uff08LCD\uff09 Raspberry Pi Zero WH AQM0802\uff08400Kbit\/s\uff09 +3.3V\u99c6\u52d5 \u53c2\u8003 i2cset \u2605\u30b3\u30de\u30f3\u30c9\u304b\u3089I2C\u3078\u30a2\u30af\u30bb\u30b9 $ sudo ras [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,32],"tags":[],"class_list":["post-3445","post","type-post","status-publish","format-standard","hentry","category-python","category-raspberry-pi"],"_links":{"self":[{"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/posts\/3445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/comments?post=3445"}],"version-history":[{"count":17,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/posts\/3445\/revisions"}],"predecessor-version":[{"id":3529,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/posts\/3445\/revisions\/3529"}],"wp:attachment":[{"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/media?parent=3445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/categories?post=3445"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/tags?post=3445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}