Cov txheej txheem:

Siv 4 Pins ntawm ESP8266-01: 3 Cov Kauj Ruam
Siv 4 Pins ntawm ESP8266-01: 3 Cov Kauj Ruam

Video: Siv 4 Pins ntawm ESP8266-01: 3 Cov Kauj Ruam

Video: Siv 4 Pins ntawm ESP8266-01: 3 Cov Kauj Ruam
Video: Playful Kiss - Playful Kiss: Full Episode 1 (Official & HD with subtitles) 2024, Kaum ib hlis
Anonim
Siv 4 Pins ntawm ESP8266-01
Siv 4 Pins ntawm ESP8266-01
Siv 4 Pins ntawm ESP8266-01
Siv 4 Pins ntawm ESP8266-01
Siv 4 Pins ntawm ESP8266-01
Siv 4 Pins ntawm ESP8266-01

Nco tseg: Txoj haujlwm no yog qhov txuas ntxiv ntawm kev qhia ua ntej uas tsuas yog siv 2 pins. Lub xov tooj tsawg (4) ntawm GPIO pins ntawm ESP8266-01 yuav zoo li muaj teeb meem, rau ib qho kev thov loj. Yog yog tias ib tus siv tus pin hauv txoj hauv kev ntse nws yog qhov ua tau zoo los ua ntau yam nrog tsuas yog 4 tus pin hauv qee qhov ntawm kuv cov lus qhia tsis ntev los no, Kuv tau qhia siv DHT11 DS18B20, OLED, RTC thiab BMP180 nrog ESP8266-01. Hauv cov lus qhia no kuv tau teeb tsa los siv 4 lub ntsuas pa thiab cov zaub, thaum tseem xa cov ntaub ntawv tau txais mus rau Thingspeak. Nws yog nthuav dav ntawm txoj haujlwm ntawm kev saib xyuas huab cua hauv thiab ib puag ncig kuv cov qaib coop. Yog lawm, koj tuaj yeem hu qhov no yog huab cua, tab sis nws tsuas yog qhia txog kev siv 4 tus pin, koj tuaj yeem ua lwm yam yooj yim li no kuv yuav siv 2 tus pin rau I2C (BMP180 thiab OLED) 1 tus pin rau 2 DS18B20 sensors ntawm lub OneWire raws tu qauv 1 tus pin rau DHT11 Txawm hais tias ESP8266-01 tam sim no muaj tag nrho nws cov pins siv, Kuv tseem tuaj yeem ntxiv cov ntsuas ntau ntxiv (lossis tus ua haujlwm) los ntawm OneWire raws tu qauv thiab/lossis ntawm I2C raws tu qauv. Yog li cas, peb xav tau dab tsi: BOM

  • ESP8266-01
  • 2 x DS18B20
  • 1 x DHT11
  • 1 x BMP180
  • OLED (yeem)

thiab ntawm qhov tseeb ntawm lub khob cij, 3.3 V PSU thiab qee lub xov tooj cua hauv xov tooj thiab Tus Nqi Dab Tsi

Tsuas yog qee cov lus hais txog BOM:

  • ESP8266-01 Pom tseeb qhov haujlwm no yog hais txog kev siv tus pin txwv ntawm ESP8266-01, tab sis yog tias koj tseem xav yuav ib qho, koj tuaj yeem txiav txim siab ESP8266-12 uas muaj tus pin ntau dua
  • DHT11A pheej yig txhua lub hom phiaj cov av noo thiab ntsuas kub. Nws tsis yog qhov tseeb tiag tab sis nws yuav ua. Yog tias koj tseem xav yuav ib qho, koj tuaj yeem xaiv DHT22 uas yog qhov xav tau ntau dua, tab sis koj tseem tuaj yeem xaiv rau AMS2321. Qhov ntawd yog hom DHT22 uas haum rau I2C, yog li tso lwm tus pin
  • BMP180 ntsuas qhov kub thiab txias. Nws yog tus ua tiav ntawm BMP085, tab sis tam sim no nws tseem muaj qee tus suvessors nws tus kheej. Muaj qhov (pheej yig dua) BMP280, tab sis koj tseem tuaj yeem xaiv rau BME280 uas ntsuas qhov kub thiab txias, huab cua thiab av noo. Txoj kev ntawd koj tuaj yeem txuag ntawm DHT/AMS sensor
  • OLEDI tsuas yog siv qhov ntawd kuv thiaj tuaj yeem pom sai sai tias cov ntsuas tau nyeem, tab sis koj tseem tuaj yeem tshawb xyuas nws ntawm Thingspeak. OLED tseem me dhau lawm los luam tawm txhua qhov kev nyeem qhov tseem ceeb

Kauj ruam 1: Circuit Court

Qhov Circuit
Qhov Circuit

4 tus pin ntawm ESP8266 tsis tau hais xws li hauv PCB, thiab cov duab feem ntau tsuas yog qhia meej meej GPIO0 thiab GPIO2. Yog li cas ESP826-01 muaj a GPIO1 tus pin (Tx tus pin) thiab GPIO3 tus pin (Rx tus pin).i yuav siv cov pins raws li hauv qab no

  • GPIO0 -> SDA tus pin ntawm I2C chaw nres nkoj
  • GPIO1 -> DHT11
  • GPIO2-> SCL tus pin ntawm I2C chaw nres nkoj
  • GPIO3-> OneWire Bus

Raws li kuv tus I2C cov qauv twb tau rub tawm cov neeg tawm tsam, Kuv yuav tsis ntxiv ib qho I2C rub tawm cov neeg tawm tsam. DS18B20 tseem xav tau rub tawm cov tshuaj tiv thaiv uas kuv tau siv 4k7, tab sis nws yeej tsis yog qhov tseem ceeb, 10k kuj tseem zoo. DHT11 xav tias tseem xav tau rub tawm tus neeg tawm tsam tab sis kuv pom nws ua haujlwm yam tsis muaj ib yam nkaus. ntxiv 4k7 resistor tsis hloov ib qho ntawm kev nyeem, yog li kuv tso nws tawm. Ntau ntawm 3 tus lej DHT11 tus qauv, twb muaj 10 k soldered mus rau tus qauv. Kuv nyuam qhuav pom tias kuv tsis tau kos cov kev sib txuas rau OLED. Qhov ntawd yog vim kuv tsuas yog txuas nws rau kev txheeb xyuas sai, tab sis koj puas xav ntxiv nws, nws tsuas yog teeb meem ntawm kev txuas SDA rau SDA thiab SCL rau SCL …

Kauj Ruam 2: Txoj Haujlwm

Qhov kev zov me nyuam yog qhov ncaj heev. Ua ntej nws teeb tsa lub tsev qiv ntawv thiab cov ntsuas ntsuas nws txuas DHT11 rau tus pin 1 (Tx) thiab OnWire npav rau DS18B20 rau tus pin 3 (Rx). Txhawm rau siv ntau dua 1 DS18B20 lub ntsuas ntawm lub npav OneWire, koj yuav tsum paub lawv 'chaw nyob tshwj xeeb'. Yog tias koj tsis muaj qhov ntawd koj xav tau ib txoj haujlwm los nyeem cov chaw nyob ntawd. Ua qhov ntawd ntawm arduino kom yooj yim Hauv qhov program koj tseem yuav tsum muab koj li ntawv pov thawj WiFi nrog rau kev sau API rau koj Thingspeak Channel

/*

Teb 1 qhov chaw sov (DHT11) Teb 2 av noo roost (DHT11) teb 3 Coop kub (DS18B20) teb 4 av kub (DS18B20) teb 5 Airpressure (bmp180) teb 6 Sab nraum kub (bmp180) * */ #suav nrog #include // https://www.pjrc.com/teensy/td_libs_OneWire.html #include // https://milesburton.com/Main_Page?title=Dallas_Tem… #include #include #include "SSD1306.h" SSD1306 zaub (0x3c, 0, 2); #define DHTPIN 1 // GPIO1 (Tx) #define DHTTYPE DHT11 #define ONE_WIRE_BUS 3 // GPIO3 = Rx const char* ssid = "YourSSID"; const char* password = "YourPassword"; const char* tus tswv tsev = "api.thingspeak.com"; const char* writeAPIKey = "W367812985"; // siv Koj li ntawv sau // DHT11 khoom ntab kub_buiten; ntab kub_buiten2; DHT dht (DHTPIN, DHTTYPE, 15); // DS18b20 khoom OneWire oneWire (ONE_WIRE_BUS); // ib qho piv txwv sib txuas lus nrog ib qho khoom siv OneWire DallasTemperature sensors (& oneWire); // Dhau qhov chaw nyob ntawm peb qhov piv txwv oneWire rau Dallas Kub. DeviceAddress Probe01 = {0x28, 0x0F, 0x2A, 0x28, 0x00, 0x00, 0x80, 0x9F}; DeviceAddress Probe0 = {0x28, 0x10, 0xA4, 0x57, 0x04, 0x00, 0x00, 0xA9}; // bmp180 khoom Adafruit_BMP085 bmp; teeb tsa tsis muaj dab tsi () {// I2C khoom Wire.pins (0, 2); Hlau.begin (0, 2); // Initialize sensors // dht 11 khoom dht.begin (); // ds18b20 khoom sensors.begin (); // ds18b20 // teeb tsa kev daws teeb meem rau 10 ntsis (Yuav yog 9 txog 12 khoom.. qis dua sai dua) sensors.setResolution (Probe01, 10); sensors.setResolution (sojntsuam02, 10); // bmp180 khoom yog (! bmp.begin ()) {// Serial.println ("Tsis muaj BMP180 /BMP085"); // thaum (1) {}} // OLED khoom display.init (); display.flipScreenVertically (); display.setFont (ArialMT_Plain_10); ncua (1000); // Txuas rau WiFi network WiFi.begin (ssid, password); thaum (WiFi.status ()! = WL_CONNECTED) {ncua (500); }} void loop () {// ds18b20stuff ------------------- sensors.requestTemperatures (); // Xa cov lus txib kom sov kub_buiten = sensors.getTempC (Probe01); // temperature_buiten2 = sensors.getTempC (Probe02); // // dht11 khoom ---------------- ---- ntab ntub = dht.readHumidity (); ntab kub = dht.readTemperature (); yog (isnan (av noo) || isnan (kub)) {rov qab; } // bmp khoom ------------------------- Txoj hlua t = Txoj hlua (bmp.readTemperature ()); Txoj hlua p = Txoj hlua (bmp.readPressure ()); // OLED khoom -------------------------- display.clear (); display.drawString (0, 10, p); // bmp siab tso tawm.drawString (0, 24, String (temperature_buiten)); // ds18b20 display.drawString (0, 38, String (humidity)); // dht11 zaub.display (); // ua TCP sib txuas WiFiClient tus thov kev pab; 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 (kub); // roost (DHT1) url += "& field2 ="; url += Txoj hlua (av noo); // roost (DHT11) url += "& field3 ="; url += String (kub_buiten); // coop kub (DS18B20 nr 1) url += "& field4 ="; url += Txoj hlua (kub_buiten2); // av kub (DS18B29 nr 2) url += "& field5 ="; url += Txoj hlua (bmp.readTemperature ()); Sab nraum kub (BMP180) url += "& field6 ="; url += Txoj hlua (bmp.readPressure ()); // Airpressure (BMP180) 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); }

……..

Kauj ruam 3: Ntau

Tam sim no txoj haujlwm no tsuas yog saib xyuas, tab sis dab tsi yog qhov txwv koj ntawm kev ntxiv BH1750 I2C lub teeb pom kev ntsuas los ntsuas yog tias nws yog yav tsaus ntuj lossis yav sawv ntxov lossis RTC kom paub lub sijhawm nruab hnub thiab qhib thiab kaw lub qhov rooj ntawm lub koom haum tau txais kev pab ntawm daim npav PCF8574 I2C I/O nthuav dav, lossis zoo li nws twb tau nyob hauv vaj lawm, ntxiv PCF8591 lossis ADS1115 AD hloov pauv los ntsuas av av thiab qhib lub twj tso kua mis thaum tsim nyog. Los yog tej zaum hloov pauv ntawm lub rhaub dej kub thaum qhov kub poob qis dua zeroif muaj I2 C nti rau nws, ESP8266 tuaj yeem siv tau.

Cov ntawv tseem ceeb txawm hais tias: Cov haujlwm zoo li ua haujlwm tau zoo, tab sis yog tias koj ntxiv lwm lub cim rau Rx lossis Tx, tshwj xeeb tshaj yog tias koj ua rau lawv tso tawm, cov pins yuav nco ntsoov nco ntsoov tias lawv tsis yog GPIO tus pin tiag tiag. Nws yog qhov zoo dua los qhia tus pin los ntawm qhov pib tias tam sim no lawv yog GPIO pins. One ua li ntawd los ntawm kev sau cov lus hauv qab no hauv teeb:

pinMode (1, FUNCTION_3);

pinMode (3, FUNCTION_3);

Pom zoo: