Cov txheej txheem:

[Tsev IoT] ESP8266 MQTT Client Device: 7 Kauj Ruam
[Tsev IoT] ESP8266 MQTT Client Device: 7 Kauj Ruam

Video: [Tsev IoT] ESP8266 MQTT Client Device: 7 Kauj Ruam

Video: [Tsev IoT] ESP8266 MQTT Client Device: 7 Kauj Ruam
Video: Hmong Fresno New Year 1992 1993 2024, Kaum ib hlis
Anonim
[Tsev IoT] ESP8266 MQTT Client Device
[Tsev IoT] ESP8266 MQTT Client Device
[Tsev IoT] ESP8266 MQTT Client Device
[Tsev IoT] ESP8266 MQTT Client Device
[Tsev IoT] ESP8266 MQTT Client Device
[Tsev IoT] ESP8266 MQTT Client Device

Nws yog qhov nthuav uas siv qhov pheej yig WiFi-qhib MCU nrog MQTT raws tu qauv los tswj cov khoom siv xws li lub tshuab nqus dej tsis siv neeg rau kuv tus miv. Muaj kuv qhov blog kom paub cov ntaub ntawv ntxaws ntxaws (https://regishsu.blogspot.com/2019/09/home-iot-esp…

Kev qhia tshwj xeeb:

  1. txuas mus rau qhov tau npaj ua ntej Access-Point SSID thiab MQTT broker
  2. tswj kev xa rov qab qhib/tua 3mins ib ntus, esp8266 yuav nkag mus rau qhov tsaug zog thaum lub sijhawm xa tawm.
  3. Kev tswj chaw taws teeb los ntawm MQTT raws tu qauv los ntawm lub xov tooj ntawm tes

Kauj ruam 1: Kev piav qhia

Nqe lus piav qhia
Nqe lus piav qhia

ECO system yuav yog

Raspberry Pi 3B+

  1. MQTT broker
  2. Python: paho-mqtt, yuav siv ntau yam ntxiv rau yav tom ntej, piv txwv li thawb ceeb toom rau lub xov tooj ntawm tes nrog kev tshuaj xyuas cov ntaub ntawv.

ESP8266

  1. tswj lub relay
  2. raws li MQTT Client

Kauj ruam 2: Schematic & Cheebtsam

Schematic & Cheebtsam
Schematic & Cheebtsam
Schematic & Cheebtsam
Schematic & Cheebtsam

Daim ntawv teev npe Parts

  • 1 x ESP6266 12E
  • 1 x 2P relay module
  • 2 x S8050 transistor
  • 2 x 100 ohm resistor
  • 1 x 10 uF capacitor
  • 1 x 0.1uF capacitor
  • 1 x LM1117 3.3v module
  • 1 x HLK-PM01 230V AC rau 5V/3W DC lub zog hluav taws xob
  • 1 x 5x7cm perfboard 1 x AC Hluav taws xob qhov (socket)

Cov Cuab Yeej:

  • 1 x 3D tshuab luam ntawv nrog PLA filament
  • 1 x Soldering hlau

Khoom siv

  • 1 x Raspberry pi 3B+
  • 1 x Dej pub piv txwv

Kauj Ruam 3: Kev Tso Chaw thiab Kev Siv Soldering

Kev Tso Chaw thiab Kev Siv Tshuaj
Kev Tso Chaw thiab Kev Siv Tshuaj
Kev Tso Chaw thiab Kev Siv Tshuaj
Kev Tso Chaw thiab Kev Siv Tshuaj
Kev Tso Chaw thiab Kev Siv Tshuaj
Kev Tso Chaw thiab Kev Siv Tshuaj
Kev Tso Chaw thiab Kev Siv Tshuaj
Kev Tso Chaw thiab Kev Siv Tshuaj

Kuv tso 2 transistors thiab resistors nyob rau hauv ESP8266 module kom txuag tau qhov chaw.

Ua tib zoo saib xyuas cov xov hlau thiab kev tso chaw yuav tsum tsis txhob cuam tshuam nrog lwm tus xov hlau.

Daim ntawv ceeb toom:

Ib qho ntxiv yog ua qhov "qhib/luv" tshuaj xyuas los ntawm multimeter kom ntseeg tau tias txhua lub xaim yog qhov txuas zoo.

Kauj ruam 4: Xeem

Kev Xeem
Kev Xeem
Kev Xeem
Kev Xeem

Muaj 3 ntu yuav tsum npaj kom zoo rau kev xeem. Hloov kho qhov kos duab ntawm SSID/Password, tsim cov duab kos thiab xa mus rau ESP8266, teeb tsa MQTT broker ntawm RPI 3B+.

Teeb MQTT broker (Nws yog qhov kev xaiv yog tias koj muaj MQTT broker twb tau ua lawm)

teeb tsa pob ntsig ntsig txog RPI 3B+, thiab yuav pib MQTT tus pabcuam kev pabcuam tau txais.

  • sudo apt hloov tshiab
  • sudo apt hloov kho sudo apt autoremove sudo apt autoclean sudo apt-tau nruab mosquitto mosquitto-neeg siv

txheeb xyuas qhov kev pabcuam MQTT

kev pabcuam tsis pub dhau qhov xwm txheej

Upload tus kos duab kos

Rub tawm daim duab kos [yooj yim version] thiab hloov kho SSID / Password thiab MQTT broker IP chaw nyob.

  • #define AP_SSID "koj-ssid"
  • #define AP_PASSWD "password"
  • #define MQTT_BROKER "xxx.xxx.xxx.xxx"

thiab tom qab ntawd rub cov duab kos rau ESP8266 tus qauv.

Qhib lub davhlau ya nyob twg ntawm Arduino IDE ntawm PC kom taug qab lub cav los ntawm ESP8266, qhib lub zog siv, esp8266 yuav pib txuas rau koj li Wifi AP thiab tom qab ntawd txuas rau MQTT broker.

Kauj Ruam 5: Xeem - MQTT Apps ntawm Xov Tooj Ntawm Tes

Kev Xeem - MQTT Apps ntawm Xov Tooj Ntawm Tes
Kev Xeem - MQTT Apps ntawm Xov Tooj Ntawm Tes
Kev Xeem - MQTT Apps ntawm Xov Tooj Ntawm Tes
Kev Xeem - MQTT Apps ntawm Xov Tooj Ntawm Tes
Kev Xeem - MQTT Apps ntawm Xov Tooj Ntawm Tes
Kev Xeem - MQTT Apps ntawm Xov Tooj Ntawm Tes
Kev Xeem - MQTT Apps ntawm Xov Tooj Ntawm Tes
Kev Xeem - MQTT Apps ntawm Xov Tooj Ntawm Tes

Txhawm rau txheeb xyuas qhov ESP8266 tus qauv no tuaj yeem tswj hwm los ntawm lwm tus MQTT cov cuab yeej, muaj ntau txoj hauv kev los ua.

Txoj Kev 1: Xa cov lus txib los ntawm RPI los ntawm Python. (yuav ua li cas rau nruab Mqtt cov cuab yeej)

  • Siv cov relay 1-
  • mosquitto_pub -h xx.xx.xx.xx -t Tsev/esp32_sub -m "11"
  • Tshem tawm relay 1-
  • mosquitto_pub -h xx.xx.xx.xx -t Tsev/esp32_sub -m "10"

Txoj Kev 2: Siv Lub Xov Tooj Ntawm Tes

  • Kuv tau sim ntau Apps, tab sis vim li cas kuv thiaj qhia qhov no? Vim tias nws zoo li yooj yim rau kuv lub taub hau ruam, Nws paub tseeb tias koj tuaj yeem siv lwm tus los ntawm koj tus kheej nyiam.
  • Ua raws cov duab txhawm rau teeb tsa MQTT tus tswv lag luam thiab hloov khawm ntxiv rau lub cav.

Kauj Ruam 6: Ua Rooj plaub (Rau Siv)

Ua Rooj plaub (Rau Siv)
Ua Rooj plaub (Rau Siv)
Ua Rooj plaub (Rau Siv)
Ua Rooj plaub (Rau Siv)
Ua Rooj plaub (Rau Siv)
Ua Rooj plaub (Rau Siv)

Kuv siv Sketchup los ua qhov teeb meem no.

Kauj Ruam 7: Lwm Qhov Kev Txhim Kho Zoo (Rau Siv)

Lwm Qhov Kev Txhim Kho Zoo (Rau Kev Siv)
Lwm Qhov Kev Txhim Kho Zoo (Rau Kev Siv)
Lwm Qhov Kev Txhim Kho Zoo (Rau Kev Siv)
Lwm Qhov Kev Txhim Kho Zoo (Rau Kev Siv)

Kuv tau ua qee qhov muaj txiaj ntsig zoo uas tuaj yeem teeb tsa chaw nyob SSID/Password thiab Borker IP chaw nyob. Thiab tseem tuaj yeem yog OTA txhawm rau rub cov duab kos, cov ncauj lus kom ntxaws nyob ntawm no (https://regishsu.blogspot.com/2019/07/home-iot-esp8266-mqtt-client-device-iot.html)

Pom zoo: