Cov txheej txheem:
- Kauj Ruam 1: Yuav Ua Li Cas I2c Ua Haujlwm
- Kauj ruam 2: Tsev qiv ntawv
- Kauj Ruam 3: Tus cwj pwm
- Kauj Ruam 4: Kev siv I2c
- Kauj Ruam 5: Ib Txoj Kev Siv Hlau
- Kauj Ruam 6: Nyeem Tsis Txaus
- Kauj Ruam 7: Nyeem Yooj Yim
- Kauj ruam 8: Nyeem tag nrho
- Kauj Ruam 9: Daim Duab Sib Txuas
- Kauj ruam 10: Arduino: OneWire
- Kauj Ruam 11: Arduino: I2c
- Kauj ruam 12: Esp8266 (D1Mini) OneWire
- Kauj Ruam 13: Esp8266 (D1Mini) I2c
- Kauj ruam 14: Ua tsaug
Video: DHT12 (i2c Pheej Yig Humidity thiab Kub Sensor), Kev Siv Yooj Yim Yooj Yim: 14 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Koj tuaj yeem pom qhov hloov tshiab thiab lwm yam ntawm kuv qhov chaw
Kuv nyiam sensor uas tuaj yeem siv nrog 2 xaim (i2c raws tu qauv), tab sis kuv nyiam qhov pheej yig.
Nov yog Arduino thiab esp8266 lub tsev qiv ntawv rau DHT12 series ntawm tus nqi qis heev ntsuas kub/av noo (tsawg dua 1 $) uas ua haujlwm nrog i2c lossis ib txoj hlua txuas.
Siv tau zoo heev yog tias koj xav siv esp01 (yog tias koj siv cov lej koj tsuas muaj 2 tus lej) los nyeem cov av noo thiab qhov kub thiab tso tawm ntawm i2c LCD.
AI nyeem tias qee zaum zoo li xav tau kev ntsuas, tab sis kuv muaj tsob ntoo ntawm qhov no thiab tau txais tus nqi zoo ib yam li DHT22. Yog tias koj tau ntsuas qhov teeb meem no, qhib qhov teeb meem ntawm github thiab kuv ntxiv kev siv.
Kauj Ruam 1: Yuav Ua Li Cas I2c Ua Haujlwm
I2C ua haujlwm nrog nws ob lub xov hlau, SDA (kab ntawv cov ntaub ntawv) thiab SCL (kab kab ntawv).
Ob txoj kab no tau qhib-ntws, tab sis raug rub nrog cov neeg tawm tsam.
Feem ntau muaj ib tus tswv thiab ib lossis ntau tus qhev ntawm kab, txawm hais tias tuaj yeem muaj ntau tus tswv, tab sis peb yuav tham txog qhov ntawd tom qab.
Ob tus tswv thiab qhev tuaj yeem xa lossis txais cov ntaub ntawv, yog li ntawd, cov cuab yeej tuaj yeem nyob hauv ib ntawm plaub lub xeev no: tus tswv xa, tus tswv tau txais, tus xa tus qhev, tus qhev tau txais.
Kauj ruam 2: Tsev qiv ntawv
Koj tuaj yeem nrhiav kuv lub tsev qiv ntawv ntawm no.
Txhawm rau rub tawm
Nyem rau DOWNLOADS khawm nyob rau hauv kaum sab xis saum toj, hloov lub npe uas tsis tau nyem DHT12.
Txheeb xyuas tias DHT nplaub tshev muaj DHT12.cpp thiab DHT12.h.
Muab DHT lub tsev qiv ntawv tais ceev tseg koj / tsev qiv ntawv / ntawv tais ceev tseg.
Koj yuav xav tsim lub tsev qiv ntawv subfolder yog nws yog koj thawj lub tsev qiv ntawv.
Rov pib dua IDE.
Kauj Ruam 3: Tus cwj pwm
Qhov kev tsis ncaj ncees no sim ua raws tus cwj pwm ntawm tus qauv DHT lub tsev qiv ntawv ntsuas (thiab luam ntau tus lej), thiab kuv ntxiv cov cai los tswj i2c olso tib yam.
Txoj hauv kev yog tib yam ntawm DHT lub tsev qiv ntawv sensor, nrog qee qhov ntxiv xws li lwg taw tes ua haujlwm.
Kauj Ruam 4: Kev siv I2c
Txhawm rau siv nrog i2c (chaw nyob thiab lub hauv paus SDA SCL tus pin) tus tsim yog:
DHT12 dht12;
thiab coj tus nqi pib rau SDA SCL tus pin.
(Nws tuaj yeem rov txhais dua nrog cov kws qhia tshwj xeeb rau esp8266, xav tau rau ESP-01). los yog
DHT12 dht12 (uint8_t addressOrPin)
addressOrPin -> chaw nyob
hloov chaw nyob.
Kauj Ruam 5: Ib Txoj Kev Siv Hlau
Txhawm rau siv ib lub xaim:
DHT12 dht12 (uint8_t addressOrPin, muaj tseeb)
addressOrPin -> pin
tus nqi boolean yog xaiv ntawm oneWire lossis i2c hom.
Kauj Ruam 6: Nyeem Tsis Txaus
Koj tuaj yeem siv Nws nrog "cuam tshuam", "nyeem yooj yim" lossis "puv": Tsis raug cai, tsuas yog thawj zaug nyeem ua qhov tseeb nyeem ntawm lub ntsuas, lwm qhov nyeem uas dhau los ua 2secs. luv yog cov nqi khaws cia ntawm thawj zaug nyeem.
// Kev nyeem ntawv ntawm lub sensor muaj 2secs ntawm lub sijhawm dhau los, tshwj tsis yog tias koj dhau qhov ntsuas qhov ntsuas
// Nyeem kub li Celsius (lub neej ntawd) ntab t12 = dht12.readTemperature (); // Nyeem kub li Fahrenheit (isFahrenheit = true) ntab f12 = dht12.readTemperature (tseeb); // Sensor nyeem ntawv kuj tseem tuaj yeem ntev txog 2 vib nas this 'qub' (nws lub sensor qeeb heev) ntab h12 = dht12.readHumidity (); // Xam qhov ntsuas cua sov hauv Fahrenheit (lub neej ntawd) ntab hif12 = dht12.computeHeatIndex (f12, h12); // Suav ntsuas qhov ntsuas cua sov hauv Celsius (isFahreheit = cuav) ntab hic12 = dht12.computeHeatIndex (t12, h12, cuav); // laij tus taw tes hauv Fahrenheit (lub neej ntawd) ntab dpf12 = dht12.dewPoint (f12, h12); // laij cov lwg taw tes hauv Celsius (isFahreheit = cuav) ntab dpc12 = dht12.dewPoint (t12, h12, cuav);
Kauj Ruam 7: Nyeem Yooj Yim
Nyeem yooj yim kom tau txais cov xwm txheej ntawm kev nyeem.
// Kev nyeem ntawv ntawm lub sensor muaj 2secs ntawm lub sijhawm dhau los, tshwj tsis yog tias koj dhau qhov yuam kev ntsuas
bool chk = dht12.read (); // nyeem tseeb yog ok, teeb meem nyeem tsis raug
// Nyeem kub li Celsius (lub neej ntawd)
ntab t12 = dht12.readTemperature (); // Nyeem kub li Fahrenheit (isFahrenheit = true) ntab f12 = dht12.readTemperature (tseeb); // Sensor nyeem ntawv kuj tseem tuaj yeem ntev txog 2 vib nas this 'qub' (nws lub sensor qeeb heev) ntab h12 = dht12.readHumidity (); // Xam qhov ntsuas cua sov hauv Fahrenheit (lub neej ntawd) ntab hif12 = dht12.computeHeatIndex (f12, h12); // Suav ntsuas qhov ntsuas cua sov hauv Celsius (isFahreheit = cuav) ntab hic12 = dht12.computeHeatIndex (t12, h12, cuav); // laij tus taw tes hauv Fahrenheit (lub neej ntawd) ntab dpf12 = dht12.dewPoint (f12, h12); // laij cov lwg taw tes hauv Celsius (isFahreheit = cuav) ntab dpc12 = dht12.dewPoint (t12, h12, cuav);
Kauj ruam 8: Nyeem tag nrho
Nyeem tag nrho kom tau txais cov xwm txheej tshwj xeeb.
// Kev nyeem ntawv ntawm lub sensor muaj 2secs ntawm lub sijhawm dhau los, tshwj tsis yog tias koj dhau qhov ntsuas qhov ntsuas
DHT12:: ReadStatus chk = dht12.readStatus (); Serial.print (F ("\ nRead sensor:")); hloov (chk) {rooj plaub DHT12:: OK: Serial.println (F ("OK")); tawg; rooj plaub DHT12:: ERROR_CHECKSUM: Serial.println (F ("Checksum yuam kev")); tawg; rooj plaub DHT12:: ERROR_TIMEOUT: Serial.println (F ("yuam kev tas sij hawm")); tawg; rooj plaub DHT12:: ERROR_TIMEOUT_LOW: Serial.println (F ("Sijhawm yuam kev ntawm lub teeb liab qis, sim muab siab rub tawm tsis kam")); tawg; rooj plaub DHT12:: ERROR_TIMEOUT_HIGH: Serial.println (F ("Sijhawm yuam kev ntawm lub teeb liab qis, sim muab qis rub tawm tsis kam")); tawg; rooj plaub DHT12:: ERROR_CONNECT: Serial.println (F ("Txuas yuam kev")); tawg; rooj plaub DHT12:: ERROR_ACK_L: Serial.println (F ("AckL yuam kev")); tawg; rooj plaub DHT12:: ERROR_ACK_H: Serial.println (F ("AckH yuam kev")); tawg; rooj plaub DHT12:: ERROR_UNKNOWN: Serial.println (F ("Tsis paub yuam kev DETECTED")); tawg; rooj plaub DHT12:: TSIS MUAJ: Serial.println (F ("Tsis muaj qhov tshwm sim")); tawg; default: Serial.println (F ("Tsis paub yuam kev")); tawg; }
// Nyeem kub li Celsius (lub neej ntawd)
ntab t12 = dht12.readTemperature (); // Nyeem kub li Fahrenheit (isFahrenheit = true) ntab f12 = dht12.readTemperature (tseeb); // Sensor nyeem ntawv kuj tseem tuaj yeem ntev txog 2 vib nas this 'qub' (nws lub sensor qeeb heev) ntab h12 = dht12.readHumidity (); // Xam qhov ntsuas cua sov hauv Fahrenheit (lub neej ntawd) ntab hif12 = dht12.computeHeatIndex (f12, h12); // Suav ntsuas qhov ntsuas cua sov hauv Celsius (isFahreheit = cuav) ntab hic12 = dht12.computeHeatIndex (t12, h12, cuav); // laij tus taw tes hauv Fahrenheit (lub neej ntawd) ntab dpf12 = dht12.dewPoint (f12, h12); // laij tus lej taw tes hauv Celsius (isFahreheit = cuav) ntab dpc12 = dht12.dewPoint (t12, h12, cuav);
Kauj Ruam 9: Daim Duab Sib Txuas
Nrog cov piv txwv, muaj daim duab txuas, nws yog ib qho tseem ceeb kom siv qhov rub tawm kom raug.
Ua tsaug rau Bobadas, dplasa thiab adafruit, los qhia cov cai hauv github (qhov twg kuv coj qee cov cai thiab cov tswv yim).
Kauj ruam 10: Arduino: OneWire
Kauj Ruam 11: Arduino: I2c
Kauj ruam 12: Esp8266 (D1Mini) OneWire
Kauj Ruam 13: Esp8266 (D1Mini) I2c
Kauj ruam 14: Ua tsaug
Chaw ua si Arduino (https://playground.arduino.cc/Main/DHT12SensorLibrary)
i2c project series (Sau):
- Kub ntsuas qhov ntsuas kub
- Analog nthuav dav
- Cov nthuav dav
- Zaub Zaub
Pom zoo:
Pheej Yig Qhov Chaw Nkag Nkag Pheej Yig Pheej Yig: 6 Kauj Ruam (nrog Duab)
Pheej Yig Qhov Chaw Nkaum Nkag Pheej Yig: CreditI zoo nkauj heev theej Savjee qhov kev siv tab sis tsis txhob siv Shelly Kuv siv Sonoff Basic. Txheeb xyuas nws lub vev xaib thiab YouTube Channel
D.I.Y YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM LOS NTAWM SCRAPS: 4 Cov Kauj Ruam (nrog Duab)
D.I.Y YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM LOS NTAWM SCRAPS: Hnub no kuv xav qhia yuav ua li cas kom pom lub teeb pom kev zoo los ntawm lub zog xa hluav taws xob tsis siv hluav taws xob los ntawm tus txhuam txhuam hniav thiab lub tshuab solenoid valve coils uas tau khaws los ntawm scrapyard.Ua ntej pib, thov saib cov vis dis aus hauv qab no:
Cov Khoom Siv Hluav Taws Xob Hloov Kho Siv Cov Pheej Yig EBay Pheej Yig: 8 Kauj Ruam
Kev Hloov Kho Lub Hwj Huam Siv Pheej Yig EBay Qhov Chaw: Hauv phau ntawv qhia no peb tab tom tsim kho lub zog hloov kho kom pheej yig los pab peb ua haujlwm rau peb cov phiaj xwm arduino, qhov ntau tshaj ntawm cov khoom siv hluav taws xob raws li cov tuam txhab tsim khoom uas peb siv yuav tsum nyob ib puag ncig 60W. Tus nqi ntawm qhov haujlwm yuav tsum yog
YUAV UA LI CAS YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM TSHAJ PLAWS YOOJ YIM: 4 Cov Kauj Ruam
YUAV UA LI CAS YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM TSHAJ PLAWS: Nyob zoo txhua tus hauv cov lus qhia no kuv yuav qhia koj yuav ua li cas kom yooj yim " SOIL DRYNESS SENSOR ". Qhuav ntawm cov av tau txheeb xyuas siv qhov taw qhia coj. Lub teeb ci wi
Ib qho yooj yim heev/yooj yim/Tsis yooj yim txoj hauv kev kom tib neeg/tib neeg/tsiaj/neeg hlau zoo li lawv muaj txias tiag tiag/Lub zeem muag tshav kub kub (Xim ntawm Koj Xaiv) Siv GIMP: 4 Cov Kauj Ruam
Ib qho yooj yim heev/yooj yim/Tsis yooj yim txoj hauv kev kom tib neeg/tib neeg/tsiaj/neeg hlau zoo li lawv muaj txias tiag tiag/Lub zeem muag tshav kub kub (Xim ntawm Koj Xaiv) Siv GIMP: Nyeem … lub npe