Cov txheej txheem:
- Khoom siv
- Kauj Ruam 1: Ntsuas Kub thiab Vaum
- Kauj Ruam 2: Tsim thiab teeb tsa Project
- Kauj ruam 3: Nruab Libraries
- Kauj Ruam 4: Txuas DHT11 Sensor
- Kauj Ruam 5: Xa Cov Ntaub Ntawv mus rau Huab
- Kauj Ruam 6: Kev kuaj mob
- Kauj ruam 7: Pib thiab Debug qhov Project
- Kauj ruam 8: Dashboard Configuration
- Kauj Ruam 9: Xaus
Video: Txuas DHT11/DHT22 Sensor mus rau Huab nrog ESP8266-based Board: 9 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Hauv tsab xov xwm dhau los, Kuv txuas kuv li ESP8266-based NodeMCU board rau Cloud4RPi kev pabcuam. Tam sim no, nws yog lub sijhawm rau qhov project tiag!
Khoom siv
Yuav tsum tau kho vajtse:
- Txhua lub rooj tsav xwm raws li ESP8266 nti (piv txwv li, NodeMCU)
- DHT11 lossis DHT22 sensor
Software thiab kev pabcuam:
- DHT sensor tsev qiv ntawv los ntawm Adafruit - v1.3.7
- Adafruit Unified Sensor - v1.0.3
- cloud4rpi-esp-arduino -v0.1.0
- Cloud4RPI - Huab tswj vaj huam sib luag rau IoT khoom siv
- PlatformIO IDE rau VSCode
Kauj Ruam 1: Ntsuas Kub thiab Vaum
Kuv twb muaj lub DHT11 sensor, yog li kuv txiav txim siab siv nws rau qhov ntsuas kub thiab av noo. Cia peb xaiv lub tsev qiv ntawv Arduino los nyeem cov ntaub ntawv sensor.
Arduino sau npe muaj ntau lub tsev qiv ntawv, los ntawm qhov kuv xaiv qhov nrov tshaj plaws.
Raws li lawv qhov chaw cia khoom GitHub, peb kuj tseem xav tau ntxiv Adafruit Unified Sensor pob.
Kauj Ruam 2: Tsim thiab teeb tsa Project
Kuv twb tau piav qhia yuav tsim PlatformIO project li cas thiab teeb tsa cov tsev qiv ntawv hauv thawj ntu. Kuv qhov haujlwm hu ua "MyNodeMCU". Tus qauv yog qhia saum toj no.
Txoj haujlwm no yog qhov hloov pauv me ntsis Cloud4RPi piv txwv. Kuv txiav txim siab khaws cov cuab yeej token thiab Wi-nkaus daim ntawv pov thawj hauv cov ntaub ntawv teeb tsa hloov chaw.
Cov ntaub ntawv platform.io zoo li hauv qab no:
[platformio] default_envs = nodemcuv2 [env: nodemcuv2] platform = espressif8266 moj khaum = arduino board = nodemcuv2
Kauj ruam 3: Nruab Libraries
Kev teeb tsa lub tsev qiv ntawv yog qhov yooj yim heev. Koj tuaj yeem ua nws los ntawm IDE's graphical interface, lossis ntxiv cov npe tsev qiv ntawv uas xav tau mus rau ntu lib_deps ntawm platform.io cov ntaub ntawv:
; … Lib_deps = cloud4rpi -esp -arduino Adafruit Unified Sensor DHT sensor library build_flags = -D MQTT_MAX_PACKET_SIZE = 1024 -D MQTT_MAX_TRANSFER_SIZE = 128 -D CLOUD4RPI_DEBUG = 0 -D SSID_NAME = / "_" _ _ " D CLOUD4RPI_TOKEN = / "_ YOUR_DEVICE_TOKEN _ \"
Cov tsev qiv ntawv ntxiv yuav raug teeb tsa ncaj qha rau hauv qhov project's subfolder.
Main.cpp header zoo li hauv qab no:
#include #include #include #include "DHT.h"
Kauj Ruam 4: Txuas DHT11 Sensor
Adafruit muab DHTtester.ino piv txwv ntawm kev sib txuas sensor.
Txoj cai no pib ua lub ntsuas thiab piav qhia tus qauv txhawm rau khaws qhov ntsuas ntsuas (yog tias nws ua tiav):
#define DHTPIN 2 // Cov lej txuas nrog DHT sensor#txhais DHTTYPE DHT11 // DHT 11 //… DHT dht (DHTPIN, DHTTYPE); dht.begin (); //… struct DHT_Result {ntab h; ploj t; }; DHT_Result dhtResult;
Lub luag haujlwm tom ntej qhia yuav ua li cas nyeem cov ntaub ntawv sensor thiab khaws nws hauv cov ntaub ntawv cov qauv piav qhia saum toj no
void readSensors () {ntab h = dht.readHumidity (); // Nyeem kub li Celsius (lub neej ntawd) ntab t = dht.readTemperature ();
// Txheeb xyuas yog tias ib qho twg nyeem tsis tau zoo thiab tawm mus
yog (isnan (h) || isnan (t)) {Serial.println (F ("Ua tsis tau tejyam nyeem los ntawm DHT sensor!")); rov qab; } dhtResult.h = h; dhtResult.t = t; }
Kauj Ruam 5: Xa Cov Ntaub Ntawv mus rau Huab
Thaum peb muaj cov ntaub ntawv ntawd, cov kauj ruam tom ntej yog xa nws mus rau Cloud4RPi kev pabcuam.
Cloud4RPi rau nplooj ntawv Arduino piav qhia lub tsev qiv ntawv API, uas yog txheej txheem txheej txheem siv rau:
- tsim, nyeem thiab hloov pauv,
- xa qhov txawv txav mus rau huab siv MQTT raws tu qauv.
Lub tsev qiv ntawv txhawb nqa peb yam sib txawv: Bool, Numeric, thiab String.
Lub tsev qiv ntawv ua haujlwm pib nrog tsim ib qho piv txwv API siv Device Token los ntawm cloud4rpi.io lub vev xaib (xa mus rau kab lus ntu 1 kom paub meej).
#if txhais (CLOUD4RPI_TOKEN) Cloud4RPi c4r (CLOUD4RPI_TOKEN); #else Cloud4RPi c4r ("!!! _ NO_DEVICE_TOKEN _ !!!"); #ib
Tom qab ntawd, tshaj tawm cov kev hloov pauv rau DHT11 nyeem:
c4r.declareNumericVariable ("DHT11_Temp"); c4r.declareNumericVariable ("DHT11_Hum");
Tom qab ntawd, tau txais cov ntaub ntawv los ntawm lub ntsuas cua, txuag lawv rau hauv qhov hloov pauv thiab tshaj tawm cov ntaub ntawv rau Cloud4RPi:
c4r.setVariable ("DHT11_Temp", dhtResult.t); c4r.setVariable ("DHT11_Hum", dhtResult.h); c4r.publishData ();
Kub thiab av noo tsis hloov pauv sai, yog li xa ntau dua ib tus nqi rau 5 feeb tsis tas yuav tsum tau ua.
Kauj Ruam 6: Kev kuaj mob
Cloud4RPi txhawb cov ntaub ntawv kuaj mob nrog rau qhov sib txawv qhov tseem ceeb. Kuv siv sijhawm ua haujlwm, Wi-Fi teeb liab lub zog, thiab IP chaw nyob raws li cov ntaub ntawv kuaj mob:
c4r.declareDiagVariable ("IP_Address"); c4r.declareDiagVariable ("RSSI"); // WiFi teeb liab lub zog c4r.declareDiagVariable ("Uptime");
Nco tseg: Lub millis muaj nuj nqi kuv siv kom tau txais cov sijhawm rov pib dua rau xoom txhua ~ 50 hnub. Uas yog ntau tshaj li txaus rau kuv qhov project.
Cov cai hauv qab no teeb tsa cov kev ntsuas ntsuas sib txawv:
c4r.setDiagVariable ("RSSI", (String) WiFi. RSSI () + "dBm"); c4r.setDiagVariable ("IP_Address", WiFi.localIP (). toString ()); c4r.setDiagVariable ("Uptime", uptimeHumanReadable (currentMillis)); c4r.publishDiag ();
Lub sijhawm ua haujlwm HumanReadable hloov pauv milliseconds rau daim ntawv yooj yim:
Txoj hlua uptimeHumanReadable (tsis tau kos npe ntev milliseconds) {zoo li qub uptimeStr [32]; unsigned ntev secs = milliseconds / 1000; unsigned ntev feeb = secs / 60; unsigned int teev = feeb / 60; unsigned int hnub = teev / 24; secs -= feeb * 60; feeb -= teev * 60; teev -= hnub * 24; sprintf (uptimeStr, "%d hnub%2.2d:%2.2d:%2.2d", (byte) hnub, (byte) teev, (byte) feeb, (byte) secs); rov hlua (uptimeStr); }
Txoj haujlwm tso tawm ib txoj hlua zoo li no 5 hnub 10:23:14 tsis yog tus lej loj coj txawv txawv.
Kauj ruam 7: Pib thiab Debug qhov Project
Tom qab suav sau cov cai tsim thiab ua rau nws ntsaws rau hauv NodeMCU, lub cuab yeej txuas nrog rau kev pabcuam huab thiab pib xa cov ntaub ntawv.
Koj tuaj yeem nce kev hais lus tsis zoo los ntawm kev teeb tsa CLOUD4RPI_DEBUG cov txheej txheem ua ntej hloov pauv mus rau 1 (ntxiv -D CLOUD4RPI_DEBUG = 1 rau build_flags ntu hauv platform.io ntawv).
Tom ntej no, qhib lub vev xaib cloud4rpi.io thiab pom lub cuab yeej tshiab online. Qhib nws kom pom txhua qhov txawv txav tau txais los ntawm lub cuab yeej: sensor thiab kuaj mob.
Kauj ruam 8: Dashboard Configuration
Hauv theem no, cov ntaub ntawv txuas rau huab tau ua haujlwm. Tam sim no, cia teeb tsa qhov pom kev sawv cev ntawm cov ntaub ntawv.
Kuv siv Dashboard teeb tsa UI los tsim cov dashboard hauv qab no.
Lub dashboard yog qhov sib faib, yog li kuv tam sim qhia nws nrog kuv tus phooj ywg.
Kauj Ruam 9: Xaus
Tag nrho txoj haujlwm txoj cai muaj nyob hauv qhov tseem ceeb.
Nov yog txhua yam tam sim no!
Cov lus nug thiab lus pom zoo txais tos hauv cov lus.
Pom zoo:
Txuas Txuas Txuas Txuas: 5 Cov Kauj Ruam
Txuas Txuas Lub Sijhawm: Nyob Zoo! Hauv qhov kev qhia no koj yuav pom yuav ua li cas txuas nrog ib qho khoom siv Arduino sib xws, nruab nrog WiFi, rau REST APIs! Qhov no siv GitKraken Glo Board webapp los tsim cov laug cam, kab & daim npav los npaj khoom! Qee qhov kev paub ntawm yuav ua li cas pej xeem
HRV (Lub Tsev Huab Cua Hloov Chaw) Arduino Tus Tswj Nrog Huab Cua Huab Cua: 7 Cov Kauj Ruam (nrog Duab)
HRV (Lub Tsev Huab Cua Hloov Chaw) Arduino Tus Tswj Nrog Air Economizer: HRV Arduino Tus Tswj Nrog Air Economizer Yog li kuv keeb kwm nrog txoj haujlwm no yog kuv nyob hauv Minnesota thiab kuv lub rooj tsav xwm hluav taws xob kib ntawm kuv LifeBreath 155Max HRV. Kuv tsis xav them $ 200 rau qhov tshiab Kuv ib txwm xav tau qee yam nrog kev lag luam huab cua kev ua txhaum
Kev Sib Txuas Txuas Txuas Txuas Siv Bluefruit: 4 Cov Kauj Ruam
Kev Sib Txuas Tsis Sib Txuas Siv Bluefruit: Nov yog cov lus qhia yooj yim los ntawm kauj ruam qhia los hloov koj cov xov hlau nrog bluetooth tsis muaj zog txuas: Nws coj kuv ib pliag los daws qhov no vim tias tsis muaj cov ntaub ntawv hais txog kev ua qhov no nrog bluetooth niaj hnub tsis muaj zog thev naus laus zis raws li Bluefrui
EZ Kev Sib Txuas Txuas Txuas Txuas Ntxiv - Tsis Muaj Tus Kheej! (CSRC-311): 7 Kauj Ruam
EZ Kev Sib Txuas Txuas Txuas Txuas Ntxiv - Tsis Muaj Tus Kheej! (CSRC-311): Tsis ntev dhau los ntawm Azamom.com (thov txim, tam sim no tau muag tawm) Kuv tau hla qhov kev pom zoo zoo ntawm Common Sense RC CSRC-311 tus qauv-siv servos.Noj zoo, Kuv xav hloov qee yam ntawm tsis tu ncua kev sib hloov. Txoj kev kuv tuaj nrog yog yooj yim heev thiab xav tau
Cov lus qhia rau Ua Plaub Qhov Kev Txuas Txuas Txuas Rau Qhov Chaw Mounted Footrest: 9 Cov Kauj Ruam (nrog Duab)
Cov lus qhia rau Ua Plaub Qhov Kev Txuas Txuas Txuas Rau Lub Hauv Paus Mounted Footrest: Mid-drive fais fab log lub rooj zaum (PWC) tau dhau los ua neeg nyiam nyob rau xyoo tas los no. Txawm li cas los xij, vim qhov kev tso rau pem hauv ntej casters, cov tsoos sab-mounted footrests tau hloov los ntawm ib qho chaw nruab nrab-footrest. Hmoov tsis zoo, center-mou