{"id":3607,"date":"2018-12-28T03:20:13","date_gmt":"2018-12-27T18:20:13","guid":{"rendered":"http:\/\/fisherman.jp\/23\/?p=3607"},"modified":"2018-12-28T03:59:35","modified_gmt":"2018-12-27T18:59:35","slug":"uart-%e3%82%b7%e3%83%aa%e3%82%a2%e3%83%ab%e9%80%9a%e4%bf%a1-raspberry-pi-zero-wh","status":"publish","type":"post","link":"http:\/\/fisherman.jp\/23\/3607","title":{"rendered":"UART \u30b7\u30ea\u30a2\u30eb\u901a\u4fe1 PythonRaspberry Pi Zero WH"},"content":{"rendered":"<p>UART \u30b7\u30ea\u30a2\u30eb\u901a\u4fe1 Python Raspberry Pi Zero WH <a href=\"https:\/\/www.electronicwings.com\/raspberry-pi\/raspberry-pi-uart-communication-using-python-and-c\">\u53c2\u7167<\/a> <a href=\"https:\/\/pyserial.readthedocs.io\/en\/latest\/shortintro.html\">\u53c2\u7167<\/a><br \/>\n\u5b9f\u9a13 \u30eb\u30fc\u30d7\u30d0\u30c3\u30af \uff08UART0 TxD\uff09-\uff08UART0 RxD\uff09 \u3092\u63a5\u7d9a<br \/>\n$ vcgencmd version #\u30d5\u30a1\u30fc\u30e0\u30a6\u30a8\u30a2\u30d0\u30fc\u30b8\u30e7\u30f3<br \/>\nNov 4 2018 16:31:07<br \/>\n$ uname -a #\u30ab\u30fc\u30cd\u30eb\u30d0\u30fc\u30b8\u30e7\u30f3<br \/>\nLinux 000003 4.14.79+ #1159 Sun Nov 4 17:28:08 GMT 2018 armv6l GNU\/Linux<br \/>\n\u30e9\u30ba\u30d9\u30ea\u30fc\u30d1\u30a4\u8a2d\u5b9a\uff08$ sudo raspi-config\uff09<br \/>\nSerial Port: Enable<br \/>\nSerial Console: Disable<br \/>\n$ sudo mc #midnight commander<br \/>\n\/boot\/config.txt<br \/>\nenable_uart=1<br \/>\n$ ls -l \/dev<br \/>\nserial0 -&gt; ttyS0<\/p>\n<pre>import serial,time\r\n\r\n#s=serial.Serial('\/dev\/serial1', 115200, timeout=10) #not work\r\n#s=serial.Serial('\/dev\/AMA0', 115200, timeout=10) #not work\r\n#s=serial.Serial('\/dev\/serial0', 115200, timeout=10) #work good\r\ns=serial.Serial('\/dev\/ttyS0', 115200, timeout=10) #work good\r\n\r\nwhile 1:\r\n    s.write(b'ABCDEFG')\r\n    time.sleep(1.6) #2=2s 0.001=1ms\r\n    print(s.readline())\r\n    #x=s.read( ) #read 1 byte\r\n    #x=s.read(4) #read 4 byte\r\n    \r\ns.close()\r\n<\/pre>\n<p><a href=\"http:\/\/fisherman.jp\/23\/3607\/screenshot-from-2018-12-28-03-21-54\" rel=\"attachment wp-att-3611\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3611\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-28-03-21-54-80x80.png\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><a href=\"http:\/\/fisherman.jp\/23\/3607\/screenshot-from-2018-12-28-03-26-23\" rel=\"attachment wp-att-3613\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3613\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-28-03-26-23-80x80.png\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><a href=\"http:\/\/fisherman.jp\/23\/3607\/screenshot-from-2018-12-28-03-29-06\" rel=\"attachment wp-att-3617\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3617\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-28-03-29-06-80x80.png\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><a href=\"http:\/\/fisherman.jp\/23\/3607\/screenshot-from-2018-12-28-03-43-05\" rel=\"attachment wp-att-3619\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3619\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-28-03-43-05-80x80.png\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>UART \u30b7\u30ea\u30a2\u30eb\u901a\u4fe1 Python Raspberry Pi Zero WH \u53c2\u7167 \u53c2\u7167 \u5b9f\u9a13 \u30eb\u30fc\u30d7\u30d0\u30c3\u30af \uff08UART0 TxD\uff09-\uff08UART0 RxD\uff09 \u3092\u63a5\u7d9a $ vcgencmd version #\u30d5\u30a1\u30fc\u30e0\u30a6\u30a8 [&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-3607","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\/3607","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=3607"}],"version-history":[{"count":11,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/posts\/3607\/revisions"}],"predecessor-version":[{"id":3622,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/posts\/3607\/revisions\/3622"}],"wp:attachment":[{"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/media?parent=3607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/categories?post=3607"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/tags?post=3607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}