Cov txheej txheem:

ESP8266 thiab Visuino: DHT11 Kub thiab Vaum Web Server: 12 Cov Kauj Ruam
ESP8266 thiab Visuino: DHT11 Kub thiab Vaum Web Server: 12 Cov Kauj Ruam

Video: ESP8266 thiab Visuino: DHT11 Kub thiab Vaum Web Server: 12 Cov Kauj Ruam

Video: ESP8266 thiab Visuino: DHT11 Kub thiab Vaum Web Server: 12 Cov Kauj Ruam
Video: Уроки Ардуино. Управление нагрузкой в сети переменного тока 2024, Kaum ib hlis
Anonim
Image
Image

ESP8266 cov qauv yog cov nqi qis uas sawv ib leeg tswj nrog ua hauv Wi-nkaus, thiab kuv twb tau ua tus lej Qhia Qhia txog lawv.

DTH11/DTH21/DTH22 thiab AM2301 yog qhov nrov heev ua ke Kub thiab Vaum Arduino ntsuas, thiab kuv tau ua tus lej Qhia Qhia nrog lawv ib yam nkaus, suav nrog Cov Lus Qhia ntawm Cov Ntsuas Kub Kub thiab Cov Ntsuas Ntsuas nrog 2 ESP8266 txuas ua ke ntawm lawv tus kheej ntiag tug Wi-nkaus network.

Hauv Cov Lus Qhia no kuv yuav qhia koj li cas koj tuaj yeem ua Tus Kub thiab Vaum Web Server nrog ESP8266 thiab DHT11 thiab txuas rau nws ntawm koj lub network Wi-nkaus uas twb muaj lawm los ntawm ntau yam khoom siv nrog lub vev xaib.

Kauj Ruam 1: Cheeb Tsam

Txuas DHT11 mus rau NodeMCU ESP8266 Module
Txuas DHT11 mus rau NodeMCU ESP8266 Module
  1. OneNodeMCU ESP8266 board (Kuv siv NodeMCU 0.9 version, tab sis lwm yam, lossis txawm sawv ib leeg ESP-12 lossis ESP-01 yuav ua haujlwm)
  2. Ib DHT11 Sensor module Kuv tau txais los ntawm qhov pheej yig 37 lub teeb ntsuas
  3. 3 Poj niam-Poj niam jumper xov hlau

Kauj Ruam 2: Txuas DHT11 mus rau NodeMCU ESP8266 Module

Txuas DHT11 mus rau NodeMCU ESP8266 Module
Txuas DHT11 mus rau NodeMCU ESP8266 Module
Txuas DHT11 mus rau NodeMCU ESP8266 Module
Txuas DHT11 mus rau NodeMCU ESP8266 Module
Txuas DHT11 mus rau NodeMCU ESP8266 Module
Txuas DHT11 mus rau NodeMCU ESP8266 Module
  1. Txuas Lub Hwj Huam (Liab Hlau), Hauv av (Dub hlau), thiab Cov Ntaub Ntawv (Grey hlau) mus rau DHT11 Module (Daim duab 1 qhia 2 yam sib txawv ntawm DHT11 sensor modules. Raws li koj tuaj yeem pom cov pins yuav txawv, yog li txuas nrog ua tib zoo!)
  2. Txuas lwm qhov kawg ntawm Cov Av Hauv av (Cov xaim dub) mus rau hauv av tus pin ntawm ESP8266 module (Duab 2)
  3. Txuas lwm qhov kawg ntawm Lub Hwj Chim Hluav Taws Xob (Hlau liab) mus rau 3.3V Lub hwj chim tus pin ntawm ESP8266 module (Duab 2)
  4. Txuas lwm qhov kawg ntawm Cov Ntaub Ntawv xov hlau (Grey hlau) mus rau Digital pin 2 ntawm ESP8266 module (Duab 3)
  5. Daim duab 4 qhia qhov twg yog av, 3.3V Fais Fab, thiab Digital 2 pins ntawm NodeMCU 0.9

Kauj Ruam 3: Pib Visuino, thiab Xaiv ESP8266 Pawg Thawj Tswj Hwm

Pib Visuino, thiab Xaiv ESP8266 Pawg Thawj Tswj Hwm
Pib Visuino, thiab Xaiv ESP8266 Pawg Thawj Tswj Hwm
Pib Visuino, thiab Xaiv ESP8266 Pawg Thawj Tswj Hwm
Pib Visuino, thiab Xaiv ESP8266 Pawg Thawj Tswj Hwm

Txhawm rau pib ua haujlwm rau Arduino, koj yuav tsum muaj Arduino IDE teeb tsa los ntawm no:

Thov nco ntsoov tias muaj qee qhov teeb meem tseem ceeb hauv Arduino IDE 1.6.6

Nco ntsoov tias koj nruab 1.6.7 lossis siab dua, txwv tsis pub Cov Lus Qhia no yuav tsis ua haujlwm!

Yog tias koj tsis tau ua raws cov kauj ruam hauv Cov Lus Qhia no teeb tsa Arduino IDE rau program ESP 8266

Visuino: https://www.visuino.com kuj tseem yuav tsum tau teeb tsa.

  1. Pib Visuinoas pom hauv thawj daim duab
  2. Nyem rau ntawm "Cov cuab yeej" khawm ntawm Arduino tivthaiv (Daim duab 1) hauv Visuino
  3. Thaum cov lus sib tham tshwm, xaiv "NodeMCU ESP-12" raws li qhia hauv daim duab 2

Kauj Ruam 4: Hauv Visuino: Teem Tus Tswv Lub Npe thiab Chaw Nkag Mus

Hauv Visuino: Teem Tus Tswv Lub Npe thiab Chaw Nkag Mus
Hauv Visuino: Teem Tus Tswv Lub Npe thiab Chaw Nkag Mus
Hauv Visuino: Teem Tus Tswv Lub Npe thiab Access Point
Hauv Visuino: Teem Tus Tswv Lub Npe thiab Access Point
Hauv Visuino: Teem Tus Tswv Lub Npe thiab Chaw Nkag Mus
Hauv Visuino: Teem Tus Tswv Lub Npe thiab Chaw Nkag Mus
Hauv Visuino: Teem Tus Tswv Lub Npe thiab Access Point
Hauv Visuino: Teem Tus Tswv Lub Npe thiab Access Point

Ua ntej peb yuav tsum teeb tsa tus qauv txhawm rau txuas rau Access Point uas twb muaj lawm thiab muab HostName rau nws yog li peb tuaj yeem tshawb pom nws ntawm lub network.

  1. Hauv Tus Kws Tshuaj Ntsuam Xyuas, nthuav cov "Cov Qauv" cov khoom, tom qab ntawd "WiFi" cov khoom qub
  2. Hauv Tus Kws Tshuaj Ntsuam Xyuas teeb tsa tus nqi ntawm "HostName" cov khoom rau "dht11server" (Daim duab 1)
  3. Hauv Tus Kws Tshuaj Ntsuam Xyuas, nthuav cov "AccessPoints" cov khoom ntiag tug ntawm "WiFi", thiab nyem rau ntawm "…" khawm tom ntej ntawm nws tus nqi (Daim duab 2)
  4. Hauv qhov "AccessPoins" tus khoos phis tawj, xaiv "WiFi Access Point" nyob rau sab xis, thiab tom qab ntawd nyem rau "+" khawm ntawm sab laug kom ntxiv qhov nkag mus (Duab 2)
  5. Hauv Tus Kws Tshuaj Ntsuam Xyuas, teeb tus nqi ntawm "SSID" cov khoom rau SSID ntawm koj li Wi-Fi Hotspot (Access Point) (Duab 4)
  6. Yog tias koj li Wi-Fi Hotspot (Access Point) xav tau lo lus zais, Hauv Tus Kws Tshuaj Ntsuam Xyuas, teeb tus password rau tus nqi ntawm tus lej "Password" (Duab 4)
  7. Kaw qhov "AccessPoints" sib tham

Kauj Ruam 5: Hauv Visuino: Ntxiv TCP/IP Server Socket rau Kev Sib Txuas Lus

Hauv Visuino: Ntxiv TCP/IP Server Socket rau Kev Sib Txuas Lus
Hauv Visuino: Ntxiv TCP/IP Server Socket rau Kev Sib Txuas Lus
Hauv Visuino: Ntxiv TCP/IP Server Socket rau Kev Sib Txuas Lus
Hauv Visuino: Ntxiv TCP/IP Server Socket rau Kev Sib Txuas Lus
Hauv Visuino: Ntxiv TCP/IP Server Socket rau Kev Sib Txuas Lus
Hauv Visuino: Ntxiv TCP/IP Server Socket rau Kev Sib Txuas Lus

Tom ntej no peb yuav tsum ntxiv TCP/IP Server qhov (socket) rau kev sib txuas lus.

  1. Hauv Tus Kws Tshuaj Ntsuam Xyuas, nyem rau lub pob “…” nyob ib sab ntawm tus nqi ntawm “Qhov Ntsuas” cov khoom ntiag tug ntawm WiFi (Duab 1)
  2. Hauv qhov hloov kho qhov khoom xaiv "TCP/IP Server", thiab tom qab ntawd nyem rau ntawm "+" khawm (Daim duab 2) ntxiv ib qho (Duab 3)
  3. Kaw qhov "Sockets" dialog

Kauj Ruam 6: Hauv Visuino: Ntxiv DTH11 thiab Cov Qauv Ntawv Sib Piv Nrog 2 Qhov Sib Piv

Hauv Visuino: Ntxiv DTH11 thiab Cov Qauv Ntawv Sib Piv Nrog 2 Qhov Sib Piv
Hauv Visuino: Ntxiv DTH11 thiab Cov Qauv Ntawv Sib Piv Nrog 2 Qhov Sib Piv
Hauv Visuino: Ntxiv DTH11 thiab Cov Qauv Ntawv Sib Piv Nrog 2 Qhov Sib Piv
Hauv Visuino: Ntxiv DTH11 thiab Cov Qauv Ntawv Sib Piv Nrog 2 Qhov Sib Piv
Hauv Visuino: Ntxiv DTH11 thiab Cov Qauv Ntawv Sib Piv Nrog 2 Qhov Sib Piv
Hauv Visuino: Ntxiv DTH11 thiab Cov Qauv Ntawv Sib Piv Nrog 2 Qhov Sib Piv

Txhawm rau tswj thiab nyeem Qhov Kub thiab Vaum los ntawm DHT11 peb yuav tsum tau ntxiv cov khoom siv rau nws hauv Visuino.

Peb kuj yuav tsum tsim lub vev xaib los ntawm cov ntaub ntawv. Nplooj ntawv tsuas yog cov ntawv HTML nkaus xwb, yog li peb tuaj yeem siv Cov Ntawv Sib Koom Cov Ntawv los tsim nws.

  1. Ntaus "dht" hauv Lub Lim Lim ntawm Lub Cuab Yeej Cuab Yeej ntawd xaiv "Humidity and Thermometer DHT11/21/22/AM2301" tivthaiv (Daim duab 1), thiab tso rau hauv qhov tsim
  2. Ntaus "daim ntawv" hauv Lub Lim Lim ntawm Cov Ntawv Cuab Yeej Cuab Yeej ces xaiv "Cov Ntawv Sib Koom" (Daim Duab 2), thiab tso rau hauv qhov tsim
  3. Nyem rau ntawm "Cov Cuab Yeej" khawm ntawm Cov Qauv Txheej Txheem 1 (Daim duab 3)
  4. Hauv Elements editor, xaiv Cov Qauv Sib Piv ntawm sab xis, thiab nyem 2 zaug ntawm "+" khawm ntawm sab laug (Daim duab 4), ntxiv 2 ntawm lawv (Duab 5)
  5. Kaw qhov "Elements" editor

Kauj Ruam 7: Hauv Visuino: Teeb Cov Qauv Ntawv rau Cov Neeg Siv Khoom Teb

Hauv Visuino: Teeb Cov Qauv Ntawv rau Cov Neeg Siv Khoom Teb
Hauv Visuino: Teeb Cov Qauv Ntawv rau Cov Neeg Siv Khoom Teb
Hauv Visuino: Teeb Cov Qauv Ntawv rau Cov Neeg Siv Khoom Teb
Hauv Visuino: Teeb Cov Qauv Ntawv rau Cov Neeg Siv Khoom Teb

Peb yuav tsum tau hais kom meej cov ntawv HTML uas yuav raug tsim thaum lub vev xaib siv txuas rau lub server.

Peb yuav hais qhia qhov kev sib txuas kom kaw tom qab cov ntaub ntawv kuv tau xa, thiab tseem yuav qhia tus browser kom rov qhib dua (Rov ua dua tshiab) tom qab 5 vib nas this los ntawm kev ntxiv "Refresh: 5" rau hauv daim ntawv. Txoj kev no lub vev xaib yuav rov ua dua tshiab txhua 5 vib nas this.

  1. Hauv Cheeb Tsam Tsim, xaiv cov Txheej Txheem Txheej Txheem 1 (Daim Duab 1)
  2. Hauv Tus Kws Tshuaj Ntsuam Xyuas xaiv cov khoom "Ntawv", thiab nyem rau ntawm "…" khawm ntawm nws tus nqi (Daim duab 1)
  3. Hauv "Text" editor type: "HTTP/1.1 200 OK" "Content-Type: text/html" "Connection: close" "Refresh: 5" "" """"""" Kub: %0 "" Vaum: %1 "" "" "(Daim duab 2) %0 yuav raug hloov nrog tus nqi los ntawm AnalogElement1, thiab %1 yuav raug hloov nrog tus nqi los ntawm AnalogElement2
  4. Nyem rau ntawm lub pob OK los kaw qhov kev sib tham

Kauj Ruam 8: Hauv Visuino: Txuas DHT11 Cheeb Tsam

Hauv Visuino: Txuas DHT11 Cheeb Tsam
Hauv Visuino: Txuas DHT11 Cheeb Tsam
Hauv Visuino: Txuas DHT11 Cheeb Tsam
Hauv Visuino: Txuas DHT11 Cheeb Tsam
Hauv Visuino: Txuas DHT11 Cheeb Tsam
Hauv Visuino: Txuas DHT11 Cheeb Tsam
  1. Txuas tus "Kub" tso zis tus pin ntawm HumidityThermometer1 tivthaiv rau "Hauv" tus pin ntawm AnalogElement1 ntawm FormattedText1 tivthaiv (Daim duab 1)
  2. Txuas "Humidity" tus pin tso tawm ntawm HumidityThermometer1 tivthaiv rau "Hauv" tus pin ntawm AnalogElement2 ntawm FormattedText1 tivthaiv (Daim duab 2)
  3. Txuas tus "Sensor" tus pin ntawm HumidityThermometer1 tivthaiv rau "Digital" tus lej nkag ntawm "Digital [2]" channel ntawm Arduino tivthaiv (Daim duab 3)

Kauj Ruam 9: Hauv Visuino: Ntxiv thiab Txuas Ntug Ntug Ntes Sib Koom

Hauv Visuino: Ntxiv thiab Txuas Ntug Ntug Ntes
Hauv Visuino: Ntxiv thiab Txuas Ntug Ntug Ntes
Hauv Visuino: Ntxiv thiab Txuas Ntug Ntug Ntes
Hauv Visuino: Ntxiv thiab Txuas Ntug Ntug Ntes
Hauv Visuino: Ntxiv thiab Txuas Ntug Ntug Ntes
Hauv Visuino: Ntxiv thiab Txuas Ntug Ntug Ntes
Hauv Visuino: Ntxiv thiab Txuas Ntug Ntug Ntes
Hauv Visuino: Ntxiv thiab Txuas Ntug Ntug Ntes

Peb yuav tsum xa cov ntawv HTML txhua lub sijhawm muaj kev sib txuas tshiab. Ua ntej peb xa peb yuav tsum tau tos me ntsis txij li lub vev xaib yuav tsum xa daim ntawv thov ua ntej lawv cia siab tias yuav pom qhov tshwm sim. Txhawm rau ua qhov ntawd peb yuav siv Kev ncua ntu txuas nrog "Txuas" tus pin ntawm TCP/IP Server Socket.

  1. Ntaus "ncua" hauv Lub Lim Lim ntawm Cov Ntawv Cuab Yeej Cuab Yeej ces xaiv qhov "Ncua Sijhawm" tivthaiv (Daim duab 1), thiab tso rau hauv thaj chaw tsim
  2. Hauv Cov Khoom teeb tsa tus nqi ntawm "Interval (uS)" cov khoom rau 200000 (Daim duab 2)
  3. Txuas tus "Txuas" tus pin ntawm "Modules. WiFi. Sockets. TCPServer1" ntawm "NodeMCU ESP-12" tivthaiv, mus rau "Hauv" tus pin ntawm Delay1 tivthaiv (Duab 3)
  4. Txuas tus "Tawm" tus pin ntawm Delay1 tivthaiv rau "Clock" tus pin nkag ntawm FormattedText1 tivthaiv (Daim duab 4)

Kauj Ruam 10: Hauv Visuino: Txuas Tus Txheej Txheem Cov Ntawv Teev Npe, thiab Ntxiv thiab Txuas Ncua Sijhawm Sib Koom

Hauv Visuino: Txuas Tus Txheej Txheem Cov Ntawv Teev Npe, thiab Ntxiv thiab Txuas Ncua Sijhawm Sib Koom
Hauv Visuino: Txuas Tus Txheej Txheem Cov Ntawv Teev Npe, thiab Ntxiv thiab Txuas Ncua Sijhawm Sib Koom
Hauv Visuino: Txuas Tus Txheej Txheem Cov Ntawv Teev Npe, thiab Ntxiv thiab Txuas Ncua Sijhawm Sib Koom
Hauv Visuino: Txuas Tus Txheej Txheem Cov Ntawv Teev Npe, thiab Ntxiv thiab Txuas Ncua Sijhawm Sib Koom
Hauv Visuino: Txuas Tus Txheej Txheem Cov Ntawv Teev Npe, thiab Ntxiv thiab Txuas Ncua Sijhawm Sib Koom
Hauv Visuino: Txuas Tus Txheej Txheem Cov Ntawv Teev Npe, thiab Ntxiv thiab Txuas Ncua Sijhawm Sib Koom
Hauv Visuino: Txuas Tus Txheej Txheem Cov Ntawv Teev Npe, thiab Ntxiv thiab Txuas Ncua Sijhawm Sib Koom
Hauv Visuino: Txuas Tus Txheej Txheem Cov Ntawv Teev Npe, thiab Ntxiv thiab Txuas Ncua Sijhawm Sib Koom
  1. Txuas tus "Tawm" tus pin ntawm FormattedText1 tivthaiv rau "Hauv" tus pin ntawm "Modules. WiFi. Sockets. TCPServer1" ntawm "NodeMCU ESP-12" tivthaiv (Duab 1)
  2. Ntaus "ncua" hauv Lub Lim Lim ntawm Cov Ntawv Cuab Yeej Cuab Yeej ces xaiv qhov "Ncua Sijhawm" tivthaiv (Daim duab 2), thiab tso rau hauv qhov tsim
  3. Txuas tus "Tawm" tus pin ntawm FormattedText1 tivthaiv rau "Hauv" tus pin ntawm Delay2 tivthaiv (Daim duab 3)
  4. Txuas tus "Tawm" tus pin ntawm Delay2 tivthaiv rau "Disconnect" tus pin nkag ntawm "Modules. WiFi. Sockets. TCPServer1" ntawm "NodeMCU ESP-12" tivthaiv (Duab 4)

Qhov kev tivthaiv qeeb yuav txuas lub qhov (socket) sai tom qab ntawv tau xa tuaj.

Kauj Ruam 11: Tsim, Ua Ke, thiab Tshaj Tawm Arduino Code

Tsim, Sau, thiab Tso Tawm Arduino Code
Tsim, Sau, thiab Tso Tawm Arduino Code
Tsim, Sau, thiab Tso Tawm Arduino Code
Tsim, Sau, thiab Tso Tawm Arduino Code
  1. Hauv Visuino, Nias F9 lossis nyem rau ntawm lub pob uas qhia ntawm daim duab 1 los tsim Arduino code, thiab qhib Arduino IDE
  2. Txuas lub NodeMCU module nrog USB cable rau lub khoos phis tawj
  3. Xaiv hom pawg thawj coj thiab chaw nres nkoj raws li kuv tau qhia koj hauv Cov Lus Qhia no
  4. Hauv Arduino IDE, nyem rau ntawm Upload khawm, txhawm rau sau thiab xa cov cai (Daim duab 2)

Kauj ruam 12: Thiab Ua Si …

Image
Image
Thiab Ua Si …
Thiab Ua Si …

Nrog koj zoo siab! Koj tau ua Wi-Fi Kub thiab Vaum Web Server.

Ntawm Daim Duab 1 thiab hauv Cov Duab Koj tuaj yeem pom qhov txuas thiab txhawb nqa txoj haujlwm. Kuv siv lub USB Power Bank me me los txhawb lub zog.

Nco ntsoov hauv txoj haujlwm ntawm Kauj Ruam 4 koj tau nkag mus rau qhov SSID thiab Password raug rau koj li Wi-nkaus hotspot

Yog tias koj qhib lub vev xaib ntawm koj lub khoos phis tawj lossis lub xov tooj ntawm tes, thiab ntaus:

dht11server./

Thiab nias Enter, koj yuav pom qhov ntsuas kub thiab av noo ntsuas los ntawm tus qauv. Qhov nyeem ntawv yuav rov ua dua tshiab txhua 5 vib nas this raws li teev tseg hauv Kauj Ruam 7.

Nco ntsoov ntxiv Dot tom kawg ntawm lub npe, txwv tsis pub Windows yuav tsis tuaj yeem daws cov npe sau npe

Ntawm daim duab 2 koj tuaj yeem pom daim duab Visuino tiav.

Kuj txuas nrog yog Visuino qhov haujlwm, uas kuv tau tsim rau qhov Qhia Qhia no. Koj tuaj yeem rub tawm thiab qhib nws hauv Visuino:

Pom zoo: