Cov txheej txheem:
- Kauj ruam 1: Yuav tsum kho vajtse
- Kauj Ruam 2: Kev Sib Txuas Kho Vajtse
- Kauj Ruam 3: Txoj Cai rau Teem Sijhawm
- Kauj Ruam 4: Txoj Cai Nyeem Ntawv Kub thiab Qhov Ntsuas Qhov Ntsuas
- Kauj Ruam 5: Txoj Cai rau Hosting Lub Vev Xaib
- Kauj Ruam 6: Code rau Tshaj Tawm Cov Ntaub Ntawv rau Yam Hais
- Kauj Ruam 7: Txoj Cai Tag Nrho
Video: Huab Cua Web App Siv Esp8266: 7 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
SHT 31 yog Cov ntsuas kub thiab av noo ua los ntawm Sensirion. SHT31 muab qib siab ntawm ib puag ncig ± 2% RH. Nws cov av noo nyob nruab nrab ntawm 0 txog 100% thiab Kub ntau yog nyob nruab nrab ntawm -40 txog 125 ° C. Nws muaj kev ntseeg tau ntau dua thiab nrawm nrog 8 sec ntawm Sensor lub sijhawm teb. Nws lub luag haujlwm suav nrog txhim kho cov teeb liab ua haujlwm thiab I2C sib xws. Nws muaj ntau hom kev ua haujlwm uas ua rau nws lub zog muaj txiaj ntsig.
Hauv qhov kev qhia no, peb tau cuam tshuam SHT 31 nrog Adafruit Huzzah board. Rau kev nyeem Cov ntsuas Kub thiab Vaum peb tau siv ESP8266 I2C daim ntaub thaiv. Tus adapter no ua rau txhua tus pin nkag tau rau tus neeg siv thiab muab cov neeg siv-phooj ywg I2C ib puag ncig.
Kauj ruam 1: Yuav tsum kho vajtse
Kho vajtse siv los ua txoj haujlwm no:
1. TSH31
2. Adafruit Huzzah ESP8266
3. ESP8266 I2C adapter
4. I2C Cable
Kauj Ruam 2: Kev Sib Txuas Kho Vajtse
Cov kauj ruam no suav nrog phau ntawv qhia kho vajtse sib txuas. Tshooj lus no piav qhia qhov txuas txuas uas xav tau ntawm lub ntsuas cua thiab ESP8266. Cov kev sib txuas yog raws li hauv qab no.
- SHT31 ua haujlwm dhau I2C. Cov duab saum toj no qhia txog kev sib txuas ntawm ESP8266 thiab SHT31 module. Peb tab tom siv I2C cable rau nws txawm tias peb tuaj yeem siv 4 F rau F jumper xov hlau.
- ib txoj hlua siv rau Vcc, ob txoj hlua rau GND thiab lwm ob rau SDA thiab SCL feem.
- Raws li I2C adapter pin2 thiab tus pin 14 ntawm ESP8266 pawg thawj coj tau siv ua SDA thiab SCL feem
Kauj Ruam 3: Txoj Cai rau Teem Sijhawm
Hauv qhov kev qhia no, peb tab tom ua peb txoj haujlwm
- Nyeem cov ntaub ntawv los ntawm SHT11 siv I2C raws tu qauv
- host lub web server thiab tshaj tawm lub sensor nyeem rau lub vev xaib
- tshaj tawm cov ntawv nyeem sensor rau ThingSpeak API
Txhawm rau ua tiav qhov no peb siv TaskScheduler lub tsev qiv ntawv. Peb tau teem sijhawm peb txoj haujlwm sib txawv hais txog peb qhov kev tswj hwm sib txawv. qhov no yog ua raws li hauv qab no
- Kev Ua Haujlwm 1 yog txhawm rau nyeem tus nqi ntsuas lub luag haujlwm no ua haujlwm rau 1 thib ob txog thaum nws mus txog sijhawm 10 feeb.
- Thaum Task1 mus txog nws lub sijhawm Task 2 tau qhib thiab Task1 tau xiam.
- Peb txuas rau AP hauv qhov kev hu rov qab no, Ob qhov boolean hloov pauv tau coj los saib xyuas kev hloov pauv ntawm STA thiab AP
- Hauv Task 2 peb tab tom tuav lub vev xaib ntawm 192.168.1.4. Txoj haujlwm no ua haujlwm rau txhua 5 vib nas this txog thaum nws mus txog qhov nws siv sijhawm 50 feeb
- Thaum Task 2 mus txog sijhawm sijhawm Task 3 tau qhib thiab Task2 raug xiam oob khab.
- Peb txuas rau STA (IP hauv zos) hauv qhov kev hu rov qab no
- Hauv Kev Ua Haujlwm 3 peb tab tom tshaj tawm lub sensor nyeem rau huab ThingSpeak API
- Task 3 khiav rau txhua tsib vib nas this txog thaum nws mus txog nws lub sijhawm tas li 50 feeb
- Thaum Task3 mus txog nws lub sijhawm Task 1 tau qhib dua thiab Task3 tau xiam oob khab.
- Thaum tsis muaj kev hu rov qab los lossis lub cuab yeej tsis ua haujlwm nws mus rau Lub Teeb Txias yog li txuag lub zog.
Teem sijhawm ts;
// Cov haujlwm rau i2c, hosting web server thiab tshaj tawm ntawm yam khoom
Task tI2C (1 * TASK_SECOND, TASK_FOREVER, & taskI2CCallback, & ts, cuav, NULL, & taskI2CDisable); Task tAP (5*TASK_SECOND, TASK_FOREVER, & taskAPCallback, & ts, cuav, NULL, & taskAPDisable); Task tWiFi (5* TASK_SECOND, TASK_FOREVER, & taskWiFiCallback, & ts, cuav, NULL, & taskWiFiDisable); // sijhawm tas rau cov haujlwm tI2C.setTimeout (10 * TASK_SECOND); tAP.setTimeout (50 * TASK_SECOND); tWiFi.setTimeout (50 * TASK_SECOND); // pab kom I2C ua haujlwm tI2C.enable ();
Kauj Ruam 4: Txoj Cai Nyeem Ntawv Kub thiab Qhov Ntsuas Qhov Ntsuas
Peb tab tom siv Wire.h lub tsev qiv ntawv los nyeem qhov ntsuas kub thiab av noo. Lub tsev qiv ntawv no pabcuam i2c kev sib txuas lus ntawm lub ntsuas cua thiab tus cuab yeej siv. 0x44 yog I2C chaw nyob rau SHT31.
SHT31 ua haujlwm sib txawv ntawm kev ua haujlwm. Koj tuaj yeem xa mus rau daim ntawv rau qhov ntawd.
Peb siv 0x2C thiab 0x06 ua MSB thiab LSB feem rau kev txhaj tshuaj ib leeg.
// I2C ua haujlwm hu rov qab tsis ua haujlwm I2CCallback ()
{Serial.println ("taskI2CStarted"); unsigned int hauv paus [6]; // pib kis los ntawm 0x44; Wire.beginTransmission (Addr); // rau kev txhaj tshuaj ib zaug nrog kev rov ua tau zoo peb siv 0x2C (MSB) thiab 0x06 (LSB) Wire.write (0x2C); Hlau.write (0x06); // kawg kis Wire.endTransmission (); // thov bytes los ntawm 0x44 Wire.beginTransmission (Addr); Wire.endTransmission (); Wire.requestFrom (Addr, 6); yog (Wire.available () == 6) {// data [0] thiab data [1] muaj 16 ntsis kub. hauv paus [0] = Wire.read (); hauv paus [1] = Wire.read (); // cov ntaub ntawv [2] muaj 8 ntsis ntawm CRC hauv paus [2] = Wire.read (); // cov ntaub ntawv [3] thiab cov ntaub ntawv [4] muaj 16 ntsis ntawm cov hauv paus av noo [3] = Wire.read (); hauv paus [4] = Wire.read (); // cov ntaub ntawv [5] muaj 8 ntsis CRC hauv paus [5] = Wire.read (); } int temp = (hauv paus [0] * 256) + hauv paus [1]; // hloov MSB los ntawm 8 khoom ntxiv LSB ntab cTemp = -45.0 + (175.0 * temp /65535.0); ntab fTemp = (cTemp * 1.8) + 32.0; // hloov MSB los ntawm 8 cov khoom ntxiv LSB rau nws cais los ntawm kev daws teeb meem tag nrho thiab * 100 rau feem pua ntab av noo = (100.0 * ((hauv paus [3] * 256.0) + hauv paus [4])) /65535.0;
tempC = cTemp;
tempF = fTemp; vaum = vaum; Serial.print ("Kub hauv C: / t"); Serial.println (Txoj hlua (cTemp, 1)); Serial.print ("Kub hauv F: / t"); Serial.println (Txoj hlua (fTemp, 1)); Serial.print ("Vaum: / t"); Serial.println (Txoj hlua (av noo, 1)); }
Kauj Ruam 5: Txoj Cai rau Hosting Lub Vev Xaib
Peb tau tuav lub vev xaib server los ntawm peb lub cuab yeej ntawm tus IP zoo li qub.
- ESP8266WebServer lub tsev qiv ntawv tau siv los tuav lub vev xaib
- Ua ntej peb yuav tsum tshaj tawm IP chaw nyob, Rooj vag thiab subnet daim npog los tsim peb tus IP zoo li qub
- Tam sim no tshaj tawm ssid thiab tus password rau koj li Access point.
- txuas mus rau Access point los ntawm ib qho khoom siv STA
- host tus neeg rau zaub mov ntawm chaw nres nkoj 80 uas yog lub chaw nres nkoj tsis raug rau kev sib tham hauv internet, Hypertext Transfer Protocol (HTTP)
- sau 192.168.1.4 ntawm koj lub vev xaib rau intro webpage thiab 192.168.1.4/Value rau sensor nyeem lub vev xaib
// IP zoo li qub rau AP
IPAddress ap_local_IP (192, 168, 1, 4);
IPAddress ap_gateway (192, 168, 1, 254);
IPAddress ap_subnet (255, 255, 255, 0); // ssid thiab AP rau WiFi hauv zos hauv STA hom
const char WiFissid = "*********";
const char WiFipass = "*********";
// ssid thiab dhau rau AP
const char APssid = "********";
const char APpass = "********";
ESP8266WebServer server (80);
void teeb tsa {
server.on ("/", onHandleDataRoot);
server.on ("/Tus nqi", onHandleDataFeed);
server.onNotFound (onHandleNotFound);
}
void taskAPCallback () {
Serial.println ("taskAP pib");
server.handleClient ();
}
void onHandleDataRoot () {server.send (200, "ntawv/html", PAGE1); }
void onHandleDataFeed () {
server.send (200, "ntawv nyeem/html", PAGE2); }
void onHandleNotFound () {
Cov hlua xov = "Cov ntaub ntawv tsis pom / n / n";
lus += "URI:";
lus += server.uri ();
lus += "\ nMethod:";
lus += (server.method () == HTTP_GET)? "GET": "POST";
lus += "\ n Cov ntaub ntawv:";
lus += server.args ();
lus += "\ n";
server.send (404, "text/plain", message);}
void reconnectAPWiFi () {
WiFi.mode (WIFI_AP_STA);
ncua (100);
WiFi.disconnect ();
boolean xwm txheej = WiFi.softAPConfig (ap_local_IP, ap_gateway, ap_subnet);
yog tias (xwm txheej == muaj tseeb) {
Serial.print ("Teeb tsa mos-AP …");
boolean ap = WiFi.softAP (APssid, APpass);
yog tias (ap == muaj tseeb) {
Serial.print ("txuas nrog: / t");
// IPAddress myIP = WiFi.softAPIP ();
Serial.println (WiFi.softAPIP ());
}
server.begin ();
}
}
Kauj Ruam 6: Code rau Tshaj Tawm Cov Ntaub Ntawv rau Yam Hais
Ntawm no peb tab tom tshaj tawm cov ntawv nyeem sensor rau Yam Hais. cov theem hauv qab no xav tau kom ua tiav txoj haujlwm no-
- Tsim koj tus account hauv kev hais lus
- Tsim cov channel thiab cov teb los khaws koj cov ntaub ntawv sensor
- peb tuaj yeem tau txais thiab tshaj tawm cov ntaub ntawv los ntawm ESP rau thingSpeak thiab hloov pauv siv GET thiab POST thov mus rau api.
- peb tuaj yeem tshaj tawm peb cov ntaub ntawv rau ThingSpeak raws li hauv qab no
void taskWiFiCallback () {
WiFiClient wifiClient; yog (wifiClient.connect (hostId, 80)) {String postStr = apiKey; postStr += "& field1 ="; postStr += Txoj hlua (ntub); postStr += "& field2 ="; postStr += Txoj hlua (tempC); postStr += "& teb 3 ="; postStr += Txoj hlua (tempF); postStr += "\ r / n / r / n"; wifiClient.print ("POST /hloov tshiab HTTP /1.1 / n"); wifiClient.print ("Tus tswv tsev: api.thingspeak.com / n"); wifiClient.print ("Kev sib txuas: kaw / n"); wifiClient.print ("X-THINGSPEAKAPIKEY:"+apiKey+"\ n"); wifiClient.print ("Cov ntsiab lus-Hom: thov/x-www-form-urlencoded / n"); wifiClient.print ("Cov ntsiab lus-Ntev:"); wifiClient.print (postStr.length ()); wifiClient.print ("\ n / n"); wifiClient.print (postStr); } wifiClient.stop (); cov. }
Kauj Ruam 7: Txoj Cai Tag Nrho
Cov lej tag nrho muaj nyob hauv kuv qhov chaw cia khoom github
Khab nias:
- Arduino JSON: ArduinoJson
- ESP826WebServer
- Teem Sijhawm
- TSH 31
- I2C Luam theej duab
- HIH6130 cov lus qhia qhia
- Hlau Arduino
- NCO.io
Pom zoo:
WunderThing: Roj Teeb-Txhawb Nqa, Sib Nqus, ESP8266 Huab Cua Huab Cua IoThing!: 6 Cov Kauj Ruam
Lub WunderThing: Roj Teeb-Txhawb Nqa, Sib Nqus, ESP8266 Huab Cua Huab Cua IoThing!: Nyob zoo, Rau kuv thawj zaug puas tau qhia qhia rau kuv qhia koj txog Qhov Tsis Txaus Ntshai. Nov yog qhov haujlwm tsis ntev los no uas kuv lub hom phiaj yog txhawm rau tsim huab cua huab cua huab cua txias tub yees
IOT Raws Li Huab Cua Huab Cua thiab Cua Ceev Saib Xyuas Qhov System: 8 Kauj Ruam
IOT Raws Li Huab Cua Huab Cua thiab Kev Saib Xyuas Cua Cua Cua: Tsim Los Ntawm - Nikhil Chudasma, Dhanashri Mudliar thiab Ashita Raj Cov huab cua yuav tsum tau saib xyuas txhawm rau txhawb nqa kev txhim kho hauv kev ua liaj ua teb, tsev ntsuab
Huab Cua Huab Cua Huab Cua: 11 Kauj Ruam (nrog Duab)
Huab Cua Huab Cua Huab Cua: Txoj haujlwm no ua rau huab cua huab siv Raspberry Pi Zero W. Nws txuas rau Yahoo Huab Cua API thiab nyob ntawm qhov kev kwv yees rau hnub tom ntej hloov xim. Kuv tau tshoov siab los ntawm Wisconsin Gas Building uas muaj nplaim taws ntawm lub ru tsev uas hloov pauv
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
Lub Sijhawm Huab Cua Huab Cua Siv Lub Tswb Qub thiab Arduino: 13 Kauj Ruam (nrog Duab)
Lub Sijhawm Huab Cua Huab Cua Siv Lub Tswb Qub thiab Arduino: Kuv muaj lub tswb nrov tawg nyob ib puag ncig thiab tau los nrog lub tswv yim los hloov nws mus rau moos thiab chaw qhia huab cua huab cua. temp, av noo, siab) LCD zaub