{"id":150693,"date":"2020-09-03T04:12:21","date_gmt":"2020-09-02T20:12:21","guid":{"rendered":"http:\/\/4563.org\/?p=150693"},"modified":"2020-09-03T04:12:21","modified_gmt":"2020-09-02T20:12:21","slug":"%e6%a0%91%e8%8e%93%e6%b4%be%e7%8e%a9%e5%85%b7%e6%80%8e%e4%b9%88%e4%bc%98%e5%8c%96%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=150693","title":{"rendered":"\u6811\u8393\u6d3e\u73a9\u5177\u600e\u4e48\u4f18\u5316\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6811\u8393\u6d3e\u73a9\u5177\u600e\u4e48\u4f18\u5316\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Breadykid <\/span>  <span><i><\/i> 22<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5176\u5b9e\u6811\u8393\u6d3e\u81ea\u5e26 GPIO \u63a5\u53e3\uff0c\u60f3\u628a\u6211\u76ee\u524d\u7684\u5b9e\u73b0\u53d8\u6210\u820d\u5f03 Arduino\uff0c\u8ba9\u6811\u8393\u6d3e\u76f4\u63a5\u63a5\u5143\u5668\u4ef6\uff0c\u6709\u6ca1\u6709\u597d\u7684\u5efa\u8bae\uff1f readme\u5982\u4e0b\uff1a<\/p>\n<p>\u57fa\u4e8e Rasperry Pi 3B and Arduino \u9009\u578b\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\u5f00\u53d1\u677f\uff1a\n<ul>\n<li>Rasberry Pi 3\uff1a\u4e2d\u592e\u63a7\u5236\u670d\u52a1\u5668\uff0c\u8d1f\u8d23\u4e0e\u4e92\u8054\u7f51\u7684\u901a\u4fe1\u3001\u91c7\u6837\u5b58\u50a8 Arduino \u4e0a\u62a5\u7684\u72b6\u6001\u6570\u636e\u3001\u63d0\u4f9b \/\u8c03\u7528 API \u4ee5\u65b9\u4fbf\u7528\u5176\u4ed6\u7ec8\u7aef\u63a7\u5236\u3002<\/li>\n<li>Arduino UNO\uff1a\u8d1f\u8d23\u4f20\u611f\u5668\u91c7\u6837\uff0c\u548c RPi \u8fdb\u884c\u901a\u4fe1\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u6e29\u5ea6\u4f20\u611f\u5668\uff1aDHT22<\/li>\n<li>\u8bed\u8a00\uff1aPython3,Java8<\/li>\n<li>\u6570\u636e\u5e93\uff1amysql<\/li>\n<\/ul>\n<h2>Arduino<\/h2>\n<pre><code>#include \"DHT.h\" DHT dht(2, DHT22);  void setup() {   Serial.begin(9600);   dht.begin(); }  void loop() {   float humidity = dht.readHumidity();   float temperature = dht.readTemperature();   Serial.print(\"Humidity: \");   Serial.print(humidity);   Serial.print(\" \");   Serial.print(\"Temperature: \");   Serial.println(temperature);   delay(2000); } <\/code><\/pre>\n<h2>RasberryPi 3B<\/h2>\n<h3>\u5b89\u88c5\u7cfb\u7edf<\/h3>\n<p>\u955c\u50cf:<em>raspbian-stretch-lite<\/em><br \/> microSD \u5361:<em>16G<\/em>\uff0c\u63a8\u8350 8G \u4ee5\u4e0a<\/p>\n<ul>\n<li>\n<p>\u5c06 SD \u5361\u683c\u5f0f\u5316:(Mac)\u78c1\u76d8\u5de5\u5177&#8211;&gt;\u62b9\u6389&#8211;&gt;MS-DOS(FAT)&#8211;&gt;\u62b9\u6389<\/p>\n<\/li>\n<li>\n<p>\u7ec8\u7aef <code>df-h<\/code> \u67e5\u770b\u6302\u8f7d\uff0cSD \u5361\u5047\u8bbe\u4e3a \/dev\/disk2s1<\/p>\n<\/li>\n<li>\n<p>\u5378\u8f7d SD \u5361 <code>diskutil unmount \/dev\/disk2s1<\/code><\/p>\n<\/li>\n<li>\n<p><code>diskutil list<\/code> \u786e\u8ba4 \/dev\/disk2 \u4e0b\u7684 disk2<\/p>\n<\/li>\n<li>\n<p>\u5b98\u7f51\u4e0b\u8f7d\u955c\u50cf\uff0c\u5199\u5165 SD \u5361 <code>sudo dd bs=4m if=\u672c\u673a\u955c\u50cf\u8def\u5f84 of=\/dev\/disk2<\/code> \u67e5\u770b\u8fdb\u5ea6\u53ef\u4ee5\u53e6\u8d77\u7ec8\u7aef <code>sudo kill -INFO $(pgrep ^dd)<\/code><\/p>\n<\/li>\n<li>\n<p>\u7531\u4e8e\u6811\u8393\u6d3e\u9ed8\u8ba4\u4e0d\u5f00\u542f ssh\uff0c\u5199\u5165\u6210\u529f\u540e\u5728 \/boot\/ \u521b\u5efa\u65e0\u540e\u7f00\u7684\u6587\u4ef6\u540d\u4e3a ssh \u7684\u6587\u4ef6<\/p>\n<\/li>\n<li>\n<p>\u8bbe\u7f6e\u81ea\u52a8\u8fde\u63a5 Wi-Fi:\u5728 \/boot\/ \u4e0b\u521b\u5efa wpa_supplicant.conf<\/p>\n<pre><code>country=CN ctrl_interface=DIR=\/var\/run\/wpa_supplicant  GROUP=netdev update_config=1 network={  scan_ssid=1#SSID \u88ab\u9690\u85cf\u65f6\u8bbe\u7f6e  ssid=\"TaiGe\"#Wi-Fi \u540d  psk=\"HaoyunHu888\"#Wi-Fi \u5bc6\u7801 } <\/code><\/pre>\n<\/li>\n<li>\n<p>\u5f39\u51fa SD \u5361<code>diskutil unmountDisk \/dev\/disk2<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\uff0cRasberryPi \u7684\u7cfb\u7edf\u5b89\u88c5\u5b8c\u6210\uff0c\u53ef\u4ee5\u5c06 SD \u5361\u63d2\u5165\u5f00\u53d1\u7248\u4e0a\u7535\u5f00\u673a\u4e86<\/p>\n<h3>\u767b\u5f55\u7cfb\u7edf<\/h3>\n<h5>SSH<\/h5>\n<pre><code>ssh [email&#160;protected] default password: raspberry <\/code><\/pre>\n<p>\u901a\u8fc7\u8def\u7531\u5668\u67e5\u770b\u6811\u8393\u6d3e\u7684\u5f53\u524d ip:<\/p>\n<ul>\n<li>\u6253\u5f00\u7f51\u9875<code>192.168.1.1<\/code>\uff0c\u767b\u5f55\u7cfb\u7edf<\/li>\n<li>\u72b6\u6001 \/\u7528\u6237\u4fa7\u4fe1\u606f \/\u4ee5\u592a\u7f51\u63a5\u53e3\u4fe1\u606f \/\uff0c\u627e\u5230\u5ba2\u6237\u7aef\u540d\u79f0\u4e3a raspberrypi \u7684 IP \u5730\u5740: <code>***.**.**.*<\/code><\/li>\n<\/ul>\n<p>\u5173\u673a<code>sudo shutdown -h now<\/code>\uff0c\u91cd\u65b0\u4e0a\u7535\u540e\u4f1a\u81ea\u52a8\u5f00\u673a<\/p>\n<ul>\n<li>\u7cfb\u7edf\u5b89\u88c5\u53c2\u8003<\/li>\n<li>\u67e5\u770b rpiIP \u53c2\u8003<\/li>\n<\/ul>\n<h2>RaspberryPi \u8bfb\u53d6 Arduino \u6570\u636e<\/h2>\n<h3>\u5b89\u88c5 Python3<\/h3>\n<p><code>sudo aptitude install python-dev<\/code><\/p>\n<h3>\u5b89\u88c5 Python \u7684 GPIO \u6a21\u5757<\/h3>\n<p>\u7528\u4e8e\u63a7\u5236 LED \u3001\u7535\u673a\u7b49<\/p>\n<pre><code>sudo apt-get install rpi.gpio  <\/code><\/pre>\n<h3>\u5b89\u88c5 Serial<\/h3>\n<p>\u7528\u4e8e\u4e32\u53e3\u901a\u4fe1\u53ca USB \u901a\u4fe1<code>sudo apt-get install python-serial<\/code><\/p>\n<h3>\u5b89\u88c5\u4e32\u53e3\u8c03\u8bd5\u7a0b\u5e8f<\/h3>\n<p>minicom \u662f linux \u5e73\u53f0\u4e32\u53e3\u8c03\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u7528\u5b83\u6765\u8bfb\u53d6 Arduino \u901a\u8fc7 USB \u4e32\u53e3\u53d1\u9001\u7684\u4f20\u611f\u5668\u6570\u503c\u3002<\/p>\n<ul>\n<li>\n<p>\u5728 RaspberryPi \u4e0a\u5b89\u88c5 minicom\uff1a<code>sudo apt-get install minicom<\/code><\/p>\n<\/li>\n<li>\n<p>\u914d\u7f6e minicom\uff1a<\/p>\n<\/li>\n<li>\n<p>minicom \u542f\u52a8\uff1a<code>minicom -b 9600 -D \/dev\/ttyACM0<\/code><\/p>\n<ul>\n<li>-b \u4ee3\u8868\u6ce2\u7279\u7387<\/li>\n<li>-D \u4ee3\u8868\u7aef\u53e3<\/li>\n<li>\/dev\/ttyACM0 \u4ee3\u8868\u6253\u5f00\u4e0e Arduino \u76f8\u8fde\u7684\u7aef\u53e3<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Python \u6253\u5370\u6570\u636e<\/h3>\n<p>show.py<\/p>\n<pre><code>import serial ser = serial.Serial('\/dev\/ttyACM0',9600) info = ser.readline() while info:     print(info)     info = ser.readline() <\/code><\/pre>\n<p>Python \u8c03\u7528 http API \u5b89\u88c5 requests <code>sudo pip install requests<\/code><\/p>\n<p>\u540e\u53f0\u8fd0\u884c py \u811a\u672c<br \/> <code>nohup python api.py &amp;<\/code><\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>1<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2982007\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tankren <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5305\u4fdd\u9c9c\u819c\u9632\u5c18                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6811\u8393\u6d3e\u73a9\u5177\u600e\u4e48\u4f18\u5316\uff1f \u8cc7\u6df1\u5927\u4f6c :&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/150693"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=150693"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/150693\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=150693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=150693"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=150693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}