發表文章

目前顯示的是有「hc-sr04」標籤的文章

MQTT-Nord-RED顯示超音波測距數據+控制LED

圖片
 MQTT-Nord-RED顯示超音波測距數據+控制LED 超音波模組(HC-SC04)測試回顧- 點我回顧 MQTT相關布暑- 點我回顧 #include   <Ultrasonic.h> #include   <WiFi.h> #include   <PubSubClient.h> Ultrasonic   ultrasonic ( 32 ,  33 ); const   char *  ssid  =  "---" ; const   char *  password  =  "-----" ; const   char *  mqttServer  =  "192.168.67.22" ; //wifi客戶端及MQTT客戶端代數 WiFiClient   espClient ; PubSubClient   client ( espClient ); //設定wifi void   wifiConn (){    WiFi . begin ( ssid ,  password );    while  ( WiFi . status () !=  WL_CONNECTED ){      Serial . print ( "." );      delay ( 50 );   }    Serial . println ( "Connected successful!" );    Serial . println ( WiFi . localIP ()); } //檢查訂閱的字串是否含有on和off,如果比對下來是 //nord-red裡的標頭一樣,而且包含on就開燈,off就關燈 void   callback ( char   * topic ,  byte...

超音波測距(HC-SR04)&網頁顯示(wifi_server)

圖片
超音波測距(HC-SR04)&網頁顯示(wifi_server)   超音波測距參考- https://esp32-blairan.blogspot.com/2021/07/blog-post.html 接線 程式碼 #include   <Arduino.h> #include   <WiFi.h> #include   <ESPAsyncWebServer.h> #include   <Ultrasonic.h> // ---------------------     ---------------------     ------------------- //  * | HC-SC04 | Arduino |     | PING))) | Arduino |     | Seeed | Arduino | //  * ---------------------     ---------------------     ------------------- //  * |   Vcc   |   5V    |     |   Vcc   |   5V    |     | ...

超音波&0.96OLED

圖片
  超音波&0.96OLED 0.96OLED實作參考 - https://esp32-blairan.blogspot.com/2021/05/091oled-esp32.html 超音波(Arduino)實作參考 - https://blairandreamwork.blogspot.com/2021/05/hc-sr04.html 超音波和Arduino上的模組大同小義,不過我使用的模組比一般簡單多了,省去 計算,直接呼叫函式就能取得inc和cm。 接線 --------------------------        ---------------------      //  * | HC-SC04 | ESP32  |     |    OLED | ESP32 | //  * ---------------------     ---------------------      //  * |   Vcc   |   3.3V  |     | Vcc | 3.3V | //  * |   Trig  |   32    |      | Gnd | GND | //  * |   Echo  |   33  ...