Cov txheej txheem:

Qhov Rooj thiab Qhov Kub Kub Logger Project: 21 Kauj Ruam
Qhov Rooj thiab Qhov Kub Kub Logger Project: 21 Kauj Ruam

Video: Qhov Rooj thiab Qhov Kub Kub Logger Project: 21 Kauj Ruam

Video: Qhov Rooj thiab Qhov Kub Kub Logger Project: 21 Kauj Ruam
Video: Hmong Medical Association Covid-19 Series: Management of Stress and Anxiety 2024, Hlis ntuj nqeg
Anonim
Qhov Rooj thiab Qhov Kub Kub Logger Project
Qhov Rooj thiab Qhov Kub Kub Logger Project

Cov lus qhia no yuav qhia koj yuav ua li cas thiaj ua tau lub qhov rooj yooj yim thiab qhov ntsuas kub nyob hauv qis dua $ 10.00 siv ESP8266 NodeMCU, DHT11 qhov ntsuas kub thiab av noo, lub qhov rooj/qhov rai rov qhib, 10K ohm resistor thiab qee qhov txuas hlau.

Lub hauv paus ntawm txoj haujlwm no los ntawm kuv lub siab xav ua ntau lub tsev siv tshuab nrog Arduino pawg thawj coj, Txij li thaum kuv tau nyeem ntau txog Arduino sib xws EPS8266 NodeMCU, Kuv txiav txim siab lub rooj tsavxwm no yuav yog lub rooj tsavxwm tus nqi qis tshaj plaws los ua qee qhov kev sim nrog. Tom qab tshawb hauv Is Taws Nem rau kev ua haujlwm hauv tsev siv lub ESP8266 cov laug cam, Kuv tau txiav txim siab ua ke qhov ntsuas kub thiab lub qhov rooj logger rau kuv thawj zaug. Thaum kawg txoj haujlwm no yuav ua ke nrog kev pabcuam, ntsuas lub ntsuas dej thiab lwm yam khoom siv hluav taws xob kom siv lub tsev ntsuab me me uas kuv yawg tsim thiab tsim 50 xyoo dhau los. Qhov ntsuas kub yuav siv los txiav txim siab yog tias lub tshuab cua sov yuav tsum tau koom nrog lossis tshem tawm nrog rau teeb liab lub servos kom qhib thiab kaw lub qhov cua thaum xav tau. Lub xeev ntawm lub tshuab tso pa tawm yuav raug saib xyuas los ntawm kev siv lub tshuab hluav taws xob sib nqus reed. Thaum kawg, lub ntsuas dej noo yuav siv los siv lub tshuab ua dej.

Kauj ruam 1: Tsis lees paub

Tsuas yog kev lees paub sai rau lub xeev tias peb tsis muaj lub luag haujlwm rau txhua yam uas tshwm sim los ntawm kev ua raws cov lus qhia no. Nws yog qhov zoo tshaj plaws ua raws cov lus qhia ntawm cov tuam ntxhab thiab cov ntawv pov thawj kev nyab xeeb thaum tsim ib yam dab tsi yog li thov tham nrog cov ntaub ntawv rau ib qho ntawm cov khoom thiab cov cuab yeej uas koj siv los tsim koj tus kheej. Peb tsuas yog muab cov ntaub ntawv ntawm cov kauj ruam uas peb siv los tsim peb li. Peb tsis yog kws tshaj lij. Raws li qhov tseeb, 2 ntawm 3 ntawm cov tib neeg uas koom nrog hauv qhov kev tsim no yog menyuam yaus.

Kauj Ruam 2: Teeb Tus lej IFTTT Dawb

Teeb Dawb IFTTT Account
Teeb Dawb IFTTT Account

Yog tias koj tsis muaj ib qho, tam sim no yog lub sijhawm los teeb tsa IFTTT tus as khauj dawb los ntawm kev mus rau lawv lub vev xaib.. IFTTT sawv rau Yog Yog Li No Thiab Qhov ntawd yog lub platform pub dawb uas tso cai rau koj txuas internet kev pabcuam raws li txoj hauv kev tshiab pab koj kom siv cov kev pabcuam no hauv txoj hauv kev tshiab. Txog qhov haujlwm no peb yuav siv IFTTT tso cai rau ESP8266 txhawm rau nkag mus rau qhov xwm txheej ntawm lub qhov rooj ntawm tus ntoo thuv hloov pauv thiab ntsuas kub thiab av noo ntawm DHT11 sensor hauv Google daim ntawv.

Kauj Ruam 3: Tsim IFTTT Applet

Tsim IFTTT Applet
Tsim IFTTT Applet

Thaum tseem nyob hauv IFTTT, txuas mus rau ntu "Kuv Applets" thiab tsim ib qho tshiab applet los ntawm txhaj "New Applet" khawm.

Kauj Ruam 4: Kho qhov "ntu" ntawm Koj Applet

Configure tus
Configure tus

Nyem rau ntawm lo lus "no" uas yog xim xiav - raws li tau hais tseg hauv daim duab saum toj no.

Kauj Ruam 5: Ntxiv WebHooks Service rau Koj Applet

Ntxiv WebHooks Service rau Koj Applet
Ntxiv WebHooks Service rau Koj Applet

Hauv kab tshawb nrhiav, tshawb rau "Webhooks" kev pabcuam thiab xaiv Webhooks lub cim.

Thaum koj pom qhov kev pabcuam "Webhooks", nyem rau nws.

Kauj Ruam 6: Teeb Lub Txais Tau Txais Kev Thov Lub Vev Xaib

Teeb tsa Qhov Tau Txais Lub Vev Xaib Thov Ua
Teeb tsa Qhov Tau Txais Lub Vev Xaib Thov Ua

Xaiv qhov "Tau txais lub vev xaib thov" txhais.

Kauj Ruam 7: Muab Lub Npe Lub Npe

Muab Lub Npe Lub Npe
Muab Lub Npe Lub Npe

Hauv kab ntawv sau muab koj lub applet tshiab nrog lub npe tshwm sim. Kuv xaiv "Data Logger" tab sis koj tuaj yeem xaiv yam koj nyiam.

Kauj Ruam 8: Kho qhov "ntawd" Feem ntawm Koj Applet

Configure tus
Configure tus

Nyem rau ntawm lo lus "ntawd" uas yog xim xiav - raws li tau hais tseg hauv daim duab saum toj no.

Kauj Ruam 9: Teeb Kev Pabcuam Ua Haujlwm

Teeb Kev Pabcuam Ua Haujlwm
Teeb Kev Pabcuam Ua Haujlwm

Hauv kab ntawv tshawb nrhiav, tshawb rau "Google Sheets" kev pabcuam, thiab nyem rau ntawm Google Sheets icon.

Kauj ruam 10: Txuas rau Google Ntawv

Txuas rau Google Ntawv
Txuas rau Google Ntawv

Yog tias koj tseem tsis tau ua li ntawd, koj yuav tsum txuas koj li IFTTT tus account rau Google Sheets. Nias lub khawm Txuas uas tau hais los saum no thiab ua raws cov lus qhia ntawm lub vijtsam.

Kauj Ruam 11: Xaiv Qhov Kev Ua

Xaiv Kev Ua
Xaiv Kev Ua

Nyem rau ntawm "Ntxiv kab rau daim ntawv".

Kauj Ruam 12: Teeb Kev Ua

Teeb qhov Kev Ua
Teeb qhov Kev Ua

Muab lub npe nyob rau hauv kab ntawv "Spreadsheet name". Kuv xaiv siv "Data_Logger" kom sib xws. Tawm ntawm qhov chaw teeb tsa ib leeg (koj tuaj yeem sim nrog cov teeb tsa ntawm qee lub sijhawm) thiab tom qab ntawd nias lub pob "Tsim Ua" nyob hauv qab ntawm qhov screen.

Kauj Ruam 13: Txheeb xyuas thiab Ua tiav Koj Daim Ntawv Thov

Txheeb xyuas thiab ua tiav koj li Applet
Txheeb xyuas thiab ua tiav koj li Applet

Thaum txaus siab rau koj li kev teeb tsa applet nias lub pob "Ua tiav".

Kauj Ruam 14: Rov Qab Kho Cov Ntaub Ntawv Xav Tau Tom Qab

Rov qab kho cov ntaub ntawv xav tau tom qab
Rov qab kho cov ntaub ntawv xav tau tom qab

Nyem rau ntawm "Webhooks" raws li tau hais los saud.

Kauj Ruam 15: Txuas mus rau Webhooks Cov Ntaub Ntawv rau API Key

Txuas mus rau Webhooks Cov Ntaub Ntawv rau API Key
Txuas mus rau Webhooks Cov Ntaub Ntawv rau API Key

Nws yuav zoo li coj txawv txawv tab sis nyem rau ntawm Cov Ntaub Ntawv txuas hauv sab saud sab xis mus rau nplooj ntawv nrog koj tus lej tshwj xeeb API.

Kauj Ruam 16: Txuag API Qhov Ntsuas

Txuag tus API Key
Txuag tus API Key
Txuag tus API Key
Txuag tus API Key

Thawj kab ntawm Cov Ntawv Ntsuam Xyuas screen qhia koj qhov tshwj xeeb API Key. Luam thiab Tseg tus yuam sij no rau siv tom qab.

Nws kuj yog lub tswv yim zoo los sim cov applet ntawm no. Nco ntsoov hloov qhov {xwm txheej} mus rau Data_Logger lossis ib yam dab tsi uas koj teev npe rau koj qhov xwm txheej thiab ntxiv qee cov ntaub ntawv rau 3 qhov tsis muaj nuj nqis ces nyem qhov "Test It" khawm nyob hauv qab ntawm nplooj ntawv. Koj yuav tsum pom cov lus ntsuab hais tias "Kev tshwm sim tau tshwm sim". Yog tias yog, txuas mus rau Google Docs thiab lees paub tias cov ntaub ntawv koj tau nkag rau hauv nplooj ntawv xeem tau tshwm nyob rau hauv Google Cov Ntawv Ntawv.

Kauj Ruam 17: Sib sau ua ke

Sau cov Cheebtsam
Sau cov Cheebtsam
Sib sau ua ke
Sib sau ua ke
Sau cov Cheebtsam
Sau cov Cheebtsam

Koj tsuas xav tau ob peb ntu.

1) ESP8266 NodeMcu Pawg Neeg Saib Xyuas Kev Txhim Kho

2) DHT11 Kub/Vaum Sensor

3) Qhov Rooj/Qhov Rooj Reed Hloov

4) 10k Ohm Resistor

5) Hookup Hlau

Kauj Ruam 18: Sib sau ua ke

1) Txuas ib qho ntawm 3v3 tus pin ntawm ESP8266 rau vcc tus pin ntawm DHT11.

2) Txuas ib qho ntawm tus pin hauv av ntawm ESP8266 rau tus pin hauv av ntawm DHT11.

3) Txuas tus pin D4 (aka pin 2 hauv IDE) ntawm ESP8266 rau tus pin tus lej ntawm DHT11.

4) Txuas lwm tus 3v3 tus pin ntawm ESP8266 mus rau ib sab ntawm lub qhov rooj/lub qhov rooj rov qhib qhov rooj.

5) Txuas tus pin D5 (aka tus pin 14 hauv IDE) ntawm ESP8266 mus rau lwm sab ntawm lub qhov rooj/qhov rai reed hloov thiab tseem txuas nws mus rau ib sab ntawm 10k ohm resistor.

6) Txuas lwm sab ntawm 10k ohm resistor rau lwm tus pin hauv av ntawm ESP8266.

Rau ESP8266 tus pin xaiv thov xa mus rau daim duab no muaj txiaj ntsig lossis cov vis dis aus muaj txiaj ntsig zoo.

Kauj Ruam 19: Sau Arduino Code

Sau Arduino Code
Sau Arduino Code

Luam thiab muab cov cai hauv qab no tso rau hauv koj li Arduino IDE.

#include #include #include "DHT.h"

#define DHTPIN 2 // dab tsi tus lej digital peb txuas nrog

#define DOORPIN 14 // dab tsi digital pin lub qhov rooj hloov mus.

#define DHTTYPE DHT11 // DHT 11

DHT dht (DHTPIN, DHTTYPE);

int suav = 1;

const char* ssid = "some_ssid"; // hloov qhov no los siv koj li ssid const char* password = "some_password"; // hloov qhov no los siv koj tus password int sleepTime = 100;

// Tus Tsim Webhooks IFTTT

const char* server = "txiag.ifttt.com";

// IFTTT URL cov peev txheej

const char* peev txheej = "/txhais/SOME_SERVICE_NAME/nrog/qhov tseem ceeb/SOME_API_KEY"; // Nco ntsoov siv koj lub npe kev pabcuam thiab koj tus lej api.

Txoj hlua qhov rooj = "Kaw";

volatile bool stateChanged = tsis tseeb;

// Yog tias pw tau ntau teev ces teev sijhawm los ntawm hr * 60 feeb * 60 vib nas this * 1000 milliseconds

const ncua sijhawm = 1.0 * 60 * 60 * 1000; // 1 teev tsis tau kos npe ntev dhau losMillis = 0 - (2 * ntu);

void teeb tsa () {

Serial.begin (115200); attachInterrupt (digitalPinToInterrupt (DOORPIN), eventTriggered, CHANGE); pinMode (DOORPIN, INPUT); // Qhov Rooj Sensor dht.begin (); WiFi.begin (ssid, password);

Serial.print ("\ n Kev sib txuas..");

thaum (WiFi.status ()! = WL_CONNECTED) {ncua (1000); Serial.print ("."); } Serial.print ("\ n"); }

void eventTriggered () {

stateChanged = muaj tseeb; Serial.println ("Txheeb xyuas lub qhov rooj!"); yog (digitalRead (DOORPIN) == HIGH) // Txheeb xyuas seb lub qhov rooj puas qhib {Serial.println ("Qhov rooj kaw lawm!"); doorStatus = "Kaw"; } lwm {Serial.println ("Qhov rooj qhib!"); doorStatus = "Qhib"; }}

void checkStatus () {

yog (WiFi.status () == WL_CONNECTED) {// Txheeb xyuas WiFi li xwm txheej txuas // Nyeem qhov ntsuas kub lossis av noo yuav 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 (lub neej ntawd) ntab t = dht.readTemperature (); // Nyeem kub li Fahrenheit (isFahrenheit = true) 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!"); //Serial.print ("."); // Ua tsis tau zoo nyeem los ntawm DHT sensor! rov qab; } // Suav ntsuas qhov ntsuas cua sov hauv Fahrenheit (lub neej ntawd) ntab hif = dht.computeHeatIndex (f, h); // Xam qhov ntsuas cua sov hauv Celsius (isFahreheit = cuav) ntab hic = dht.computeHeatIndex (t, h, cuav);

Serial.print ("\ n");

Serial.print ("Kub:"); Serial.print (f); Serial.print (" *F ("); Serial.print (t); Serial.print (" *C)"); Serial.print ("\ t"); Serial.print ("Cov ntsuas cua sov:"); Serial.print (hif); Serial.print (" *F ("); Serial.print (hic); Serial.print (" *C)%"); Serial.print ("\ t"); Serial.print ("Vaum:"); Serial.println (h);

yog (digitalRead (DOORPIN) == HIGH) // Txheeb xyuas seb lub qhov rooj qhib

{Serial.println ("Qhov rooj raug kaw!"); doorStatus = "Kaw"; } lwm {Serial.println ("Qhov rooj qhib!"); doorStatus = "Qhib"; } String jsonObject = String ("{" value1 / ": \" ") + f +"*F (" + t +"*C) / " + hif +"*F (" + hic +"*C) " +" / ", \" value2 / ": \" " + h +" / ", \" value3 / ": \" " + doorStatus +" / "}"; HTTPClient http; Txoj hlua completeUrl = "https://maker.ifttt.com/trigger/bme280_readings/with/key/cZFasEvy5_3JlrUSVAxQK9"; http.begin (ua tiavUrl); // http.begin (neeg rau zaub mov); http.addHeader ("Hom-Hom", "application/json"); http. POST (jsonObject); http.writeToStream (& Serial); http.end (); // Kaw kev sib txuas

stateChanged = tsis tseeb;

int sleepTimeInMinutes = ncua sijhawm / 1000/60; Serial.print ("\ n / n Mus pw rau"); Serial.print (sleepTimeInMinutes); Serial.println ("feeb (s) …"); }}

void voj () {

unsigned ntev currentMillis = millis (); ncua (4000); // Yog tias peb dhau lub sijhawm dhau los ces yuam kev txheeb xyuas lub qhov rooj thiab qhov kub. yog (currentMillis - previousMillis> = ncua sijhawm) {stateChanged = muaj tseeb; PreviousMillis = currentMillis; Serial.print (suav ++); Serial.println (") Txheeb xyuas vim lub sijhawm dhau mus!"); } lwm yog (stateChanged) {Serial.print (suav ++); Serial.println (") Txheeb xyuas vim lub xeev hloov pauv!"); }

// Yog hais tias lub xeev hloov ces kos lub qhov rooj thiab qhov kub.

yog (stateChanged) {checkStatus (); }

ncua (sleepTime);

}

Kauj Ruam 20: Cov txiaj ntsig

Cov txiaj ntsig
Cov txiaj ntsig

Thaum koj upload cov cai hauv qib dhau los koj yuav tsum muaj cov txiaj ntsig zoo li qhov piv txwv qhia saum toj no.

Kauj ruam 21: Khab nias

Kuv pom ntau cov lus qhia pab tau thiab cov lus qhia los ntawm Random Nerd Tutorials thiab xav ua lawv tsaug rau txhua qhov ntawm lawv txoj kev pab. Tshwj xeeb tshaj yog lawv cov ntawv qhia tau zoo ntawm ESP32 ESP8266 Tshaj Tawm Kev Nyeem Ntawv rau Google Cov Ntawv uas ib feem loj ntawm Cov Lus Qhia no yog ua raws.

Ib qho ntxiv, DHT11 Qhia los ntawm TheCircuit tau pab kuv nkag siab siv qhov no pheej yig heev tab sis nthuav me me lub ntsuas cua.

Tsis tas li ntawd, muaj ntau yam kev qhia cuam tshuam txog kev saib xyuas koj lub qhov rooj zoo li Lub Nkoj Qhov Rooj Saib Xyuas thiab lwm qhov los ntawm Kev Nyuaj Siab Nerd Tutorials. Kuv siv cov khoom me me thiab cov khoom no los pab kuv nkag siab yuav ua li cas kom kuv lub reed hloov ua haujlwm kom raug.

Thaum kawg, nrog cov ntaub ntawv no nrog rau lwm cov ntsiab lus Kuv pom nyob ib puag ncig Internet Kuv muaj peev xwm los tsim cov kab ke uas ua tau raws li qhov kuv xav tau. Kuv vam tias koj pom Cov Lus Qhia no muaj txiaj ntsig thiab tsim ib qho ntawm koj tus kheej.

Pom zoo: