Cov txheej txheem:

Ib Qhov Chaw Ntxiv Arduino Weather (ESP-01 & BMP280 & DHT11 & OneWire): 4 Cov Kauj Ruam
Ib Qhov Chaw Ntxiv Arduino Weather (ESP-01 & BMP280 & DHT11 & OneWire): 4 Cov Kauj Ruam

Video: Ib Qhov Chaw Ntxiv Arduino Weather (ESP-01 & BMP280 & DHT11 & OneWire): 4 Cov Kauj Ruam

Video: Ib Qhov Chaw Ntxiv Arduino Weather (ESP-01 & BMP280 & DHT11 & OneWire): 4 Cov Kauj Ruam
Video: Argent Weather Station Arduino Hacks - Hardware and Code 2024, Hlis ntuj nqeg
Anonim
Ib Qhov Chaw Ntxiv Arduino Weather (ESP-01 & BMP280 & DHT11 & OneWire)
Ib Qhov Chaw Ntxiv Arduino Weather (ESP-01 & BMP280 & DHT11 & OneWire)

Ntawm no koj tuaj yeem pom ib qho rov ua dua ntawm kev siv OneWire nrog ob peb tus pin ntawm ESP-01. Cov cuab yeej tsim hauv cov lus qhia no txuas rau Wifi network ntawm koj xaiv (koj yuav tsum muaj daim ntawv pov thawj …) Sau cov ntaub ntawv nkag siab los ntawm BMP280 thiab DHT11, thiab xa cov ntaub ntawv khaws tseg mus rau ThingSpeak channel tau muab rau kuv. Kuv xav tias koj paub yuav ua li cas rub cov duab kos rau koj ESP-01, yog li kuv yuav tsis mus rau hauv cov ntsiab lus ntawd. nrog max 3.3V DC. Not ntau cov ntawv ntxiv, nyeem yuav tsum ncaj qha los ntawm qhov no.

Kauj Ruam 1: Kauj Ruam 1: BOM

Kauj ruam 1: BOM
Kauj ruam 1: BOM
Kauj ruam 1: BOM
Kauj ruam 1: BOM
Kauj ruam 1: BOM
Kauj ruam 1: BOM
Kauj ruam 1: BOM
Kauj ruam 1: BOM

Kho vajtse:

1 x Wifi module: ESP-01 (kuv siv 1024 KB version)

1 x Siab thiab Kub sensor: BMP280

1 x Vaum thiab Kub sensor: DHT11

1 x Tus Tswj Hluav Taws Xob AMS1117 (xaiv tau rau lub zog ncaj qha, lossis koj tuaj yeem siv lwm yam muaj peev xwm tswj hwm koj qhov hluav taws xob nkag mus rau qhov ruaj khov 3.3V)

Kauj Ruam 2: Kauj Ruam 2: Txuas Hluav Taws Xob

Kauj ruam 2: Kev thaiv kab
Kauj ruam 2: Kev thaiv kab

ESP-01 VCC to 3.3VESP-01 GND to GNDESP-01 TX to DHT11 DATAESP-01 GPIO0 to BMP280 SDAESP-01 GPIO2 to BMP280 SCLDHT11 VCC to 3.3VDHT11 GND to GNDBMP280 VCC to 3.3VBMP280 GND to GND

Kauj Ruam 3: Kauj Ruam 3: Txoj Cai

#include #include #include // CHECK #define BMP280_ADDRESS mine ua haujlwm nrog (0x76) #include #define DHTPIN 1 // GPIO1 (Tx) #define DHTTYPE DHT11 #define ONE_WIRE_BUS 3 // GPIO3 = Rx const char* ssid = "asd "; // KOJ WIFI SSID const char* password = "asd"; // KOJ WIFIPASS const char* host = "api.thingspeak.com"; const char* writeAPIKey = "asd"; // KOJ APIKEY // DHT11 khoom ntab kub_buiten; ntab kub_buiten2; DHT dht (DHTPIN, DHTTYPE, 15); // BMP280 Adafruit_BMP280 bmp; teeb tsa tsis muaj dab tsi () {// I2C khoom Wire.pins (0, 2); Hlau.begin (0, 2); // DHT1 dht.begin (); // BMP280 yog (! Bmp.begin ()) {// Serial.println ("Tsis muaj BMP280"); // thaum (1) {}} // Txuas rau WiFi network WiFi.begin (ssid, password); thaum (WiFi.status ()! = WL_CONNECTED) {ncua (500); }} void loop () {// DHT11 float humidity = dht.readHumidity (); ntab kub = dht.readTemperature (); yog (isnan (av noo) || isnan (kub)) {rov qab; } // BMP280 Txoj hlua t = Txoj hlua (bmp.readTemperature ()); Txoj hlua p = Txoj hlua (bmp.readPressure ()); // TCP Txuas Txuas WiFiClient tus neeg siv khoom; const int httpPort = 80; yog (! client.connect (host, httpPort)) {rov qab; } Txoj hlua url = "/hloov tshiab? Qhov tseem ceeb ="; url += writeAPIKey; url += "& field1 ="; url += Txoj hlua (ntsuas kub); // DHT11 CELSIUS url += "& field2 ="; url += Txoj hlua (av noo); // DHT11 RELATIVE HUMIDITY url += "& field3 ="; url += Txoj hlua (bmp.readTemperature ()); // BMP280 CELSIUS url += "& field4 ="; url += Txoj hlua (bmp.readPressure ()/100); // BMP280 MILLIBAR url += "& field5 ="; url += Txoj hlua (bmp.readAltitude (1013.25)); // BMP280 METER url += "& field6 ="; url += Txoj hlua ((kub +bmp.readTemperature ())/2); // DHT11 + BMP280 AVERAGE CELSIUS url + = "\ r / n"; // Xa ntawv thov mus rau tus neeg siv khoom server.print (String ("GET") + url + "HTTP/1.1 / r / n" + "Host:" + host + "\ r / n" + "Connection: close / r / n / r / n "); ncua (1000); }

Pom zoo: