Cov txheej txheem:

DS18B20 Kub Sensor Box: 5 Kauj Ruam
DS18B20 Kub Sensor Box: 5 Kauj Ruam

Video: DS18B20 Kub Sensor Box: 5 Kauj Ruam

Video: DS18B20 Kub Sensor Box: 5 Kauj Ruam
Video: Проект "Рельсы", часть 1: запуск шасси 2024, Hlis ntuj nqeg
Anonim
DS18B20 Kub Sensor Box
DS18B20 Kub Sensor Box

Yooj yim DS18B20 raws qhov ntsuas qhov ntsuas kub nrog qhib qhov 3D luam tawm lub thawv thiab cov qauv PCB.

Lub thawv thiab tus qauv PCB yog xaiv tau, tsuas yog ib qho ESP8266 raws MCU xav tau thiab ib qho DS18B20 ntsuas kub. Kuv qhia rau koj WEMOS D1 mini, tab sis qhov piv txwv no ua haujlwm nrog ESP-01 ib yam.

Qhov piv txwv no piav qhia yuav sau li cas thiab tso ib qho Arduino program mus rau ESP8266 MCU, yog li paub txog qhov txuj ci no ua ntej ua raws kuv.:)

Khoom siv

Yuav tsum muaj:- ESP8266 MCU- DS18B20- ib qho 4.7 kOhm resistor- ib co xaim

Xaiv tau:- WEMOS D1 mini li MCU- tus qauv PCB rau WEMOS D1 mini- 3D lub thawv luam ntawv

Kauj Ruam 1: Yuav Ua Li Cas Txuas Cov Xov Tooj?

Yuav Ua Li Cas Txuas Cov Xov Tooj?
Yuav Ua Li Cas Txuas Cov Xov Tooj?

Nws yog ib qho yooj yim li ncuav qab zib, txheeb xyuas cov kab hluav taws xob ntawm daim duab …:)

1, Yog tias tsis muaj lub rooj tsav xwm ESP8266, txuas RX thiab TX rau koj lub cuab yeej USB-txuas, thaum muaj ib lub rooj tsav xwm nrog USB sib xyaw ua ke qhov no tsis tsim nyog.

2, Txuas GND thiab VCC mus rau ESP8266 lub rooj tsavxwm thiab mus rau DS18B20 sensor.

3, Txuas tus tiv thaiv nruab nrab ntawm VCC thiab cov ntaub ntawv xov hlau ntawm DS18B20 sensor.

4, Txuas cov ntaub ntawv xov tooj ntawm DS18B20 sensor mus rau ib qho GPIO ntawm MCU (piv txwv li GPIO 2).

Kauj Ruam 2: Kho ArduinoIDE

Koj xav tau peb lub tsev qiv ntawv ntxiv:- OneWire: https://www.arduinolibraries.info/libraries/one-wire- DallasTemperature: https://www.arduinolibraries.info/libraries/dallas-temperature- IoT Guru Integration:

Kauj Ruam 3: Sau Npe thiab Tsim Khoom, Node thiab Field

IoT Guru huab yog huab dawb backend, koj tuaj yeem siv nws los cawm thiab qhia ntsuas qhov yooj yim heev.

Koj yuav tsum tsim lub cuab yeej, ntawm qhov chaw thiab thaj chaw:- Lub npe ntawm lub cuab yeej yog ESP8266: https://iotguru.cloud/tutorials/devices- Lub npe ntawm qhov yog DS18B20: https://iotguru.cloud/tutorials/ nodes- Lub npe teb yog qhov kub:

Txhawm rau txuas nrog huab, koj yuav tsum sib sau tsib tus cim:- userShortId: tus cim luv ntawm koj- deviceShortId: tus cim luv ntawm koj lub ntaus ntawv- ntaus ntawvKey: tus yuam sij zais ntawm koj lub ntaus ntawv-nodeShortId: tus cim luv ntawm koj lub ntaus ntawv- tebName: lub npe ntawm daim teb

Kauj ruam 4: Arduino Code

Nov yog tus lej piv txwv, koj yuav tsum hloov tus cim rau koj tus cim, hloov SSID thiab tus password rau koj li ntaub ntawv pov thawj WiFi thiab txheeb xyuas GPIO tus lej ntawm DS18B20 cov ntaub ntawv xov hlau.

#suav nrog

#include #include #include const char* ssid = "iotguru.cloud"; const char*password = "********"; String userShortId = "l4jLDUDDVKNNzx4wt2UR6Q"; Txoj hlua deviceShortId = "uAjbSzf8LvlrofvwYU8R6g"; Txoj hlua deviceKey = "hacfIjPn6KbBf2md8nxNeg"; IoTGuru iotGuru = IoTGuru (userShortId, deviceShortId, deviceKey); Txoj hlua nodeKey = "tGib1WSRvEGJ98rQYU8R6g"; String fieldName = "kub"; #define ONE_WIRE_BUS 2 OneWire oneWire (ONE_WIRE_BUS); DallasTemperature sensors (& oneWire); teeb tsa tsis muaj dab tsi (tsis muaj dab tsi) {Serial.begin (115200); ncua (10); WiFi.begin (ssid, password); thaum (WiFi.status ()! = WL_CONNECTED) {ncua (50); Serial.print ("."); } Serial.println (""); iotGuru.setCheckDuration (60000); iotGuru.setDebugPrinter (& Serial); sensors.begin (); } void loop (tsis muaj dab tsi) {iotGuru.check (); sensors.requestTemperatures (); ntab ntsuasValue = sensors.getTempCByIndex (0); Serial.println ("Thawj qhov ntsuas kub:" + Txoj hlua (ntsuas tus nqi) + "° C"); iotGuru.sendHttpValue (nodeKey, fieldName, ntsuas tus nqi); ncua (30000); }

Kauj ruam 5: Khiav thiab Tshawb xyuas

Khiav thiab Kos
Khiav thiab Kos

Yog tias txhua yam zoo, koj lub npov ntsuas cua yuav xa lub ntsuas ntsuas mus rau huab thiab koj yuav pom cov duab zoo li lub sijhawm yog tias kev ntsuas txaus tau sau tseg.

Cov piv txwv nyob: -

Txuas ntxiv qhov project GitHub:-

Pom zoo: