Cov txheej txheem:

Kev Saib Xyuas Cog Siv ESP32 Yam thiab Blynk: 5 Kauj Ruam
Kev Saib Xyuas Cog Siv ESP32 Yam thiab Blynk: 5 Kauj Ruam

Video: Kev Saib Xyuas Cog Siv ESP32 Yam thiab Blynk: 5 Kauj Ruam

Video: Kev Saib Xyuas Cog Siv ESP32 Yam thiab Blynk: 5 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
Cog Saib Xyuas Siv ESP32 Yam thiab Blynk
Cog Saib Xyuas Siv ESP32 Yam thiab Blynk
Cog Saib Xyuas Siv ESP32 Yam thiab Blynk
Cog Saib Xyuas Siv ESP32 Yam thiab Blynk

Txheej txheem cej luam

Lub hom phiaj ntawm txoj haujlwm no yog txhawm rau tsim cov cuab yeej siv tau uas tuaj yeem saib xyuas qhov xwm txheej ntawm kev cog ntoo hauv tsev. Cov cuab yeej ua rau tus neeg siv tshuaj xyuas qib av noo, qib av noo, ntsuas kub, thiab "zoo li" kub los ntawm lub xov tooj smartphone siv Blynk App. Ib qho ntxiv, tus neeg siv yuav tau txais email ceeb toom thaum cov xwm txheej tsis zoo rau tsob ntoo. Piv txwv li, tus neeg siv yuav tau txais kev ceeb toom rau ywg dej cov nroj tsuag thaum cov av noo noo qis dua qib uas tsim nyog.

Kauj ruam 1: Yuav tsum tau ua

Yuav tsum muaj
Yuav tsum muaj
Yuav tsum muaj
Yuav tsum muaj
Yuav tsum muaj
Yuav tsum muaj

Txoj haujlwm no siv Sparkfun ESP32 yam, DHT22 lub ntsuas hluav taws xob, thiab Hluav Taws Xob Hluav Taws Xob Av noo noo. Ib qho ntxiv, yuav tsum muaj wifi network thiab Blynk app. Ua ntej tshaj, lub thawv thaiv dej yuav tsum tsim kom muaj ESP32 yam. Thaum qhov piv txwv no siv tus qauv hluav taws xob rau lub zog siv hluav taws xob, ntxiv cov roj teeb uas them rov qab tau, lub hnub ci vaj huam sib luag, thiab tus tswj kev them nqi yuav ua rau lub cuab yeej siv tau los ntawm lub zog tauj dua tshiab.

Kauj ruam 2: Blynk

Blynk
Blynk
Blynk
Blynk
Blynk
Blynk

Txhawm rau ua, rub tawm Blynk app thiab tsim txoj haujlwm tshiab. Nco tseg ntawm daim ntawv pov thawj kev lees paub-nws yuav raug siv hauv cov cai. Tsim cov cuab yeej tshiab tso rau hauv Blynk app thiab xaiv cov pins virtual uas tau hais tseg hauv txoj cai. Teem caij ncua sijhawm tshiab kom thawb. Txhua lub widget yuav tsum tau muab nws tus kheej tus lej pin.

Kauj Ruam 3: Arduino IDE

Arduino IDE Cov
Arduino IDE Cov

Rub tawm Arduino IDE. Ua raws li cov lus qhia rub tawm rau ESP32 yam tsav tsheb thiab qhov ua piv txwv kom ntseeg tau kev sib txuas wifi. Rub tawm Blynk thiab DHT cov tsev qiv ntawv suav nrog hauv txoj cai. Sau daim ntawv pov thawj kev lees paub, tus password wifi, lub npe siv wifi, thiab email hauv tus lej kawg. Siv tus lej demo rau qhov ntsuas av noo kom pom qhov tsawg kawg thiab qhov siab tshaj plaws rau hom av. Sau thiab hloov cov txiaj ntsig no hauv tus lej kawg. Hloov qhov tseem ceeb yam tsawg kawg nkaus rau qhov kub thiab txias, av noo, thiab av noo rau tsob ntoo hauv kab lus kawg. Upload cov cai.

Kauj ruam 4: Tsim Nws

Tsim Nws
Tsim Nws
Tsim Nws
Tsim Nws
Tsim Nws
Tsim Nws

Ua ntej tshaj, txuas cov av noo sensor mus rau 3.3V, hauv av, thiab tus pin nkag 34. Nco tseg, nws yog ib qho tseem ceeb hloov pauv tau teeb tsa rau A vim tias kev teeb tsa analog rau lub ntsuas ntsuas no yuav raug siv. Tom ntej no, txuas DHT sensor rau 3.3V, hauv av, thiab tus pin nkag 27. DHT22 sensor xav tau 10K Ohm resistor ntawm VCC thiab cov ntaub ntawv tawm tus pin. Nco ntsoov xyuas daim duab DHT kom ntseeg tau tias nws tau siv kab kom raug. Kho ESP32 sab hauv lub thawv tsis muaj dej nrog lub ntsuas dej noo hauv cov av thiab DHT sensor siab dua saum npoo av. Txuas mus rau lub hwj chim thiab txaus siab rau cov ntaub ntawv ntawm koj cov chaw ib puag ncig.

Kauj ruam 5: Code

// Muaj cov tsev qiv ntawv

#define BLYNK_PRINT Serial

#include #include #include #include "DHT.h"

// DHT sensor cov ntaub ntawv

#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 #define DHTPIN 27 // Cov lej pin txuas nrog DHT sensor DHT dht (DHTPIN, DHTTYPE); // Pib DHT sensor.

// txhais cov pins input thiab outputs

int av_sensor = 34; // txhais analog input tus lej txuas nrog lub ntsuas dej noo

int output_value; // txhais raws li cov zis

int moisturelevel; // txhais raws li cov zis

int ceeb toom = 0; // txhais notifed li 0

int timedelay = 60000L; // teeb tsa lub sijhawm ua haujlwm kom tau txais cov ntaub ntawv ib zaug txhua feeb lossis 60, 000 miliseconds

// teeb tsa yam tsawg kawg nkaus rau tsob ntoo

int min_moisture = 20; int min_temperature = 75; int min_cov = 60;

// Koj yuav tsum tau txais Auth Token hauv Blynk App.

char auth = "Auth_Token_Here";

// Koj li ntawv pov thawj WiFi.

char ssid = "Wifi_Network_Here"; char pass = "Wifi_Password_Here";

BlynkTimer timer;

// Lub luag haujlwm no xa Arduino lub sijhawm txhua txhua ob rau Virtual Pin (5).

// Hauv app, Widget's nyeem zaus yuav tsum tau teeb tsa rau PUSH. Qhov no txhais tau tias // uas koj txheeb xyuas ntau npaum li cas xa cov ntaub ntawv mus rau Blynk App.

void Sensors () // lub luag haujlwm tseem ceeb los nyeem cov cim thiab thawb rau blynk

{output_value = analogRead (av_sensor); // Nyeem analog teeb liab los ntawm av_sensor thiab txhais raws li output_value // Daim ntawv qhia output_vlaue los ntawm min, max qhov tseem ceeb rau 100, 0 thiab txwv ntawm 0, 100 // Siv cov qauv coj mus kuaj thiab saib xyuas kom pom min thiab qhov tseem ceeb tshaj plaws rau tus kheej lub ntsej muag thiab hom av kom zoo dua ntsuas dej noo qib = txwv (daim ntawv qhia (cov txiaj ntsig tawm, 1000, 4095, 100, 0), 0, 100); ntab h = dht.readHumidity (); // Nyeem cov av noo t = dht.readTemperature (); // Nyeem kub li Celsius (lub neej ntawd) ntab f = dht.readTemperature (muaj tseeb); // Nyeem qhov ntsuas kub raws li Fahrenheit (isFahrenheit = true) // Suav qhov ntsuas cua sov hauv Fahrenheit (lub neej ntawd) ntab hif = dht.computeHeatIndex (f, h); // Txheeb xyuas yog tias ib qho twg nyeem tsis tau zoo thiab tawm ntxov (sim dua). yog (isnan (h) || isnan (t) || isnan (f)) {Serial.println (F ("Ua tsis tau tejyam nyeem los ntawm DHT sensor!")); rov qab; } // Qhov no txuas tus nqi mus rau tus lej pins uas tau hais tseg hauv cov cuab yeej hauv Blynk app Blynk.virtualWrite (V5, moisturelevel); // Xa qib dej noo mus rau tus lej virtual 5 Blynk.virtualWrite (V6, f); // Xa qhov kub mus rau virtual tus pin 6 Blynk.virtualWrite (V7, h); // Xa cov av noo mus rau tus lej virtual 7 Blynk.virtualWrite (V8, hif); // Xa cov ntsuas cua sov mus rau tus lej pin 8

yog (ceeb toom == 0)

{yog (moisturelevel <= min_moisture) // Yog tias cov av noo sib npaug los yog qis dua tus nqi {Blynk.email ("Email_Here", "Plant Monitor", "Water Plant!"); // Xa email rau cov dej cog} ncua (15000); // Blynk email yuav tsum yog 15 vib nas this sib nrug. Ncua 15000 millisecons yog tias (f <= min_temperature) // Yog tias qhov kub sib npaug los yog qis dua tus nqi {Blynk.email ("Email_Here", "Plant Monitor", "Temperature Low!"); // Xa email tias qhov ntsuas kub qis

}

ncua (15000); // Blynk email yuav tsum yog 15 vib nas this sib nrug. Ncua 15000 millisecons yog tias (h <= min_humidity) // Yog cov av noo sib npaug los yog qis dua tus nqi {Blynk.email ("Emial_Here", "Plant Monitor", "Humidity Low!"); // Xa email tias cov av noo tsawg} ceeb toom = 1; timer.setTimeout (timedelay *5, resetNotified); // multipy timedelay los ntawm tus lej xav tau ntawm rov ceeb toom email}}

void resetNotified () // muaj nuj nqi hu rau rov pib dua email zaus

{ceeb toom = 0; }

void teeb tsa ()

{Serial.begin (9600); // Debug console Blynk.begin (auth, ssid, dhau); // txuas rau blynk timer.setInterval (timedelay, Sensors); // Teeb tsa lub luag haujlwm kom raug hu ua txhua feeb lossis lub sijhawm twg yog teem rau dht.begin (); // khiav DHT sensor}

// Lub voj void yuav tsum tsuas yog muaj blynk.run thiab timer

lub voj void () {Blynk.run (); // Khiav blynk timer.run (); // Pib BlynkTimer}

Pom zoo: