Cov txheej txheem:

Yuav Ua Li Cas Siv DHT11 Kub Sensor Nrog Arduino thiab Luam Kub Kub thiab Vaum: 5 Kauj Ruam
Yuav Ua Li Cas Siv DHT11 Kub Sensor Nrog Arduino thiab Luam Kub Kub thiab Vaum: 5 Kauj Ruam

Video: Yuav Ua Li Cas Siv DHT11 Kub Sensor Nrog Arduino thiab Luam Kub Kub thiab Vaum: 5 Kauj Ruam

Video: Yuav Ua Li Cas Siv DHT11 Kub Sensor Nrog Arduino thiab Luam Kub Kub thiab Vaum: 5 Kauj Ruam
Video: Tsis Paub Yuav Ua Li Cas 2024, Hlis ntuj nqeg
Anonim
Yuav Ua Li Cas Siv DHT11 Kub Sensor Nrog Arduino thiab Luam Kub Kub thiab Vaum
Yuav Ua Li Cas Siv DHT11 Kub Sensor Nrog Arduino thiab Luam Kub Kub thiab Vaum

DHT11 sensor siv los ntsuas qhov kub thiab txias. Lawv yog cov khoom siv hluav taws xob nrov tshaj plaws. Qhov DHT11 cov av noo thiab ntsuas kub ua rau nws yooj yim ntxiv cov av noo thiab ntsuas kub rau koj li DIY cov phiaj xwm hluav taws xob. Nws yog qhov zoo tshaj plaws rau cov chaw nyob huab cua nyob deb, kev tswj hwm ib puag ncig hauv tsev, thiab kev ua liaj ua teb lossis saib xyuas vaj tsev. Yog li hauv qhov kev qhia no peb yuav pom yuav siv DHT11 Cov ntsuas kub li cas nrog Arduino thiab luam tawm qhov ntsuas cua sov & cua sov ntawm qhov ntsuas ntawm arduino ide.

Kauj Ruam 1: Yam Koj Xav Tau

Yam Koj Xav Tau
Yam Koj Xav Tau
Yam Koj Xav Tau
Yam Koj Xav Tau

Yog li rau txoj haujlwm no koj xav tau cov khoom hauv qab no: 1x Arduino uno:

1x DHT11 Kub sensor: https://www.utsource.net/itm/p/9221601.htmlBreadboard & ob peb dhia

Kauj ruam 2: Kev sib txuas

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

Thov txuas txhua yam Raws li tau qhia hauv cov duab muab thiab ua mus rau kauj ruam tom ntej.

Kauj Ruam 3: Nruab Arduino Library

Nruab Arduino Library
Nruab Arduino Library
Nruab Arduino Library
Nruab Arduino Library

mus rau koj Arduino IDE tom qab ntawd mus rau Sketch> suav nrog Tsev Qiv Ntawv> Tswj Tsev Qiv. Tom qab txhim kho cov tsev qiv ntawv DHT no, ntaus "Adafruit Unified Sensor" hauv lub npov tshawb nrhiav thiab nqes mus. lub tsev qiv ntawv thiab teeb tsa nws thiab koj npaj txhij rau code.

Kauj Ruam 4: Tshaj Tawm Txoj Cai rau Arduino Lub Tswv Yim

Tom qab txhua yam ua tiav saum toj no tsuas yog theej cov cai hauv qab no & rub nws mus rau koj Arduino uno: #include "DHT.h" #define DHTPIN 7 // dab tsi tus pin peb txuas nrog rau // Tsis hais yam twg koj tab tom siv! txhais DHTTYPE DHT11 // DHT 11 //#txhais DHTTYPE DHT22 // DHT 22 (AM2302) //#txhais DHTTYPE DHT21 // DHT 21 (AM2301) // Pib DHT sensor rau qhov qub 16mhz ArduinoDHT dht (DHTPIN, DHTTYPE); teeb tsa () {Serial.begin (9600); Serial.println ("DHTxx xeem!"); dht.begin ();} void loop () {// Tos ob peb feeb ntawm kev ntsuas. ncua (2000); // Nyeem qhov ntsuas kub lossis av noo siv li 250 milliseconds! // Sensor nyeem ntawv kuj tseem tuaj yeem ntev txog 2 vib nas this 'qub' (nws lub sensor qeeb heev) ntab h = dht.readHumidity (); // Nyeem kub li Celsius ntab t = dht.readTemperature (); // Nyeem kub li Fahrenheit ntab f = dht.readTemperature (tseeb); // 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 ("Ua tsis tau tejyam nyeem los ntawm DHT sensor!"); rov qab; } // Txheeb xyuas qhov ntsuas cua sov // Yuav tsum xa cov ntsuas hauv Fahrenheit! ntab hi = dht.computeHeatIndex (f, h); Serial.print ("Vaum:"); Serial.print (h); Serial.print (" %\ t"); Serial.print ("Kub:"); Serial.print (t); Serial.print (" *C"); Serial.print (f); Serial.print (" *F / t"); Serial.print ("Cov ntsuas cua sov:"); Serial.print (nyob zoo); Serial.println (" *F");}

Kauj Ruam 5: Tau Txais Qhov Kub & Vaum Hauv Serial Monitor

Tau Txais Qhov Kub & Vaum Hauv Serial Monitor
Tau Txais Qhov Kub & Vaum Hauv Serial Monitor

Tom qab xa cov cai qhib qhov ntsuas tam sim no hauv arduino lub tswv yim thiab koj tuaj yeem pom qhov ntsuas kub, av noo & ntsuas cua sov ntawm koj ib puag ncig (uas koj lub ntsuas tam sim no tam sim no nyob hauv) ntawm koj lub xov tooj saib raws li kuv thiab koj tuaj yeem ua qhov no me ntsis ntxiv ib yam koj tuaj yeem siv cov ntsuas kub/av noo no hauv koj cov phiaj xwm xws li chaw nres tsheb huab cua, saib ib puag ncig thiab lwm yam.

Pom zoo: