Cov txheej txheem:
- Kauj ruam 1: Tau txais API Ntsiab Cai thiab URL Los Ntawm Openweather.org
- Kauj ruam 2: Daim duab txuas
- Kauj Ruam 3: Arduino Code
- Kauj Ruam 4: Ua Txoj Cai
Video: (IOT Project) Tau Txais Cov Ntaub Ntawv Huab Cua Siv ESP8266 thiab Openweather API: 5 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:24
Hauv cov lus qhia no peb yuav tsim txoj haujlwm IOT yooj yim uas nqa cov ntaub ntawv huab cua ntawm peb lub nroog los ntawm openweather.com/api thiab tso tawm nws siv software ua.
Khoom siv:
- Arduino
- ESP8266 lossis lwm yam esp module
- Arduino IDE Cov
- Ua software
- Cov qhob cij
- Jumperwires Txiv neej rau Txiv neej thiab Txiv neej rau Poj Niam
Kauj ruam 1: Tau txais API Ntsiab Cai thiab URL Los Ntawm Openweather.org
- Tsim tus account hauv https://openweathermap.org (Duab 1)
- Tom qab koj nkag mus rau API yuam sij thiab koj yuav tau txais tus lej API raws li qhia hauv duab. (Duab 2)
- Luam tus lej API thiab khaws nws hauv cov ntawv sau cia. (Duab 3)
- Mus rau qhov kev xaiv API (Duab 4)
- Mus rau API doc xaiv raws li qhia hauv duab (Duab 5)
- Luam qhov url los ntawm thiab qhia thiab khaws nws hauv cov ntawv sau cia (Duab 6)
Kauj ruam 2: Daim duab txuas
Kauj Ruam 3: Arduino Code
Ua ntej theej cov cai no rau hauv Arduino nco ntsoov tias koj tau rub tawm ESP8266 pawg thawj coj mus rau hauv arduino lub tswv yim siv Boards manager.
#suav nrog
#include #include #include const char* ssid = "Koj SSID"; const char* password = "Koj SSID PASSWORD"; // Koj lub npe sau nrog URL kab lossis IP chaw nyob nrog txoj hlua Txoj hlua openWeatherMapApiKey = "Muab koj tus lej API tso rau ntawm no"; // Hloov nrog koj lub tebchaws cov cai thiab lub nroog Txoj hlua lub nroog = "Mumbai"; Txoj hlua countryCode = "IN"; Cov ntaub ntawv xov [16]; // Lub Sijhawm DEFAULT TSEV YOG 10 SECONDS RAU KOOM TSEV KAWM NTAWV // Rau daim ntawv thov zaum kawg, txheeb xyuas qhov API hu txwv ib teev/feeb kom tsis txhob raug thaiv/txwv tsis pub kos npe ntev lastTime = 0; // Timer teem rau 10 feeb (600000) // tsis tau kos npe ntev timerDelay = 600000; // Teeb tsa lub sijhawm rau 10 vib nas this (10000) tsis tau kos npe ntev timerDelay = 10000; Txoj hlua jsonBuffer; teeb tsa tsis muaj dab tsi () {Serial.begin (115200); WiFi.begin (ssid, password); //Serial.println("Txuas"); thaum (WiFi.status ()! = WL_CONNECTED) {ncua (500); // Serial.print ("."); } // Serial.println (""); // Serial.print ("Txuas nrog WiFi network nrog IP Chaw Nyob:"); // Serial.println (WiFi.localIP ()); // // Serial.println ("Timer set to 10 seconds (timerDelay variable), nws yuav siv 10 vib nas this ua ntej tshaj tawm thawj zaug nyeem ntawv."); } void loop () {// Xa HTTP GET thov yog ((millis () - lastTime)> timerDelay) {// Txheeb xyuas WiFi li xwm txheej txuas yog (WiFi.status () == WL_CONNECTED) {String serverPath = "https://api.openweathermap.org/data/2.5/weather?q= " + city +", " + countryCode +" & APPID = " +" d5b56fd07988143ae141503ed9d81742 " +" & units = metric "; jsonBuffer = httpGETRequest (serverPath.c_str ()); //Serial.println(jsonBuffer); JSONVar myObject = JSON.parse (jsonBuffer); // JSON.typeof (jsonVar) tuaj yeem siv los ua hom var yog tias (JSON.typeof (myObject) == "undefined") {//Serial.println("Parsing input ua tsis tiav! "); rov qab; } // Serial.print ("JSON kwv ="); // Serial.println (myObject); // Serial.print ("Kub:"); // Serial.println (myObject ["main"] ["temp"]); // Serial.print ("Siab:"); // Serial.println (myObject ["lub ntsiab"] ["siab"]); // Serial.print ("Vaum:"); // Serial.println (myObject ["lub ntsiab"] ["av noo"]); // Serial.print ("Cua Ceev:"); // Serial.println (myObject ["cua"] ["ceev"]); int temp = myObject ["main"] ["temp"]; ntev pres = myObject ["lub ntsiab"] ["siab"]; int ntub = myObject ["lub ntsiab"] ["av noo"]; int cua = myObject ["cua"] ["ceev"]; Txoj hlua lub teb chaws = JSON.stringify (myObject ["sys"] ["lub teb chaws"]); String city1 = JSON.stringify (myObject ["lub npe"]); Txoj hlua huab cua = JSON.stringify (myObject ["huab cua"] [0] ["kev piav qhia"]); String icon = JSON.stringify (myObject ["huab cua"] [0] ["icon"]); data [0] = Txoj hlua (temp); cov ntaub ntawv [1] = "/"; data [2] = Txoj hlua (pres); cov ntaub ntawv [3] = "/"; data [4] = Txoj hlua (ntub); cov ntaub ntawv [5] = "/"; data [6] = Txoj hlua (cua); cov ntaub ntawv [7] = "/"; data [8] = teb chaws; cov ntaub ntawv [9] = "/"; data [10] = nroog 1; cov ntaub ntawv [11] = "/"; data [12] = huab cua; cov ntaub ntawv [13] = "/"; cov ntaub ntawv [14] = icon; data [15] = "\ n"; rau (int i = 0; i0) {// Serial.print ("HTTP Teb chaws tus lej:"); // Serial.println (httpResponseCode); ntsaws = http.getString (); } lwm {Serial.print ("Error code:"); Serial.println (httpResponseCode); } // Cov peev txheej pub dawb http.end (); payload rov qab; }
Kauj Ruam 4: Ua Txoj Cai
Ua ntej khiav cov cai no rub tawm lub cim cim duab uas yuav siv los qhia huab cua. Thiab khaws cov duab thiab cov cai hauv tib daim nplaub tshev.
ntshuam ua.serial.*;
Serial myPort; Cov duab img; Cov duab img2; Cov duab img3; Duab img4; Duab img5; Duab img6; Duab img7; Duab img8; Duab img9; PImage img10; PImage img11; PImage img12; Cov duab img13; Cov duab img14; PImage img15; PImage img16; Cov duab img17; PImage img18; koj temp; koj pres; ntub dej; cua zog; Txoj hlua lub nroog = ""; Txoj hlua lub teb chaws = ""; Txoj hlua huab cua = ""; Txoj hlua cim = ""; teeb tsa tsis muaj dab tsi () {loj (500, 500); myPort = Serial tshiab (qhov no, "COM3", 115200); img = loadImage ("01d.png"); img2 = loadImage ("01n.png"); img3 = loadImage ("02d.png"); img4 = loadImage ("02n.png"); img5 = loadImage ("03d.png"); img6 = loadImage ("03n.png"); img7 = loadImage ("04d.png"); img8 = loadImage ("04n.png"); img9 = loadImage ("09d.png"); img10 = loadImage ("09n.png"); img11 = loadImage ("10d.png"); img12 = loadImage ("10n.png"); img13 = loadImage ("11d.png"); img14 = loadImage ("11n.png"); img15 = loadImage ("13d.png"); img16 = loadImage ("13n.png"); img17 = loadImage ("50d.png"); img18 = loadImage ("50n.png"); } void kos () {keeb kwm yav dhau (72, 209, 204); textSize (22); sau (54, 69, 79); text ("Kub:", 25, 100); ntawv (temp +"° C", 200, 100); text ("Siab:", 25, 150); ntawv nyeem (pres + "hpa", 200, 150); text ("Vaum:", 25, 200); ntawv (ntub+" %", 200, 200); text ("Cua:", 25, 250); ntawv (cua+"m/s", 200, 250); text ("Lub Tebchaws/Lub Nroog:", 25, 300); ntawv (lub tebchaws + "-" + nroog, 200, 300); text ("Huab cua:", 25, 350); ntawv (huab cua, 200, 350); yog (icon.contains ("01d")) {duab (img, 380, 15); } lwm yog (icon.contains ("01n")) {duab (img2, 380, 15); } lwm yog (icon.contains ("02d")) {duab (img3, 380, 15); } lwm yog (icon.contains ("02n")) {duab (img4, 380, 15); } lwm yog (icon.contains ("03d")) {duab (img5, 380, 15); } lwm yog (icon.contains ("03n")) {duab (img6, 380, 15); } lwm yog (icon.contains ("04d")) {duab (img7, 380, 15); } lwm yog (icon.contains ("04n")) {duab (img8, 380, 15); } lwm yog (icon.contains ("09d")) {duab (img9, 380, 15); } lwm yog (icon.contains ("09n")) {duab (img10, 380, 15); } lwm yog (icon.contains ("10d")) {duab (img11, 380, 15); } lwm yog (icon.contains ("10n")) {duab (img12, 380, 15); } lwm yog (icon.contains ("11d")) {duab (img13, 380, 15); } lwm yog (icon.contains ("11n")) {duab (img14, 380, 15); } lwm yog (icon == "13d") {duab (img15, 380, 15); } lwm yog (icon.contains ("13n")) {duab (img16, 380, 15); } lwm yog (icon.contains ("50d")) {duab (img17, 380, 15); } lwm yog (icon.contains ("50n")) {duab (img18, 380, 15); }} void serialEvent (Serial myPort) {yog (myPort.available ()> 0) {String data = myPort.readStringUntil ('\ n'); yog (data! = tsis muaj) {data = trim (data); Cov khoom hlua = cais (cov ntaub ntawv, '/'); yog (items.length> 1) {temp = int (yam khoom [0]); pres = int (cov khoom [1]); ntub = int (cov khoom [2]); cua = int (cov khoom [3]); nroog = cov khoom [4].replace ("\" "," "); lub tebchaws = cov khoom [5].replace (" / "", ""); huab cua = cov khoom [6].replace ("\" "," "); icon = yam khoom [7].replace (" / "", ""); }}}}
Pom zoo:
Yuav Ua Li Cas Vaum Thiab Kub Tiag Tiag Cov Ntaub Ntawv Teev Npe Nrog Arduino UNO thiab SD-Card - DHT11 Cov ntaub ntawv-logger Simulation hauv Proteus: 5 Cov Kauj Ruam
Yuav Ua Li Cas Vaum Thiab Kub Tiag Tiag Cov Ntaub Ntawv Teev Npe Nrog Arduino UNO thiab SD-Card | DHT11 Cov ntaub ntawv-logger Simulation hauv Proteus: Taw qhia: nyob zoo, qhov no yog Liono Maker, ntawm no yog YouTube txuas. Peb tab tom tsim txoj haujlwm muaj tswv yim nrog Arduino thiab ua haujlwm ntawm cov kab ke. Cov ntaub ntawv-Logger: Cov ntaub ntawv logger (tseem cov ntaub ntawv-logger lossis cov ntaub ntawv kaw) yog cov cuab yeej siv hluav taws xob uas sau cov ntaub ntawv dhau sijhawm
Cov Ntaub Ntawv Huab Cua Siv Google Ntawv thiab Google Tsab Ntawv: 7 Kauj Ruam
Cov Ntaub Ntawv Huab Cua Siv Google Ntawv thiab Google Tsab Ntawv: Hauv Blogtut no, peb yuav xa cov ntawv nyeem ntawm SHT25 sensor mus rau google nplooj ntawv siv Adafruit huzzah ESP8266 uas pab xa cov ntaub ntawv mus rau is taws nem. thiab txoj hauv kev yooj yim uas txuag cov ntaub ntawv hauv
Kev Tau Txais Cov Ntaub Ntawv thiab Cov Ntaub Ntawv Pom Kev Pom Zoo rau MotoStudent Fais Fab Sib Tw Tsheb kauj vab: 23 Kauj Ruam
Kev Tshawb Nrhiav Cov Ntaub Ntawv thiab Cov Ntaub Ntawv Pom Zoo rau MotoStudent Hluav Taws Xob Sib Tw Tsheb: Cov ntaub ntawv khaws cov ntaub ntawv yog cov khoom siv khoos phis tawj thiab software ua haujlwm ua ke txhawm rau sau cov ntaub ntawv los ntawm cov ntsuas sab nraud, khaws thiab ua nws tom qab kom nws tuaj yeem pom cov duab thiab txheeb xyuas, tso cai rau cov kws tsim txuj ci los ua
IoT Ua Yooj Yim: Txheeb Xyuas Cov Ntaub Ntawv Huab Cua Tej Zaum: UV thiab Huab Cua Kub & Vaum: 7 Kauj Ruam
IoT Ua Yooj Yim: Txheeb Xyuas Cov Ntaub Ntawv Huab Cua Nyob deb: UV thiab Huab Cua Kub & Vaum: Ntawm qhov kev qhia no, peb yuav ntes cov ntaub ntawv nyob deb li UV (Ultra-Violet hluav taws xob), huab cua kub thiab av noo. Cov ntaub ntawv no yuav yog ib qho tseem ceeb heev thiab yuav siv rau yav tom ntej Chaw Ua Haujlwm Huab Cua.Qhov thaiv daim duab qhia tau tias peb yuav tau txais dab tsi thaum kawg
Yuav Ua Li Cas Tau Txais Cov Nkauj Los Ntawm Txhua Qhov (Haha) Lub Vev Xaib (Ntev Li Koj Tau hnov Nws Koj Yuav Tau Txais Nws Ok Zoo Yog Nws Tau Ntxig Hauv Flash Koj Yuav Tsis Muaj Peev Xwm) EDITED !!!!! Ntxiv Info: 4 Cov Kauj Ruam
Yuav Ua Li Cas Tau Txais Cov Nkauj Los Ntawm Txhua Qhov (Haha) Lub Vev Xaib (Ntev Li Koj Tau hnov Nws Koj Yuav Tau Txais Nws … Ok Zoo Yog Nws Tau Ntxig Hauv Flash Koj Yuav Tsis Muaj Peev Xwm) EDITED !!!!! Ntxiv Cov Lus Qhia: yog tias koj tau mus rau lub vev xaib thiab nws ua nkauj nkauj uas koj nyiam thiab xav tau nws ntawm no yog cov lus qhia rau koj tsis yog kuv qhov txhaum yog tias koj cuam tshuam qee yam (tsuas yog txoj hauv kev nws yuav tshwm sim yog tias koj pib tshem cov khoom yam tsis muaj laj thawj. ) Kuv tuaj yeem tau txais cov nkauj rau