Cov txheej txheem:
- Kauj ruam 1: Mus kav khw
- Kauj ruam 2: Teeb thiab Tom Qab
- Kauj Ruam 3: Arduino - ESP12 Tshooj
- Kauj Ruam 4: Xeem ESP Raws Li Network Time Protocol (NTP) Cov Neeg Siv Khoom
- Kauj Ruam 5: Kuaj DHT22 Sensor
- Kauj Ruam 6: Muab Nws Ua Ke …
- Kauj Ruam 7: Sab Server ntawm Yam
Video: Tsev Network Kub Sensor: 7 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Koj yuav tsum paub dab tsi los ua txoj haujlwm no:
Koj yuav tsum paub txog:- Qee qhov txuj ci hluav taws xob (siv tshuaj zas)
- Linux
- Arduino IDE
(koj yuav tsum hloov kho cov laug cam ntxiv hauv IDE:
- hloov kho/tsim cov phiaj xwm ESP ntawm Arduino IDE.
(muaj qee qhov kev qhia zoo nyob hauv lub vev xaib)
Qhov no tuaj yeem ua tiav siv Arduino Uno lossis siv FTDI (usb rau serial adapter).
Kuv siv kuv Uno vim tias kuv tsis muaj ib qho chaw nres nkoj hauv kuv lub PC lossis kuv tsis muaj FTDI
Kauj ruam 1: Mus kav khw
Koj yuav xav tau dab tsi los ua qhov no?
Rau Digital Kub thiab Vaum Sensor:
- Tog twg los yog lub khob cij lossis lwm txoj hauv kev xws li cov qauv pcb, cov laug, cov hlau txuas …
- Ib co xaim
- ob tug dhia
-10k Ohm resistor
- ESP12F (lwm cov qauv yuav ua haujlwm ib yam nkaus …)
- DHT22 (kim kim dua DHT11 tab sis raug dua)
- 3 AA roj teeb rov tau thiab lub roj teeb
- lub thawv yas me me los tso koj txoj haujlwm
- Hauv theem tom qab kuv npaj yuav ntxiv HT7333 nrog ob lub 10uF capacitors nruab nrab ntawm lub roj teeb thiab ESP
txhawm rau ruaj khov cov tswv yim hluav taws xob (VCC) rau qhov pom zoo 3.3V tab sis kuj tseem tiv thaiv ESP los ntawm overvoltage.
Rau Network ntu:
- Koj lub tsev WiFi Network
Rau tus neeg rau zaub mov ib feem:
- Txhua lub Linux raws qhov system (ib txwm nyob!)
Kuv siv Raspberry Pi (uas kuv kuj siv ua server rau kuv lub koob yees duab IP sab nraum zoov.)
- gcc compiler los sau koj tus lej server
- rrdtool pob los khaws cov ntaub ntawv thiab tsim cov duab
- apache (lossis lwm lub vev xaib)
Koj lub PC lossis lub laptop nyiam nrog Arduino IDE rau nws.
Kauj ruam 2: Teeb thiab Tom Qab
Hauv qhov txuas ntawm WiFi txuas nrog no - tsis hais IOT - ntsuas kub thiab av noo Kuv tau siv ESP12F, DHT22 thiab 3 AA lub roj teeb tuav nrog cov roj teeb rov tau.
Txhua 20 feeb ESP ntsuas ntsuas los ntawm DHT22 thiab xa nws mus rau server (Raspberry Pi) hla UDP ntawm kuv lub tsev WiFi network. Tom qab qhov ntsuas ntsuas tau raug xa mus, ESP nkag mus rau hauv kev tsaug zog. Qhov no txhais tau tias tsuas yog Lub Sij Hawm Tiag Sijhawm ntawm tus qauv tseem muaj zog, ua rau muaj kev ntseeg tsis txaus ntseeg txuag lub zog. Txog li 5 vib nas this, tus qauv xav tau txog 100mA, tom qab ntawd 20 feeb tsaug zog tsuas yog 150uA.
Kuv tsis xav siv kev pabcuam hauv Is Taws Nem vim tias kuv muaj kuv Raspberry Pi uas ib txwm nyob ntawm ib qho twg thiab hauv txoj kev no kuv muaj kev zoo siab ntawm kev sau cov server ib yam nkaus.
Ntawm tus neeg rau zaub mov (Raspberry Pi khiav Raspbian) Kuv tau sau qhov yooj yim UDP mloog (server) uas khaws cov txiaj ntsig rau hauv RRD yooj yim. (Hloov Robin Database siv RRDtool los ntawm Tobias Oetiker.)
Qhov zoo ntawm RRDtool yog tias koj tsim koj li database ib zaug thiab qhov loj tseem zoo ib yam. Tsis tas li koj tsis tas yuav muaj cov server server (zoo li mySQLd) khiav hauv keeb kwm yav dhau. RRDtool muab cov cuab yeej rau koj los tsim Database thiab tsim cov duab.
Kuv tus neeg rau zaub mov tsim cov kab ntawv nyob rau lub sijhawm thiab qhia txhua yam hauv nplooj http yooj yim heev. Kuv tuaj yeem sab laj kuv nyeem nrog qhov browser yooj yim los ntawm kev txuas rau Apache2 webserver ntawm Raspberry Pi!
Thaum kawg, kuv tsis muaj FTDI (USB rau Serial) yog li kuv siv kuv Arduino UNO. Koj yuav tsum txuas TX's thiab RX's thiab GND ntawm ESP thiab UNO. (Kuv paub, koj txoj kev xav yuav qhia koj kom hla RX thiab TX's … sim nws ib yam, tsis ua haujlwm.)
Kuv tsis tau ua qib hloov dua siab tshiab (UNO: Siab = 5V tab sis ESP feem ntau yog 3.3V ntaus ntawv… Muaj qee qhov zoo FTDI nyob rau ntawm kev ua lag luam uas koj tuaj yeem xaiv koj qib siab ua 5 lossis 3.3V.
Kuv lub voj voog yog siv los ntawm 3 AA roj teeb uas tau them rov qab - yog li qhov tseeb 3 X 1.2V. Nyob rau theem tom ntej no kuv npaj siab tso HT7333 nruab nrab ntawm lub roj teeb pob thiab lub Circuit Court kom nyab xeeb; cov roj teeb uas tau them tshiab tuaj yeem muaj ntau dua 1.2V thiab ESP yuav tsum tau siv nrog min. 3V thiab max. 3.6v ua. Tsis tas li yog tias kuv txiav txim siab - nyob rau lub sijhawm tsis muaj zog - tso Alkaline roj teeb (3 X 1.5V = 4.5V) kuv ESP yuav tsis kib!
Kuv kuj tau txiav txim siab siv 10cm x 10cm Solar vaj huam sib luag, tab sis nws tsuas yog tsis tsim nyog qhov teeb meem. Los ntawm kev ntsuas 3 ntsuas ib teev (qhov tseeb 3x 5 vib nas this @ 100mA max.
Kauj Ruam 3: Arduino - ESP12 Tshooj
Kuv tau ua txoj haujlwm no hauv ntau qib.
Muaj ntau qhov txuas uas pab koj ntshuam ESP12 (aka. ESP8266) rau hauv Arduino IDE. (Kuv yuav tsum tau siv version 2.3.0 hloov qhov tshiab vim tias muaj kab laum uas yuav raug daws lub sijhawm ntawd …)
Kuv pib los ntawm kev sib txuas ESP, hla kuv Arduino UNO (tsuas yog siv ua tus choj ntawm kuv lub PC ntawm USB mus rau Serial) mus rau ESP serial interface. Muaj cais Cov Kws Qhia Ntawv piav qhia qhov no.
Hauv kuv qhov haujlwm tiav kuv tso cov xov hlau txuas mus rau Serial thaum kuv xav tau teeb meem. RX
Tom qab ntawd koj yuav tsum xaim koj li ESP12 raws li hauv qab no:
ESP tus pin…
GND UNO GND
RX UNO RX
TX UNO TX
EN VCC
PIB 15 GND
Thaum xub thawj kuv tau sim ua kom muaj zog kuv li ESP los ntawm 3.3V ntawm UNO tab sis kuv tau txav mus sai rau txhawb kuv lub ESP nrog lub rooj zaum Lub Hwj Huam Muab Khoom tab sis koj tuaj yeem siv koj lub roj teeb pob ib yam.
GPIO0 Kuv txuas qhov no nrog lub jumper mus rau GND kom ua rau lub teeb nyem (= programming) ESP.
Thawj qhov kev sim: tawm ntawm lub jumper qhib thiab pib saib xyuas hauv Arduino IDE (ntawm 115200 baud!)
Lub zog hloov pauv ESP, koj yuav tsum pom qee cov ntawv pov tseg thiab tom qab ntawv zoo li:
Ai-Thinker Technology Co. Ltd. npaj txhij
Hauv hom no, ESP ua haujlwm me ntsis zoo li qub modem. Koj yuav tsum tau siv AT cov lus txib.
Sim cov lus txib hauv qab no:
AT+RST
thiab ob qho lus txib hauv qab no
AT+CWMODE = 3
OK
AT+CWLAP
Qhov no yuav tsum muab koj cov npe ntawm txhua lub network WiFi hauv cheeb tsam.
Yog tias qhov no ua haujlwm koj tau npaj rau qib tom ntej.
Kauj Ruam 4: Xeem ESP Raws Li Network Time Protocol (NTP) Cov Neeg Siv Khoom
Hauv Arduino IDE, hauv Cov Ntaub Ntawv, Piv txwv, ESP8266WiFi, thauj NTPClient.
Yuav tsum tau kho me me kom nws ua haujlwm; koj yuav tsum tau sau koj tus SSID thiab tus password ntawm koj lub network WiFi.
Tam sim no tso lub jumper, luv GPIO0 rau GND.
Fais lub voj voog ESP thiab xa cov duab kos mus rau ESP.
Tom qab muab tso ua ke, xa mus rau ESP yuav tsum pib. Xiav LED ntawm ESP yuav ntsais muag sai li sai tau thaum tus lej tau rub tawm.
Kuv pom tias kuv yuav tsum ua si ib puag ncig me ntsis nrog rov pib dua IDE, rov pib dua ESP ua ntej kev tshaj tawm yuav ua haujlwm.
Ua ntej koj pib suav sau/xa cov duab kos, nco ntsoov kaw lub serial console (= serial monitor) vim qhov no yuav tiv thaiv koj los ntawm kev rub tawm.
Thaum qhov upload tau ua tiav, koj tuaj yeem rov qhib lub koos pij tawj saib kom pom ESP tau txais lub sijhawm los ntawm Is Taws Nem.
Zoo kawg, koj tau teeb tsa koj li ESP, txuas nrog koj li WiFi thiab tau txais sijhawm los ntawm Is Taws Nem.
Cov kauj ruam tom ntej peb yuav sim DHT22.
Kauj Ruam 5: Kuaj DHT22 Sensor
Tam sim no yuav tsum muaj cov xov txuas ntxiv.
DHT pins… Txuas tus pin 1 (ntawm sab laug) ntawm lub sensor rau VCC (3.3V)
Txuas tus pin 2 ESP GPIO5 (DHTPIN hauv daim duab)
Txuas tus pin 4 (ntawm sab xis) ntawm lub sensor mus rau GROUND
Txuas tus 10K resistor los ntawm tus pin 2 (cov ntaub ntawv) rau tus pin 1 (lub zog) ntawm lub sensor.
Zoo ib yam li NTP xeem, mus nrhiav DHTtester kos duab, thiab kho nws raws li hauv qab no:
#define DHTPIN 5 // peb xaiv GPIO5 los txuas rau lub ntsuas#txhais DHTTYPE DHT22 // txij li thaum peb siv DHT22 tab sis cov cai/tsev qiv ntawv no kuj haum rau DHT11
Ib zaug ntxiv, kaw qhov kev tshuaj xyuas ib ntus, hloov lub zog ESP thiab suav sau thiab nyem ESP.
Yog tias txhua yam mus tau zoo koj yuav tsum pom cov kev ntsuas tshwm sim hauv daim ntawv saib.
Koj tuaj yeem ua si ib puag ncig me ntsis nrog lub sensor. Yog tias koj ua pa ntawm nws, koj yuav pom cov av noo nce.
Yog tias koj muaj (tsis yog LED) lub teeb rooj, koj tuaj yeem ci ntawm lub ntsuas cua kom sov nws me ntsis.
Zoo kawg! Ob qhov loj ntawm lub sensor tam sim no ua haujlwm.
Hauv cov kauj ruam tom ntej kuv yuav tawm tswv yim txog qhov chaws kawg.
Kauj Ruam 6: Muab Nws Ua Ke …
Ntxiv qee qhov txuas ntxiv … qhov no yog ua kom DeepSleep ua tau.
Nco ntsoov, DeepSleep yog qhov ua haujlwm tsis txaus ntseeg rau IoT cov cuab yeej.
Txawm li cas los xij yog tias koj lub ntsuas hluav taws xob muaj zog rau DeepSleep, nws yuav nyuaj rau rov tsim dua ESP yog li peb yuav ua lwm qhov txuas txuas txuas ntawm
GPIO16-RST.
Yog nws YUAV TSUM yog GPIO16, vim qhov ntawd yog GPIO uas tau siv zog los tsa lub cuab yeej thaum Lub Sijhawm Tiag Taug Kev mus tom qab DeepSleep!
Thaum koj tab tom sim, koj tuaj yeem txiav txim siab ua 15 vib nas this DeepSleep.
Thaum kuv tau debugging, Kuv yuav txav lub jumper mus rau GPIO0 yog li kuv tuaj yeem nyem kuv qhov program.
Thaum rub tawm tiav, Kuv yuav txav lub jumper mus rau GPIO16 kom DeepSleep yuav ua haujlwm.
Cov cai rau ESP hu ua TnHclient.c
Koj yuav tsum hloov koj li SSID, Tus lej zais thiab tus IP chaw nyob ntawm koj lub server.
Muaj cov kab ntxiv ntawm cov cai uas koj tuaj yeem siv los daws teeb meem lossis sim koj teeb tsa.
Kauj Ruam 7: Sab Server ntawm Yam
Nws yog qhov kev nkag siab yuam kev uas UDP tsis ntseeg tau thiab TCP yog…
Qhov ntawd tsuas yog ua dag raws li hais tias rauj yog muaj txiaj ntsig ntau dua li cov ntsia hlau. Lawv tsuas yog sib txawv cov cuab yeej muaj txiaj ntsig zoo heev thiab lawv ob leeg tau siv lawv.
Los ntawm txoj kev, tsis muaj UDP Internet yuav tsis ua haujlwm … DNS raws li UDP.
Yog li, kuv xaiv UDP vim nws yog qhov hnyav heev, yooj yim thiab nrawm.
Kuv zoo li xav tias kuv li WiFi txaus ntseeg heev yog li cov neeg siv khoom yuav xa ntau tshaj 3 UDP pob ntawv yog tias lees paub "OK!" tsis tau txais.
C-code rau TnHserver nyob hauv TnHServer.c ntawv.
Muaj ntau qhov lus pom hauv txoj cai piav qhia nws.
Peb yuav xav tau qee yam cuab yeej ntxiv ntawm tus neeg rau zaub mov: rrdtool, apache thiab tej zaum tcpdump.
Txhawm rau nruab rrdtool ntawm Raspbian koj tuaj yeem yooj yim nruab pob zoo li no: apt-tau nruab rrdtool
Yog tias koj xav tau debug lub network kev sib tw, tcpdump los ua ke apt-tau nruab tcpdump
Kuv xav tau lub vev xaib kom siv tau qhov browser txhawm rau sab laj cov kab lus: apt-tau nruab apache2
Kuv siv cov cuab yeej no: https://rrdwizard.appspot.com/index.php kom tau txais cov lus txib los tsim Round Robin Database. Koj tsuas yog yuav tsum ua qhov no ib zaug (yog tias koj tau txais nws yog thawj zaug).
rrdtool tsim TnHdatabase.rrd-pib tam sim no-10s
-qib '1200'
'DS: Kub: GAUGE: 1200: -20.5: 45.5'
'DS: Vaum: GAUGE: 1200: 0: 100.0'
'RRA: AVERAGE: 0.5: 1: 720'
'RRA: AVERAGE: 0.5: 3: 960'
'RRA: AVERAGE: 0.5: 18: 1600'
Thaum kawg, Kuv siv crontab nkag los pib kuv TnHserver txhua hnub thaum ib tag hmo. Kuv khiav TnHserver raws li tus neeg siv ib txwm muaj (piv txwv li. Tsis yog hauv paus) raws li kev tiv thaiv kev nyab xeeb.
0 0 * * */usr/bin/pkill TnHserver; /home/user/bin/TnHserver>/dev/null 2> & 1
Koj tuaj yeem tshawb xyuas tias TnHserver tau ua haujlwm los ntawm kev ua
$ ps -elf | grep TnHserver
thiab koj tuaj yeem txheeb xyuas nws tau mloog pob ntawv ntawm chaw nres nkoj 7777 los ntawm kev ua
$ netstat -ua
Kev sib txuas hauv Is Taws Nem nquag (servers thiab tsim)
Proto Recv-Q Xa-Q Chaw Nyob Hauv Xeev Lub Xeev Chaw Nyob
udp 0 0 0.0.0.0:7777 0.0.0.0:*
Thaum kawg TsimTnH_Graphs.sh.txt yog tsab ntawv piv txwv los tsim cov duab kab. (Kuv tsim cov ntawv sau ua hauv paus, koj yuav tsis xav ua qhov no.)
Siv lub vev xaib yooj yim heev koj tuaj yeem saib cov duab los ntawm txhua lub browser ntawm koj lub network hauv tsev.
Pom zoo:
Plug & Ua Si CO2 Sensor Zaub Nrog NodeMCU/ESP8266 rau Cov Tsev Kawm Ntawv, Tsev Kawm Qib Siab lossis Koj Lub Tsev: 7 Kauj Ruam
Plug & Ua Si CO2 Sensor Zaub Nrog NodeMCU/ESP8266 rau Cov Tsev Kawm Ntawv, Lub Tsev Kawm Qib Siab lossis Koj Lub Tsev: Kuv yuav qhia koj sai npaum li cas txhim kho lub plug & ua si CO2 sensor qhov twg txhua qhov ntawm txoj haujlwm yuav txuas nrog DuPont xov hlau. Yuav muaj tsuas yog 5 cov ntsiab lus uas yuav tsum tau muab siv, vim tias kuv tsis tau muab tshuaj txhuam ua ntej qhov haujlwm no txhua lub sijhawm
ESP32 Raws M5Stack M5stick C Huab Cua Saib Nrog DHT11 - Saib Xyuas Qhov Kub Kub & Qhov Kub Kub ntawm M5stick-C Nrog DHT11: 6 Cov Kauj Ruam
ESP32 Raws M5Stack M5stick C Huab Cua Saib Nrog DHT11 | Saib Xyuas Qhov Kub thiab Qhov Ntsuas Kub ntawm M5stick-C Nrog DHT11: Nyob zoo cov neeg, hauv cov lus qhia no peb yuav kawm paub yuav ua li cas cuam tshuam DHT11 ntsuas kub nrog m5stick-C (pawg tswj hwm kev txhim kho los ntawm m5stack) thiab tso tawm ntawm cov zaub ntawm m5stick-C. Yog li hauv qhov kev qhia no peb yuav nyeem qhov ntsuas kub, av noo & heat kuv
Yuav Ua Li Cas Siv DHT11 Kub Sensor Nrog Arduino thiab Luam Kub Kub thiab Vaum: 5 Kauj Ruam
Yuav Ua Li Cas Siv DHT11 Kub Sensor Nrog Arduino thiab Luam Kub Kub thiab Vaum: Lub DHT11 sensor tau siv los ntsuas kub thiab av noo. Lawv yog cov khoom siv hluav taws xob nrov tshaj plaws.Qhov DHT11 cov av noo thiab ntsuas kub ua rau nws yooj yim ntxiv cov av noo thiab ntsuas kub rau koj li DIY cov phiaj xwm hluav taws xob. Nws yog rau
ESP32 NTP Kev Ntsuas Kub Ua Haujlwm Kub Kub Nrog Steinhart-Hart Kho thiab Tswb Kub: 7 Kauj Ruam (nrog Duab)
ESP32 NTP Kev Ntsuas Kub Ua Haujlwm Ntsuas Kub nrog Steinhart-Hart Kev Kho thiab Tswb Kub: Tseem tab tom taug kev kom ua tiav "qhov haujlwm yuav los tom ntej", "ESP32 NTP Kev Ntsuas Kub Kev Ntsuas Kub Ua Noj Nrog Steinhart-Hart Kev Kho thiab Tswb Kub" yog Cov Ntawv Qhia qhia yuav ua li cas kuv ntxiv NTP ntsuas kub, piezo b
WiFi IoT Kub thiab Vaum Sensor. Ntu: 8 IoT, Kev Siv Tsev Hauv Tsev: 9 Kauj Ruam
WiFi IoT Kub thiab Vaum Sensor. Ntu: 8 IoT, Kev Ua Haujlwm Hauv Tsev: Preamble Cov kab lus no sau cov tswv yim ruggedisation thiab txuas ntxiv mus ntawm kev qhia ua ntej: 'Pimping' koj thawj IoT WiFi Device. Ntu 4: IoT, Kev Ua Haujlwm Hauv Tsev suav nrog txhua qhov tsim nyog software ua haujlwm kom ua tiav