Cov txheej txheem:

Covid19 Stat IoT Display: 5 Kauj Ruam
Covid19 Stat IoT Display: 5 Kauj Ruam

Video: Covid19 Stat IoT Display: 5 Kauj Ruam

Video: Covid19 Stat IoT Display: 5 Kauj Ruam
Video: IoT Happy Hour #5: Fold for Covid 2024, Kaum ib hlis
Anonim
Image
Image
Yam Uas Xav Tau
Yam Uas Xav Tau

Lub ntiaj teb tam sim no muaj tus kabmob coronavirus thiab zoo li ntau lwm lub tebchaws nws raug kaw hauv Is Nrias teb ib yam nkaus, yog li kuv tau txais lub tswv yim no los tsim IoT zaub uas yuav muab sijhawm hloov tshiab ntawm Corona Statistic ntawm lub tebchaws. Kuv siv API uas muab cov ntaub ntawv ntawm Is Nrias teb, Tab sis koj tuaj yeem siv ib qho API nrog kev hloov pauv me ntsis hauv cov cai.

Kauj Ruam 1: Yam Yuav Tsum Tau

Yam Uas Xav Tau
Yam Uas Xav Tau
Yam Uas Xav Tau
Yam Uas Xav Tau

Nov yog yam uas koj yuav xav tau los ua IoT zaub:

  • NodeMCU (ESP8266) Cov
  • 16x2 LCD module (I2C)
  • Breadboard (yeem)
  • Qee Cov Hluav Taws Xob/ Jumpers
  • USB cable

Kauj ruam 2: Kev sib txuas

Kev sib txuas
Kev sib txuas
Kev sib txuas
Kev sib txuas
Kev sib txuas
Kev sib txuas

Cov kev sib txuas yog yooj yim zoo nkauj. Tsuas muaj 4 xaim txuas. Koj tuaj yeem siv lub khob cij los tso esp8266 hauv nws thiab tom qab ntawd txuas rau lub LCD module lossis koj tsuas tuaj yeem siv ncaj qha poj niam rau poj niam jumper xov hlau txuas.

Cov kev sib txuas yog (ESP-> LCD):

  1. VIN -> VCC (rau 5V)
  2. GND -> GND
  3. D2 -> SDA
  4. D1 -> SCL

Tam sim no tsuas yog txuas lub esp8266 nrog USB cable rau PC, tam sim no peb tsuas yog xav tau xa cov cai.

Kauj ruam 3: Coding

Coding
Coding

Tam sim no, qhov no yog qhov tseem ceeb tshaj plaws. Koj coob leej ntawm koj yuav muaj lus nug hauv siab tias qhov no ua haujlwm li cas?

Yog li, Nws xub txuas rau wifi thiab tom qab ntawd txuas mus rau API txhawm rau khaws cov ntaub ntawv JSON, tom qab ntawd nws txiav txim siab JSON cov ntaub ntawv thiab khaws cov txiaj ntsig ntawd hauv qhov sib txawv, tom qab ntawd LCD qhia cov txiaj ntsig thiab qhov no txuas ntxiv hauv lub voj.

API kuv siv yog https://coronago.xyz/api/data.json, uas tau txais nws cov ntaub ntawv los ntawm https://www.covid19india.org/, Nws muab cov ntaub ntawv tsuas yog rau Is Nrias teb, Tab sis muaj ntau API rau lwm lub tebchaws, koj tuaj yeem siv ib qho API, tab sis xyuas kom nws tuaj yeem nkag tau los ntawm

Ua ntej, koj yuav tsum teeb tsa ESP8266 pawg thawj coj txhawb rau Arduino IDE. Ua raws li qhov kev qhia no.

Qhov thib ob uas yuav tsum ua yog teeb tsa txhua lub tsev qiv ntawv xav tau, koj tuaj yeem yooj yim teeb tsa lawv los ntawm Arduino Tus Thawj Saib Xyuas Tsev Qiv Ntawv.

Tom qab ntawd qhib tus lej thiab hloov pauv daim ntawv pov thawj wifi thiab xa cov cai.

cov cai nyob ntawm no hauv kuv qhov chaw khaws GitHub-https://github.com/Soumojit28/covid19-iot-display.

Kauj Ruam 4: Txoj Cai Piav Qhia thiab Siv Lwm Yam API

Kev piav qhia Code thiab Siv Lwm Yam API
Kev piav qhia Code thiab Siv Lwm Yam API

Cov cai yog yooj yim zoo nkauj

Hauv qhov tsis muaj teeb tsa ib feem nws pib lub LCD module thiab nthuav tawm cov lus pom tom qab ntawd nws txuas rau lub network wifi.

Hauv lub voj ib feem, nws nqa cov ntaub ntawv JSON los ntawm API thiab txiav txim siab ad khaws nws hauv qhov sib txawv tom qab ntawd nws nthuav tawm cov ntawd hauv cov lej saib thiab LCD.

rau kev siv lwm tus API koj yuav tsum hloov chaw nyob hauv kab kab ntawv no

http.begin ("https://coronago.xyz/api/data.json"); // API NPE

Lwm qhov API yuav tsum ua haujlwm nrog kev txuas HTTP, HTTPS kev txuas yuav tsis ua haujlwm hauv cov cai no thiab koj yuav tau txais qhov yuam kev -1.

API rov qab JSON cov ntaub ntawv zoo li no

Tam sim no Tus lej tom ntej no tsuas yog txiav txim siab JSON thiab khaws cov txiaj ntsig hauv qhov sib txawv, qhov no tag nrho nyob ntawm API thiab JSON cov ntaub ntawv nws rov qab los. Tab sis nws hloov pauv tau yooj yim, yog xav paub ntxiv koj tuaj yeem tshawb xyuas qhov kev qhia no.

StaticJsonBuffer JSONBuffer; // Memory pool JsonObject & parsed = JSONBuffer.parseObject (them nyiaj); // Parse cov lus lees paub = parsed ["tau lees paub"]; zoo = parsed ["zoo"]; tuag = parsed ["tuag"]; current_active = parsed ["nquag"];

Tom qab ntawd txoj cai tsuas yog qhia cov kev hloov pauv hauv cov ntawv saib thiab hauv LCD.

Serial.print ("paub tseeb:"); Serial.println (paub tseeb); Serial.print ("zoo:"); Serial.println (zoo tu qab tso); Serial.print ("currenty_active:"); Serial.println (current_active); Serial.print ("tuag:"); Serial.println (tuag); yog (httpCode == 200) {// tso saib cov ntaub ntawv hauv lcd lcd.clear (); lcd.setCursor (0, 0); lcd.print ("Pom zoo:"); lcd.print (paub tseeb); lcd.setCursor (0, 1); lcd.print ("Tuag:"); lcd.print (tuag); ncua (2500); lcd.clear (); lcd.setCursor (0, 0); lcd.print ("Ua haujlwm:"); lcd.print (current_active); lcd.setCursor (0, 1); lcd.print ("Rov qab tau:"); lcd.print (zoo tu qab tso); ncua (2500);

}

Kauj Ruam 5: Xaus

Nov yog txoj haujlwm zoo los tshuaj xyuas cov txheeb cais txhua lub sijhawm, thiab koj tuaj yeem tsim nws kom dhau koj lub sijhawm hauv qhov xwm txheej raug kaw no.

Yog tias koj xav tau kev pab koj tuaj yeem nug kuv ntawm cov lus lossis koj tuaj yeem qhib qhov teeb meem hauv kuv Github

github.com/Soumojit28/covid19-iot-display rau txhua qhov teeb meem cuam tshuam nrog cov cai.

Ua tsaug.

Pom zoo: