Cov txheej txheem:

ESP8266 Huab Cua Saib Xyuas Lub Vev Xaib (Tsis Muaj Arduino): 4 Cov Kauj Ruam
ESP8266 Huab Cua Saib Xyuas Lub Vev Xaib (Tsis Muaj Arduino): 4 Cov Kauj Ruam

Video: ESP8266 Huab Cua Saib Xyuas Lub Vev Xaib (Tsis Muaj Arduino): 4 Cov Kauj Ruam

Video: ESP8266 Huab Cua Saib Xyuas Lub Vev Xaib (Tsis Muaj Arduino): 4 Cov Kauj Ruam
Video: فرصة ربح قطعتين يوميا من عملة رقمية إسلامية قوية Sidra bank تسجيل في دقيقة 2024, Kaum ib hlis
Anonim
ESP8266 Huab Cua Saib Xyuas Lub Vev Xaib (Tsis Muaj Arduino)
ESP8266 Huab Cua Saib Xyuas Lub Vev Xaib (Tsis Muaj Arduino)

"Internet ntawm txhua yam" (IoT) tau dhau los ua cov ncauj lus nthuav dav zuj zus ntawm kev sib tham txhua hnub. Nws yog lub tswv yim uas tsis tsuas yog muaj peev xwm cuam tshuam peb lub neej tab sis kuj yuav ua li cas peb ua haujlwm. Los ntawm cov tshuab tsim khoom mus rau cov cuab yeej siv tau - siv lub tshuab ua kom pom cov ntaub ntawv thiab nqis tes ua cov ntaub ntawv ntawd thoob plaws lub network.

Yog li, peb txiav txim siab los tsim txoj haujlwm yooj yim tab sis nthuav dav nrog lub tswv yim - IoT.

Hnub no, peb yuav tsim lub vev xaib yooj yim los saib xyuas huab cua puag ncig peb. Peb tuaj yeem saib cov av noo thiab qhov ntsuas kub ntawm peb cov khoom siv txawb thiab phau ntawv sau. Zoo li kuv tau hais, nws yog nplooj ntawv web yooj yim thiab yooj yim los muab tswv yim rau koj. Koj tuaj yeem hloov kho thiab hloov kho txoj haujlwm raws li koj xav tau, zoo li koj tuaj yeem khaws cov ntaub ntawv thiab siv nws rau kev siv yav tom ntej, koj tuaj yeem tsim lub tsev siv tshuab los ntawm kev tswj hwm koj cov cuab yeej siv hauv tsev lossis txhua yam uas koj tuaj yeem xav. Nco ntsoov ib txwm - Lub zog ntawm kev xav ua rau peb tsis muaj qhov kawg (los ntawm John Muir).

Yog li, cia pib !!

Kauj Ruam 1: Sau Koj Cov Cuab Yeej

Sau koj cov cuab yeej !!
Sau koj cov cuab yeej !!
Sau koj cov cuab yeej !!
Sau koj cov cuab yeej !!
Sau koj cov cuab yeej !!
Sau koj cov cuab yeej !!
Sau koj cov cuab yeej !!
Sau koj cov cuab yeej !!

1 SHT25 Vaum thiab Kub Sensor

SHT25 qhov tseeb cov av noo thiab qhov ntsuas kub ntawm Sensirion tau dhau los ua tus txheej txheem kev lag luam raws li daim ntawv foos thiab kev txawj ntse: Nkag mus rau hauv qhov rov ua kom rov zoo dua qub tiaj tus tsis muaj (DFN) pob ntawm 3 x 3mm ko taw sau thiab 1.1mm qhov siab nws muab ntsuas, linearized sensor teeb liab hauv digital, hom I2C.

1 Adafruit Huzzah ESP8266

ESP8266 tus txheej txheem los ntawm Espressif yog 80 MHz microcontroller nrog WiFi puv ntoob-kawg (ob qho tib si raws li tus neeg siv khoom thiab nkag mus rau qhov chaw) thiab TCP/IP pawg nrog DNS txhawb nqa ib yam. ESP8266 yog lub platform zoo kawg rau IoT daim ntawv thov txhim kho. ESP8266 muab kev paub tab rau kev tshuaj xyuas thiab tswj kev siv daim ntawv Arduino Wire Language thiab Arduino IDE.

1 ESP8266 USB Programmer

Qhov ESP8266 tus tswv tsev adapter tau tsim tshwj xeeb rau Adafruit Huzzah version ntawm ESP8266, tso cai rau I²C interface.

1 I2C Txuas Kab

Kauj ruam 2: Txuas Kho Vajtse

Txuas Cov Khoos Phis Tawj
Txuas Cov Khoos Phis Tawj
Txuas Cov Khoom Kho Vajtse
Txuas Cov Khoom Kho Vajtse
Txuas Cov Khoos Phis Tawj
Txuas Cov Khoos Phis Tawj

Coj ESP8266 thiab maj mam thawb nws hla USB Programmer. Tom qab ntawd txuas ib kawg ntawm I2C cable rau SHT25 sensor thiab lwm qhov kawg rau USB Programmer. Thiab koj ua tiav. Yog, koj nyeem nws raug. Tsis mob taub hau, suab txias. Yog lawm !!

Nrog kev pab los ntawm ESP8266 USB Programmer, nws yooj yim heev rau program ESP. Txhua yam koj yuav tsum ua yog ntsaws lub sensor rau hauv USB Programmer thiab koj zoo mus. Peb nyiam siv cov khoom lag luam no vim tias nws ua kom yooj yim dua los txuas cov khoom siv. Yog tsis muaj cov ntsaws thiab ua si USB Programmer muaj qhov pheej hmoo ntawm kev ua txuas tsis raug. Kev xaim hluav taws xob tsis zoo tuaj yeem tua koj li Wi -nkaus thiab koj lub sensor.

Tsis muaj kev txhawj xeeb txog kev siv tus pin ntawm ESP rau lub sensor lossis nyeem tus lej kab kos thiab cov ntawv teev npe. Peb tuaj yeem siv thiab ua haujlwm ntawm ntau lub ntsuas hluav taws xob ib txhij, koj tsuas yog xav tau ua cov saw hlau.

Ntawm no koj txheeb xyuas tag nrho cov khoom lag luam los ntawm lawv.

Nco tseg: Thaum ua kev sib txuas thov ua kom ntseeg tau tias cov xaim xim av ntawm cov xov txuas txuas nrog rau hauv av hauv av ntawm lub ntsuas cua thiab zoo ib yam rau USB Programmer.

Kauj ruam 3: Code

Code
Code
Code
Code
Code
Code
Code
Code

ESP8266 code rau SHT25 tuaj yeem rub tawm los ntawm peb qhov chaw cia khoom github

Ua ntej mus rau txoj cai, nco ntsoov koj nyeem cov lus qhia muab hauv Readme cov ntaub ntawv thiab teeb tsa koj li ESP8266 raws li nws. Nws yuav siv sijhawm tsuas yog 5 feeb los teeb tsa ESP.

Tam sim no, rub tawm (lossis git rub) cov cai thiab qhib nws hauv Arduino IDE.

Sau thiab xa cov cai thiab pom cov txiaj ntsig ntawm Serial Monitor.

Nco tseg: Ua ntej rub tawm, xyuas kom tseeb tias koj nkag mus rau koj li SSID network thiab tus password hauv tus lej.

Luam tus IP chaw nyob ntawm ESP8266 los ntawm Serial Monitor thiab muab tso rau hauv koj lub vev xaib.

Koj yuav pom lub web server nrog cov av noo thiab ntsuas kub. Cov txiaj ntsig ntawm lub ntsuas ntawm Serial Monitor thiab Web Server tau qhia hauv daim duab saum toj no.

Rau koj txoj kev nplij siab koj tuaj yeem luam theej ua ESP tus lej rau lub ntsuas no los ntawm no kuj:

#suav nrog

#suav nrog

#suav nrog

#suav nrog

// SHT25 I2C chaw nyob yog 0x40 (64)

#define Ntxiv 0x40

const char* ssid = "koj lub network ssid";

const char* password = "koj tus password"; ntab dej noo, cTemp, fTemp;

ESP8266WebServer server (80);

tsis muaj dab tsi handleroot ()

{unsigned int cov ntaub ntawv [2];

// Pib I2C kis tau tus mob

Wire.beginTransmission (Addr); // Xa cov lus ntsuas ntsuas, TSIS MUAJ HOLD tswv Wire.write (0xF5); // Nres I2C kev xa xov Wire.endTransmission (); ncua (500);

// Thov 2 bytes ntawm cov ntaub ntawv

Wire.requestFrom (Addr, 2);

// Nyeem 2 bytes ntawm cov ntaub ntawv

// humidity msb, av noo lsb yog (Wire.available () == 2) {data [0] = Wire.read (); cov ntaub ntawv [1] = Wire.read ();

// Hloov cov ntaub ntawv

av noo = (((cov ntaub ntawv [0] * 256.0 + cov ntaub ntawv [1]) * 125.0) / 65536.0) - 6;

// Cov ntaub ntawv tso tawm rau Serial Monitor

Serial.print ("Tus txheeb ze Vaum:"); Serial.print (av noo); Serial.println (" %RH"); }

// Pib I2C kis tau tus mob

Wire.beginTransmission (Addr); // Xa qhov ntsuas qhov ntsuas kub, TSIS TXHOB tuav tswv Wire.write (0xF3); // Nres I2C kev xa xov Wire.endTransmission (); ncua (500);

// Thov 2 bytes ntawm cov ntaub ntawv

Wire.requestFrom (Addr, 2);

// Nyeem 2 bytes ntawm cov ntaub ntawv

// temp msb, temp lsb yog (Wire.available () == 2) {data [0] = Wire.read (); cov ntaub ntawv [1] = Wire.read ();

// Hloov cov ntaub ntawv

cTemp = (((data [0] * 256.0 + data [1]) * 175.72) / 65536.0) - 46.85; fTemp = (cTemp * 1.8) + 32;

// Cov ntaub ntawv tso tawm rau Serial Monitor

Serial.print ("Kub hauv Celsius:"); Serial.print (cTemp); Serial.println ("C"); Serial.print ("Kub hauv Fahrenheit:"); Serial.print (fTemp); Serial.println ("F"); } // Cov ntaub ntawv tso tawm rau lub vev xaib server.sendContent ("<meta http-equiv = 'refresh' cov ntsiab lus = '5'""

Tswj txhua yam

www.controleverything.com

SHT25 Sensor I2C Mini Module

"); server.sendContent ("

Tus txheeb ze Vaum = " + Txoj hlua (av noo) +" %RH "); server.sendContent ("

Kub hauv Celsius = " + Txoj hlua (cTemp) +" C "); server.sendContent ("

Kub hauv Fahrenheit = " + String (fTemp) +" F "); ncua (300);}

void teeb tsa ()

{// Initialise I2C kev sib txuas lus li MASTER Wire.begin (2, 14); // Initialise serial communication, set baud rate = 115200 Serial.begin (115200);

// Txuas rau WiFi network

WiFi.begin (ssid, password);

// Tos rau kev txuas

thaum (WiFi.status ()! = WL_CONNECTED) {ncua (500); Serial.print ("."); } Serial.println (""); Serial.print ("Txuas nrog"); Serial.println (ssid);

// Tau txais IP chaw nyob ntawm ESP8266

Serial.print ("IP chaw nyob:"); Serial.println (WiFi.localIP ());

// Pib server

server.on ("/", tus tuav tes); server.begin (); Serial.println ("HTTP server tau pib"); }

void lub voj ()

{server.handleClient (); }

Kauj Ruam 4: Xaus

SHT25 cov av noo thiab qhov kub thiab txias series ua rau siv lub tshuab thev naus laus zis mus rau qib tshiab nrog kev ua haujlwm tsis sib xws, ntau yam sib txawv, thiab cov yam ntxwv tshiab. Haum rau ntau yam kev lag luam, xws li khoom siv hauv tsev, kho mob, IoT, HVAC, lossis kev lag luam. Nrog kev pab los ntawm ESP8266, peb tuaj yeem nce nws lub peev xwm kom ntev dua. Peb tuaj yeem tswj hwm peb cov cuab yeej siv thiab saib xyuas qhov ua tau zoo ntawm peb phau ntawv sau thiab khoom siv mobile. Peb tuaj yeem khaws thiab tswj cov ntaub ntawv online thiab kawm lawv txhua lub sijhawm rau kev hloov kho.

Peb tuaj yeem siv cov tswv yim zoo li no hauv kev kho mob, rau ib pliag tsuas yog hais kom tswj lub qhov cua nkag hauv chav neeg mob thaum cov av noo thiab qhov kub tau nce tuaj. Cov neeg ua haujlwm kho mob tuaj yeem saib xyuas cov ntaub ntawv online yam tsis mus hauv chav.

Vam tias koj nyiam qhov kev rau siab thiab xav txog qhov muaj peev xwm ntau nrog nws. Zoo li kuv tau hais los saum no, Kev xav yog tus yuam sij.:)

Yog xav paub ntxiv txog SHT25 thiab ESP8266, txheeb xyuas qhov txuas hauv qab no:

  • SHT25 Vaum thiab Kub Sensor Cov Ntaub Ntawv
  • Cov Ntaub Ntawv Keeb Kwm Dav Hlau rau ESP8266 los ntawm Kev Tshawb Dav Dav Dav

Yog xav paub ntxiv, mus saib ControlEverything.

Pom zoo: