#include #define SSID "無線網路SSID" #define PASS "無線網路密碼" void setup() { pinMode(2,INPUT); WiFi.begin( SSID, PASS ); } void loop(){ if(digitalRead(2)==HIGH){ WiFiClientSecure client; if( !client.connect("maker.ifttt.com", 443 ) ) { return; } else { //第二組感應器就把value1=1改成value1=2 String getStr_line = "GET /trigger/sensor_pir/with/key/本段文字替換成您的?value1=1 HTTP/1.1\r\n"; client.print( getStr_line ); client.print( "Host: maker.ifttt.com\n" ); client.print( "Connection: close\r\n\r\n" ); client.stop(); } delay(5000); } } ``` ### 電路接線圖 請注意ESP-01電源是接到3.3V,紅外線感應器的電源是接到5V,別接錯了 ![](http://maker.tn.edu.tw/uploads/tad_book3/image/eps01_powerboard_pir.png) ![](http://maker.tn.edu.tw/uploads/tad_book3/image/DSCF2332.jpg) 接好線路插上變壓器,當紅外線感應器有偵測到動靜時,手機應該馬上就可以收到LINE的通知了 ![](http://maker.tn.edu.tw/uploads/tad_book3/image/Screenshot_20161211-224911.jpg)
進階搜尋