Cov txheej txheem:
- Kauj Ruam 1: BoM - Cov Nqi Khoom Siv
- Kauj Ruam 2: Txhim Kho Qhov Kub & Vaum Sensor
- Kauj Ruam 3: Txhim Kho DS18B20 - Kub Sensor
- Kauj Ruam 4: Txhim Kho BMP180
- Kauj Ruam 5: Ntsuas Huab Cua thiab Qhov Siab Nrog BMP180
- Kauj Ruam 6: Ua tiav HW
- Kauj Ruam 7: Xa Cov Ntaub Ntawv rau ThingSpeak
- Kauj Ruam 8: Xa Cov Ntaub Ntawv Chaw Nyob mus rau ThingSpeak Siv ESP8266
- Kauj Ruam 9: Sau Ntawv Kawg
- Kauj ruam 10: Xaus
Video: IoT Weather Station Nrog RPi thiab ESP8266: 10 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
Ntawm kev qhia yav dhau los, peb tau ua si nrog NodeMCU, lub ntsuas pa thiab kawm paub yuav ua li cas txhawm rau thiab sau cov ntaub ntawv ntawm ThingSpeak (Internet ntawm Yam (IoT) platform uas tso cai rau koj sau thiab khaws cov ntaub ntawv sensor hauv huab thiab tsim IoT daim ntawv thov):
IOT MADE YOOJ YIM: CAPTURING REMOTE WEATHER DATA: UV THIAB AIR TEMPERATURE & HUMIDITY
Nrog qhov kev qhia tshiab no, peb yuav kawm paub yuav ua li cas ib yam tab sis lub sijhawm no, siv Raspberry Pi txhawm rau ntes cov ntaub ntawv los ntawm ntau qhov sib txawv thiab tseem tshawb nrhiav ntau txoj hauv kev sib txuas lus ntawm cov khoom siv thiab lub vev xaib:
Sensors thiab Cominication yam:
- DHT22 (Kub thiab Vaum) ==> Kev sib txuas lus digital
- BMP180 (Kub thiab Siab) ==> I2C raws tu qauv
- DS18B20 (Kub) ==> 1-Wire Protocol
Cov duab kab lus Qhia pom dab tsi peb yuav tau txais thaum kawg nrog txoj haujlwm no:
Kauj Ruam 1: BoM - Cov Nqi Khoom Siv
- Raspberry Pi V3 - US $ 32.00
- DHT22 Kub thiab Txheeb Ze Cov Vaum Sensor - USD 9.95
- Resistor 4K7 ohm
- DS18B20 Waterproof Kub Sensor - USD 5.95
- Resistor 4K7 ohm
- BMP180 Barometric Siab, Kub thiab Qhov Siab Sensor - USD 6.99
Kauj Ruam 2: Txhim Kho Qhov Kub & Vaum Sensor
Thawj lub ntsuas hluav taws xob tau teeb tsa yuav yog DHT22 rau kev ntes huab cua kub thiab cov ntaub ntawv txheeb ze cov av noo. ADAFRUIT qhov chaw muab cov ntaub ntawv zoo txog cov ntsuas no. Hauv qab no, qee cov ntaub ntawv khaws los ntawm qhov ntawd:
Txheej txheem cej luam
Tus nqi qis DHT qhov ntsuas kub & av noo yog qhov yooj yim heev thiab qeeb tab sis zoo rau cov nyiam ua haujlwm uas xav ua qee cov ntaub ntawv sau cia yooj yim. DHT cov ntsuas tau ua los ntawm ob ntu, lub ntsuas hluav taws xob muaj peev xwm, thiab lub ntsuas cua sov. Kuj tseem muaj cov txheej txheem yooj yim heev sab hauv uas ua qee qhov sib piv rau kev hloov pauv digital thiab nti tawm lub teeb liab digital nrog qhov kub thiab txias. Cov teeb liab digital yog yooj yim kom nyeem tau siv ib lub microcontroller.
DHT22 Cov yam ntxwv tseem ceeb:
- Tus nqi qis
- 3 txog 5V lub zog thiab I/O
- 2.5mA siv tam sim no thaum hloov pauv (thaum thov cov ntaub ntawv)
- Zoo rau 0-100% cov av noo nrog 2-5% qhov tseeb
- Zoo rau -40 txog 125 ° C ntsuas kub ± 0.5 ° C raug
- Tsis pub ntau tshaj 0.5 Hz tus qauv piv txwv (ib zaug txhua 2 vib nas this)
- Lub cev loj 15.1mm x 25mm x 7.7mm
- 4 pins nrog 0.1 "spacing
Ib zaug feem ntau koj yuav siv lub ntsuas ntawm qhov nrug tsawg dua 20m, 4K7 ohm resistor yuav tsum txuas nrog ntawm Cov Ntaub Ntawv thiab VCC tus pin. DHT22 cov ntaub ntawv tso tawm tus pin yuav txuas nrog Raspberry GPIO 16. Txheeb xyuas daim duab hluav taws xob saum toj no, txuas lub sensor rau RPi pins raws li hauv qab no:
- Pin 1 - Vcc ==> 3.3V
- Pin 2 - Cov ntaub ntawv ==> GPIO 16
- Pin 3 - Tsis Txuas
- Pin 4 - Gnd ==> Gnd
Tsis txhob hnov qab Txhim Kho 4K7 ohm resistor ntawm Vcc thiab Cov Ntaub Ntawv pins
Thaum lub ntsuas tau txuas nrog, peb yuav tsum tau teeb nws lub tsev qiv ntawv ntawm peb RPi.
Txhim kho DHT Library:
Ntawm koj li Raspberry, pib ntawm /tsev, mus rau /Cov Ntaub Ntawv
cd Cov ntaub ntawv
Tsim cov npe rau nruab lub tsev qiv ntawv thiab txav mus rau qhov ntawd:
mkdir DHT22_Sensor
cd DHT22_Sensor
Ntawm koj tus browser, mus rau Adafruit GitHub:
github.com/adafruit/Adafruit_Python_DHT
Rub lub tsev qiv ntawv los ntawm txhaj rau rub rub zip txuas rau sab xis thiab unzip cov ntawv khaws cia ntawm koj li Raspberry Pi nyuam qhuav tsim cov ntawv. Tom qab ntawd mus rau phau ntawv teev npe ntawm lub tsev qiv ntawv (subfolder uas tau tsim los thaum koj qhib cov ntaub ntawv), thiab ua raws cov lus txib:
sudo python3 setup.py nruab
Qhib qhov kev xeem (DHT22_test.py) los ntawm kuv GITHUB
ntshuam Adafruit_DHT
DHT22Sensor = Adafruit_DHT. DHT22 DHTpin = 16 vaum, qhov kub = Adafruit_DHT.read_retry (DHT22Sensor, DHTpin) yog cov av noo tsis muaj thiab tsis kub tsis yog: print ('Temp = {0: 0.1f}*C Vaum = {1: 0.1 f}%'. hom ntawv (kub, av noo)) lwm qhov: luam tawm (' Ua tsis tau tejyam nyeem. Sim dua! ')
Ua qhov program nrog cov lus txib:
python3 DHT22_test.py
Hauv qab Terminal Terminal tshuaj ntsuam pom qhov tshwm sim.
Kauj Ruam 3: Txhim Kho DS18B20 - Kub Sensor
Txheej txheem cej luam Sensor:
Peb yuav siv hauv qhov kev qhia no tiv thaiv dej tsis haum ntawm DS18B20 sensor. Nws yog qhov muaj txiaj ntsig zoo rau qhov kub thiab txias nyob rau thaj tsam ntub, piv txwv li ntawm cov av noo. Lub ntsuas ntsuas tau sib cais thiab tuaj yeem ntsuas ntsuas kom txog 125oC (Adafrut tsis pom zoo kom siv nws ntau dua 100oC vim nws lub tsho PVC cable).
DS18B20 yog lub ntsuas digital uas ua rau nws zoo siv txawm tias nyob deb deb! Cov 1-xaim digital ntsuas qhov ntsuas yog qhov ncaj ncees (± 0.5 ° C ntau ntawm qhov ntau) thiab tuaj yeem muab txog 12 qhov khoom ntawm qhov tseeb los ntawm onboard digital-to-analog converter. Lawv ua haujlwm zoo nrog NodeMCU siv tus lej digital nkaus xwb, thiab koj tseem tuaj yeem txuas ntau tus rau tib tus pin, txhua tus muaj qhov tshwj xeeb 64-ntsis ID hlawv hauv lub hoobkas kom sib txawv lawv.
Lub sensor ua haujlwm los ntawm 3.0 txog 5.0V, txhais tau tias nws tuaj yeem siv ncaj qha los ntawm 3.3V muab los ntawm ib qho ntawm Raspberry pins (1 lossis 17).
Lub sensor muaj 3 xaim:
- Dub: GND
- Liab: VCC
- Daj: 1-Cov Ntaub Ntawv Hlau
Ntawm no, koj tuaj yeem pom cov ntaub ntawv tag nrho: DS18B20 Datasheet
Kev teeb tsa Sensor:
Ua raws li daim duab saum toj no thiab ua kev sib txuas:
- Vcc ==> 3.3V
- Gnd ==> Gnws
- Cov ntaub ntawv ==> GPIO 4 (default for library)
Txhim kho Python Library:
Tom ntej no, cia nruab Python lub tsev qiv ntawv uas yuav lis lub sensor:
sudo pip3 nruab w1thermsensor
Ua ntej khiav tsab ntawv txhawm rau ntsuas lub ntsuas, kos yog tias "1-Wire" interface tau qhib rau hauv koj li RPi (saib saum toj sau ntawv)
Tsis txhob hnov qab rov pib dua koj RPi, tom qab hloov nws cov teeb tsa
Kev ntsuas lub sensor:
Rau kev ntsuas lub ntsuas kab ntawv yooj yim nab nab tuaj yeem siv tau:
lub sij hawm ntshuam
los ntawm w1thermsensor ntshuam W1ThermSensor ds18b20Sensor = W1ThermSensor () thaum Tseeb: kub = ds18b20Sensor.get_temperature () luam tawm ("Kub yog % s c Celsius" % kub) time.sleep (1)
Kauj Ruam 4: Txhim Kho BMP180
Txheej txheem cej luam Sensor:
BMP180 yog tus ua tiav ntawm BMP085, lub cim tshiab ntawm kev ntsuas siab digital siab ntsuas rau cov neeg siv khoom thov. Lub zog qis heev, hluav taws xob hluav taws xob tsawg ntawm BMP180 tau ua kom zoo rau siv hauv xov tooj ntawm tes, PDAs, GPS cov khoom siv qhia thiab khoom siv sab nraum zoov. Nrog lub suab nrov qis qis ntawm tsuas yog 0.25m ntawm lub sijhawm hloov pauv sai, BMP180 muab kev ua tau zoo tshaj. I2C interface tso cai rau kev sib koom ua ke yooj yim nrog lub microcontroller. BMP180 yog ua raws cov thev naus laus zis thev naus laus zis thev naus laus zis rau EMC kev ruaj khov, qhov tseeb, thiab kev ncaj ncees ntxiv rau kev ruaj ntseg mus sij hawm ntev.
Ua tiav daim ntawv BMP tuaj yeem nrhiav tau ntawm no: BMP180 - Digital Pressure Sensor
Kev teeb tsa Sensor: Ua raws li daim duab saum toj no thiab ua qhov sib txuas:
- Vin ==> 3.3V
- GND ==> GND
- SCL ==> GPIO 3
- SDA ==> GPIO 2
Pab kom I2C Interface
Mus rau RPi Configuration thiab lees paub tias I2C interface tau qhib. Yog tias tsis yog, qhib nws thiab rov pib RPi.
Siv BMP180
Yog tias txhua yam tau teeb tsa zoo, thiab txhua yam tau txuas nrog zoo, tam sim no koj npaj tau qhib koj li Pi thiab pib pom dab tsi BMP180 tau qhia koj txog lub ntiaj teb ib puag ncig koj.
Thawj qhov uas yuav tsum tau ua yog xyuas yog tias Pi pom koj li BMP180. Sim cov hauv qab no hauv lub qhov rai davhlau ya nyob twg:
sudo i2cdetect -y 1
Yog tias cov lus txib ua haujlwm, koj yuav tsum pom qee yam zoo sib xws saum toj no Terminal Printscreen, qhia tias BMP180 nyob ntawm channel '77'.
Txhim kho lub tsev qiv ntawv BMP180:
Tsim cov npe rau nruab lub tsev qiv ntawv:
mkdir BMP180_Sensorcd BMP180_Sensor
Ntawm koj tus browser, mus rau Adafruit GITHub:
github.com/adafruit/Adafruit_Python_BMP
Rub lub tsev qiv ntawv los ntawm txhaj rau rub rub zip txuas rau sab xis thiab unzip cov ntawv khaws cia ntawm koj li Raspberry Pi tsim cov ntawv. Tom qab ntawd mus rau subfolder tsim thiab ua raws cov lus txib hauv qab no hauv cov npe ntawm cov tsev qiv ntawv:
sudo python3 setup.py nruab
Qhib koj li Python IDE thiab tsim qhov kev xeem thiab npe nws, piv txwv li BMP180Test.py
ntshuam Adafruit_BMP. BMP085 li BMP085sensor = BMP085. BMP085 () print ('Temp = {0: 0.2f} *C'.format (sensor.read_temperature ())) print (' Siab = {0: 0.2f} Pa '. format (sensor.read_pressure ())) print ('Altitude = {0: 0.2f} m'.format (sensor.read_altitude ())) print (' Sealevel Siab = {0: 0.2f} Pa'.format (sensor.read_sealevel_pressure ()))
Ua qhov kev xeem ntawv:
nab hab sej 3 BMP180Test.py
Lub davhlau ya nyob twg Terminal saum toj no qhia pom qhov tshwm sim.
Nco ntsoov tias qhov siab tau nthuav tawm hauv Pa (Pascals). Saib cov kauj ruam tom ntej kom nkag siab zoo dua txog chav tsev no.
Kauj Ruam 5: Ntsuas Huab Cua thiab Qhov Siab Nrog BMP180
Cia peb siv sijhawm los nkag siab me ntsis ntxiv txog yam peb yuav tau txais, nrog kev nyeem BMP. Koj tuaj yeem hla ntu no ntawm kev qhia, lossis rov qab los tom qab.
Yog tias koj xav paub ntau ntxiv txog Sensor nyeem, thov mus rau qhov kev qhia zoo no:
BMP180 tau tsim los ntsuas qhov ntsuas huab cua kom raug. Huab cua huab cua sib txawv nrog huab cua thiab qhov siab.
Dab tsi yog Huab Cua Siab?
Lub ntsiab lus ntawm huab cua siab yog lub zog uas huab cua nyob ib puag ncig koj ua rau txhua yam. Qhov hnyav ntawm cov pa cua hauv huab cua tsim huab cua hauv siab. Ib chav tsev siab yog "phaus ib square inch" lossis psi. Peb yuav siv ntawm no cov cim thoob ntiaj teb, uas yog newtons ib square meter, uas hu ua pascals (Pa).
Yog tias koj nqa 1 cm dav kem ntawm huab cua yuav hnyav txog 1 kg
Qhov hnyav no, nyem rau ntawm tus hneev taw ntawm kab ntawv ntawd, tsim cov huab cua hauv siab uas peb tuaj yeem ntsuas nrog cov ntsuas zoo li BMP180. Vim tias qhov dav -dav dav ntawm huab cua hnyav txog 1Kg, nws ua raws li qhov nruab nrab dej hiav txwv siab txog 101325 pascals, lossis zoo dua, 1013.25 hPa (1 hPa tseem hu ua milibar - mbar). Qhov no yuav poob li 4% rau txhua 300 metres koj nce. Qhov siab koj tau txais, qhov tsawg dua qhov koj yuav pom, vim tias kab ntawv mus rau saum huab cua yog luv dua thiab yog li hnyav dua. Qhov no muaj txiaj ntsig kom paub, vim los ntawm kev ntsuas lub siab thiab ua qee qhov lej, koj tuaj yeem txiav txim siab koj qhov siab.
Cov huab cua siab ntawm 3, 810 meters tsuas yog ib nrab ntawm qhov uas nyob hauv hiav txwv.
BMP180 tso tawm qhov siab hauv pascals (Pa). Ib pascal yog qhov me me ntawm qhov siab, kwv yees tus nqi uas ib daim ntawv yuav ua kom so ntawm lub rooj. Koj yuav pom ntau zaus ntsuas hauv hectopascals (1 hPa = 100 Pa). Lub tsev qiv ntawv siv ntawm no muab cov txiaj ntsig ntab-ntsiab lus hauv hPa, uas tseem tshwm sim kom sib npaug ib millibar (mbar).
Nov yog qee qhov kev hloov pauv mus rau lwm qhov ntsuas siab:
- 1 hPa = 100 Pa = 1 mbar = 0.001 bar
- 1 hPa = 0.75006168 TZS
- 1 hPa = 0.01450377 psi (phaus ib square inch)
- 1 hPa = 0.02953337 inHg (inches ntawm mercury)
- 1 hpa = 0.00098692 atm (txheem huab cua)
Cov Teeb Meem Kub
Vim tias qhov kub thiab txias cuam tshuam rau qhov hnyav ntawm cov pa, thiab qhov hnyav cuam tshuam rau qhov hnyav ntawm cov pa, thiab qhov hnyav cuam tshuam rau qhov siab (whew), huab cua hauv siab yuav hloov pauv nrog qhov kub thiab txias. Cov kws tsav dav hlau paub qhov no raws li "qhov siab qhov siab", uas ua rau nws yooj yim dua rau hnub txias dua li qhov kub vim tias huab cua ntom ntom thiab muaj lub zog zoo dua qub. Txhawm rau txhawm rau ntsuas kub, BMP180 suav nrog qhov ntsuas kub zoo dua nrog rau lub ntsuas siab.
Txhawm rau ua qhov ntsuas siab, koj xub ntsuas qhov ntsuas kub, tom qab ntawd ua ke nrog qhov ntsuas siab nyoos kom tuaj yeem ntsuas qhov ntsuas kub siab kawg. (Lub tsev qiv ntawv ua txhua yam no yooj yim heev.)
Ntsuas Siab Siab
Yog tias koj daim ntawv thov yuav tsum ntsuas qhov ntsuas siab, txhua yam koj yuav tsum ua yog ntsuas qhov ntsuas kub, tom qab ntawd ua qhov ntsuas siab (saib cov duab piv txwv kom ntxaws). Qhov siab kawg nyeem yuav nyob hauv hPa = mbar. Yog tias koj xav tau, koj tuaj yeem hloov qhov no mus rau chav sib txawv uas siv cov kev hloov pauv saum toj no.
Nco ntsoov tias qhov siab ntawm huab cua yuav txawv nrog koj qhov siab thiab cov qauv huab cua tam sim no, ob qho no yog yam khoom tseem ceeb los ntsuas.
Kev Saib Xyuas Huab Cua
Cov huab cua siab ntawm ib qho chaw nyob hauv ntiaj teb (lossis txhua qhov chaw nrog huab cua) tsis tas li. Kev sib cuam tshuam nyuaj ntawm lub ntiaj teb txoj kev tig, axis qaij, thiab ntau yam ntxiv ua rau thaj chaw txav mus los ntawm siab dua thiab qis dua, uas ua rau muaj kev hloov pauv huab cua peb pom txhua hnub. Los ntawm kev saib rau kev hloov pauv hauv siab, koj tuaj yeem kwv yees kev hloov pauv luv luv hauv huab cua. Piv txwv li, kev poob siab feem ntau txhais tau tias huab cua ntub lossis cua daj cua dub tab tom los (lub zog qis tau txav mus los). Kev nce siab feem ntau txhais tau tias huab cua ntshiab tab tom los txog (lub zog siab tau txav mus los). Tab sis nco ntsoov tias huab cua siab kuj txawv nrog qhov siab. Qhov siab tshaj plaws hauv kuv lub tsev, Lo Barnechea hauv Chile (qhov siab 950m) ib txwm qis dua qhov siab tshaj hauv San Francisco piv txwv (tsawg dua 2 meters, yuav luag hiav txwv). Yog tias cov chaw saib huab cua nyuam qhuav tshaj tawm lawv qhov kev ntsuas siab, nws yuav nyuaj rau ncaj qha sib piv ntsuas ntsuas los ntawm ib qhov chaw mus rau lwm qhov (thiab kev kwv yees huab cua loj yog nyob ntawm kev ntsuas los ntawm ntau qhov chaw raws li ua tau).
Txhawm rau daws qhov teeb meem no, cov chaw ntsuas huab cua ib txwm tshem tawm qhov cuam tshuam ntawm qhov siab los ntawm lawv qhov kev qhia ntsuas siab los ntawm kev ua lej ntxiv qhov sib npaug ruaj khov kom ua rau nws zoo li yog tias tau nyeem ntawm qib hiav txwv. Thaum koj ua qhov no, kev nyeem ntawv siab dua hauv San Francisco ntau dua Lo Barnechea ib txwm yog vim huab cua qauv, thiab tsis yog vim qhov siab.
Txhawm rau ua qhov no, muaj lub luag haujlwm hauv lub tsev qiv ntawv hu ua qib hiav txwv (P, A). Qhov no siv qhov siab (P) hauv hPa, thiab qhov chaw nres tsheb qhov siab tam sim no (A) hauv meters, thiab tshem tawm qhov cuam tshuam ntawm qhov siab ntawm qhov siab. Koj tuaj yeem siv cov txiaj ntsig ntawm txoj haujlwm no los sib piv ncaj qha koj cov huab cua nyeem rau lwm qhov chaw thoob ntiaj teb.
Txiav txim siab qhov siab
Txij li lub siab sib txawv nrog qhov siab, koj tuaj yeem siv lub ntsuas siab ntsuas ntsuas qhov siab (nrog qee qhov kev ceeb toom). Qhov nruab nrab siab ntawm huab cua ntawm qib hiav txwv yog 1013.25 hPa (lossis mbar). Qhov no poob rau xoom thaum koj nce mus rau qhov nqus ntawm qhov chaw. Vim tias qhov nkhaus ntawm qhov kev poob qis no tau nkag siab zoo, koj tuaj yeem suav qhov siab sib txawv ntawm ob qhov kev ntsuas siab (p thiab p0) los ntawm kev siv qhov sib npaug tshwj xeeb.
Yog tias koj siv dej hiav txwv siab (1013.25 hPa) raws li lub hauv paus siab (p0), qhov tso tawm ntawm qhov sib npaug yuav yog koj qhov siab tam sim no saum toj no hiav txwv. Muaj lub luag haujlwm hauv lub tsev qiv ntawv hu ua qhov siab (P, P0) uas cia koj tau txais "suav qhov siab".
Cov lus piav qhia saum toj no tau muab rho tawm los ntawm BMP 180 Sparkfun nyeem.
Kauj Ruam 6: Ua tiav HW
Kauj Ruam 7: Xa Cov Ntaub Ntawv rau ThingSpeak
Txog tam sim no, peb tau kawm paub yuav npaj RPi li cas txhawm rau ntes cov ntaub ntawv los ntawm tag nrho 3 lub ntsuas cua, luam tawm rau ntawm lub davhlau ya nyob twg. Tam sim no, nws yog lub sijhawm los saib yuav xa cov ntaub ntawv no mus rau IoT platform, ThingSpeak li cas.
Cia peb pib!
Ua ntej, koj yuav tsum muaj tus as khauj ntawm ThinkSpeak.com
Ua raws cov lus qhia los tsim Channel thiab sau koj li Channel ID thiab Sau API Key
Rub tawm Python Script los ntawm kuv GitHub: localData ToTS_v1_EXT.py
Cia peb tawm tswv yim cov cai tseem ceeb tshaj plaws:
Ua ntej tshaj, cia li ntshuam lub tsev qiv ntawv ThingSpeak, txheeb xyuas cov neeg siv WiFi thiab txheeb xyuas koj li Router hauv cheeb tsam thiab Thinkspeak daim ntawv pov thawj:
ntshuam yam lus
Muaj ntau txoj hauv kev los sib txuas lus nrog ThingSpeak, txoj hauv kev yooj yim tshaj plaws yog siv cov tsev qiv ntawv cov neeg siv khoom rau yam khoom siv yam API API tsim los ntawm Mikolaj Chwaliz thiab Keith Ellis.
Lub tsev qiv ntawv tuaj yeem rub tawm los ntawm https://github.com/mchwalisz/thingspeak lossis siv PIP ntawm lub davhlau ya nyob twg:
sudo pip3 nruab yam khoom
Tom ntej no, sab hauv tsab ntawv, hloov kho ThingSpeak channel cov ntaub ntawv pov thawj
chId = 9999999 # Nkag mus nrog koj li Channel ID
tsKey = 'ENTER WITH YOUR CHANNEL WRITE KEY' tsUrl = 'https://api.thingspeak.com/update' ts = thingspeak. Channel (chId, tsUrl, tsKey)
Tam sim no, cia pib ua ntej 3 lub ntsuas:
# DS18B20 1-Wire lub tsev qiv ntawv
los ntawm w1thermsensor ntshuam W1ThermSensor ds18b20Sensor = W1ThermSensor () # Los ntawm default GPIO 4 tau siv los ntawm tsev qiv ntawv # DHT22 Library import Adafruit_DHT DHT22Sensor = Adafruit_DHT. DHT22 DHTpin = 16 # BMP180 library import Adafruit_BMP. BMP085 li BMP085 (BMP085) Koj yuav tsum txheeb xyuas qhov siab tiag tiag uas koj Lub Chaw Saib Huab Cua nyob, hloov kho thoob ntiaj teb sib txawv "altReal". Hauv kuv qhov xwm txheej, Kuv Qhov Chaw Nres Tsheb nyob ntawm 950m siab dua ntawm hiav txwv
ntiaj teb altReal
pem = 950
Thaum nkag mus nrog lub chaw nres tsheb qhov siab tiag tiag raws li kev tawm tswv yim, peb tuaj yeem tau txais lub siab tsis txaus, dej hiav txwv siab, qhov kub thiab qhov siab siv qhov ua haujlwm bmp180GetData (qhov siab):
def bmp180GetData (qhov siab):
temp = bmp180Sensor.read_temperature () pres = bmp180Sensor.read_pressure () alt=bmp180Sensor.read_altitude () presSeaLevel = pres/pow (1.0 - qhov siab/44330.0, 5.255) temp = puag ncig (temp, 1) pres = puag ncig (pres/100), 2) # meej siab hauv hPa (lossis mbar) alt=puag ncig (alt) presSeaLevel = puag ncig (presSeaLevel/100, 2) # tsis muaj siab hauv hPa (lossis mbar) rov qab tem, pres, alt, presSeaLevel
Kev ua haujlwm getLocalData (), yuav xa rov qab txhua cov ntaub ntawv hauv cheeb tsam uas tau ntes los ntawm peb lub chaw nres tsheb:
def getLocalData (): cov
ntiaj teb lub sijhawm Cov hlua thoob ntiaj teb humLab ntiaj teb tempExt ntiaj teb tempLab ntiaj teb presSL ntiaj teb altLab ntiaj teb presAbs # Tau sijhawm nyeem tam sim no = datetime.datetime.now () timeString = now.strftime ("%Y-%m-%d%H:%M") # Nyeem Sab Nraud Kub (1 meter nrug) tempExt = puag ncig (ds18b20Sensor.get_temperature (), 1) tempLab, presAbs, altLab, presSL = bmp180GetData (altReal) humDHT, tempDHT = Adafruit_DHT.read_retry (DHT22 tsis yog) thiab tempDHT tsis yog Tsis muaj: humLab = puag ncig (humDHT
Thaum koj muaj tag nrho cov ntaub ntawv khaws los ntawm cov haujlwm saum toj no, koj yuav tsum xa lawv mus rau ThingSpeak. Koj yuav ua nws siv kev ua haujlwm sendDataTs ():
def xaDataTs ():
data = {"field1": tempLab, "field2": tempExt, "field3": humLab, "field4": presSL, "field5": altLab} ts.update (data) print ("[INFO] Cov ntaub ntawv xa mus rau 5 daim teb: ", tempLab, tempExt, humLab, presSL, altLab)
Nrog koj cov ntaub ntawv channel hloov tshiab, txuag tsab ntawv thiab ua nws ntawm koj lub davhlau ya nyob twg:
sudo Python3 localData_ToTs_v1_EXT.py
Txog Kev sib txuas lus cov txheej txheem
Nco ntsoov tias siv "lub tsev qiv ntawv hais lus", "thov lub tsev qiv ntawv" raug xa tawm, uas yog Apache2 Tso Cai HTTP lub tsev qiv ntawv, sau hauv Python. Cov ntaub ntawv thov Kev teeb tsa ua haujlwm tuaj yeem nrhiav tau ntawm no:
docs.python-requests.org/en/latest/user/install/
Yog tias tsim nyog, ua ntej khiav koj tsab ntawv, koj tuaj yeem txheeb xyuas yog tias thov lub tsev qiv ntawv raug teeb tsa:
sudo pip3 nruab kev thov
Kev xaiv koj tuaj yeem siv MTTQ ua txoj hauv kev xa cov ntaub ntawv mus rau ThingSpeak. MQTT txawv ntawm HTTP, ib zaug Nws tau tsim tshwj xeeb los ua lub teeb yuag thiab npaj rau cov khoom siv nrog nrog RAM tsawg thiab CPU ua haujlwm tau zoo. Tsis tas li, feem ntau, MQTT siv tsawg dua bandwidth.
Xa mus rau qhov kev qhia no: Hloov Kho Dab TsiSpeak Channel siv MQTT ntawm Raspberry Pi kom paub meej ntxiv.
Kauj Ruam 8: Xa Cov Ntaub Ntawv Chaw Nyob mus rau ThingSpeak Siv ESP8266
Rau theem no, peb yuav siv tib HW uas tau piav qhia hauv muy qhia:
IOT MADE YOOJ YIM: CAPTURING REMOTE WEATHER DATA: UV THIAB AIR TEMPERATURE & HUMIDITY
Cov cai uas peb yuav siv ntawm no, yog qhov zoo ib yam siv ntawm cov ntawv qhia no. Cia peb tawm tswv yim cov cai tseem ceeb tshaj plaws:
Ua ntej tshaj, hu rau ESP8266 lub tsev qiv ntawv, txheeb xyuas WiFi tus neeg siv thiab txheeb xyuas koj li Router hauv zos thiab Thinkspeak cov ntaub ntawv pov thawj:
/ * NodeMCU ESP12-E */
#suav nrog WiFiClient tus neeg siv khoom; const char* MY_SSID = "ENTER nrog koj li SSDID"; const char* MY_PWD = "ENTER WITH YOUR PASSWORD"; /* Thinkspeak*/ const char* TS_SERVER = "api.thingspeak.com"; Txoj hlua TS_API_KEY = "ENTER WITH YOUR WRITE KEY";
Qhov thib ob, cia suav nrog lub tsev qiv ntawv tseem ceeb heev rau IoT cov haujlwm: SimpleTimer.h:
/ * TIMER */
#suav nrog SimpleTimer timer;
Thib peb, thaum teeb tsa (), peb yuav pib sib txuas lus txuas, hu rau lub luag haujlwm txuas txuas Wii () thiab txheeb xyuas lub sijhawm. Nco ntsoov tias kab ntawm txoj cai: timer.setInterval (60000L, xa cov ntaub ntawv); yuav hu lub luag haujlwm sendDataTS () txhua 60 vib nas this, txhawm rau rub cov ntaub ntawv rau ThinkSpeak channel.
void teeb tsa ()
{… Serial.begin (115200); ncua (10); … TxuasWifi (); timer.setInterval (60000L, xa cov ntaub ntawv); …}
Thaum kawg tab sis tsis tsawg, thaum lub voj (), tsuas yog cov lus txib xav tau yog pib lub sijhawm thiab qhov ntawd yog nws!
void lub voj ()
{… Timer.run (); // Pib SimpleTimer}
Hauv qab no, koj tuaj yeem pom ob txoj haujlwm tseem ceeb siv los tuav Thinkspeak kev sib txuas lus:
ESP12-E txuas nrog koj lub network WiFi:
/***************************************************
*Txuas WiFi *********************************************** ***/ void connectWifi () {Serial.print ("Txuas rau"+*MY_SSID); WiFi.begin (MY_SSID, MY_PWD); thaum (WiFi.status ()! = WL_CONNECTED) {ncua (1000); Serial.print ("."); } Serial.println (""); Serial.println ("WiFi Txuas"); Serial.println (""); }
ESP12-E xa cov ntaub ntawv rau ThinkSpeak:
***************************************************
*Xa Cov Ntaub Ntawv rau Thinkspeak Channel ******************************************** ******/ void sendDataTS (void) {if (client.connect (TS_SERVER, 80)) {String postStr = TS_API_KEY; postStr += "& teb 6 ="; postStr += Txoj hlua (temp); postStr += "& teb7 ="; postStr += Txoj hlua (hum); postStr += "& field8 ="; postStr += String (dataSensorUV); postStr += "\ r / n / r / n"; client.print ("POST /hloov tshiab HTTP /1.1 / n"); client.print ("Tus tswv tsev: api.thingspeak.com / n"); client.print ("Kev sib txuas: kaw / n"); client.print ("X-THINGSPEAKAPIKEY:" + TS_API_KEY + "\ n"); client.print ("Cov ntsiab lus-Hom: thov/x-www-form-urlencoded / n"); client.print ("Cov ntsiab lus-Ntev:"); client.print (postStr.length ()); client.print ("\ n / n"); client.print (postStr); ncua (1000); } xa ++; client.stop (); cov. }
Cov lej ua tiav tuaj yeem pom ntawm kuv GitHub: NodeMCU_UV_DHT_Sensor_OLED_TS_EXT
Thaum koj muaj cov cai tso rau koj NodeMCU. Cia peb txuas lub roj teeb sab nraud thiab ntsuas qee qhov ntsuas hauv qab lub hnub. Kuv muab Chaw Taws Teeb Chaw Nyob ntawm lub ru tsev thiab pib ntes cov ntaub ntawv ntawm ThingSpeak.com raws li qhia hauv cov duab saum toj no.
Kauj Ruam 9: Sau Ntawv Kawg
Lub hom phiaj tseem ceeb ntawm qhov kev qhia no yog los qhia yuav ua li cas txuas Raspberry Pi mus rau ThingSpeak. Qhov no yog qhov zoo rau kev khaws cov ntaub ntawv thiab nkag mus rau ntawm IoT platform.
Siv lub sijhawm peb tseem xa cov ntaub ntawv mus rau cov channel tshwj xeeb ntawd, ntes lawv los ntawm chaw nres tsheb nyob deb uas siv ESP8266. Nov yog txoj hauv kev yog OK, tab sis tsis yog qhov zoo tshaj plaws. Vim tias peb muaj "asynchronous" ua haujlwm, qee zaum, ob qho tib si, RPi thiab ESP8266 sim nkag mus rau tib lub sijhawm (lossis nrog lub sijhawm me me) dab tsi yog tsis lees paub los ntawm ThingSpeak. Qhov zoo tshaj yuav muaj ESP8266 xa cov ntaub ntawv hauv zos mus rau Raspberry Pi thiab qhov kawg yog lub luag haujlwm los saib xyuas txhua cov ntaub ntawv. Ua qhov ntawd, "Chaw Nres Tsheb Loj" (Raspberry Pi), tuaj yeem ua 3 yam:
- Nkag tag nrho cov ntaub ntawv ntawm lub hauv paus hauv cheeb tsam
- Qhia tag nrho cov ntaub ntawv ntawm lub WebPage hauv zos (siv Flask raws li qhia hauv daim duab saum toj no)
- Xa tag nrho cov ntaub ntawv rau ThingSpeak tib lub sijhawm.
Hauv kev qhia yav tom ntej, peb yuav tshawb xyuas cov kev xaiv ntawd.
Kauj ruam 10: Xaus
Raws li ib txwm muaj, Kuv vam tias txoj haujlwm no tuaj yeem pab lwm tus pom lawv txoj hauv kev mus rau hauv lub ntiaj teb zoo ntawm hluav taws xob!
Yog xav paub ntxiv thiab tus lej kawg, thov mus saib kuv qhov kev tso nyiaj GitHub: RPi-NodeMCU-Weather-Station
Yog xav paub ntau ntxiv, thov mus saib kuv qhov blog: MJRoBot.org
Nyob twj ywm! Kev qhia tom ntej peb yuav xa cov ntaub ntawv los ntawm chaw nres tsheb huab cua nyob deb mus rau hauv nruab nrab, raws li Raspberry Pi Web server:
Saludos los ntawm sab qab teb ntawm lub ntiaj teb!
Pom koj hauv kuv cov lus qhia tom ntej!
Ua tsaug, Marcelo
Pom zoo:
Qhov muag tsis pom kev Nrog ESP8266, Google Tsev thiab Openhab Kev Sib Koom thiab Kev Tswj Xyuas Web: 5 Cov Kauj Ruam (nrog Duab)
Qhov muag tsis pom kev Nrog ESP8266, Google Tsev thiab Openhab Kev Sib Koom thiab Kev Tswj Xyuas Web: Hauv Cov Lus Qhia no kuv qhia koj li cas kuv ntxiv kev siv tshuab rau kuv qhov muag tsis pom. Kuv xav kom muaj peev xwm ntxiv thiab tshem tawm qhov kev siv tshuab nws, yog li txhua qhov kev teeb tsa yog clip ntawm.Qhov tseem ceeb yog: Stepper motor Stepper tsav tswj bij ESP-01 Iav thiab teeb tsa
Arduino WiFi Wireless Weather Weather Station Wunderground: 10 Kauj Ruam (nrog Duab)
Arduino WiFi Wireless Weather Weather Station Wunderground: Hauv Phau Ntawv Qhia no kuv yuav qhia koj yuav tsim lub chaw nres tsheb huab cua tus kheej li cas siv ArduinoA Chaw nres tsheb huab cua yog lub cuab yeej uas khaws cov ntaub ntawv cuam tshuam nrog huab cua thiab ib puag ncig siv ntau yam sib txawv. Peb tuaj yeem ntsuas ntau yam
8 Relay Tswj Nrog NodeMCU thiab IR Txais Txais Siv WiFi thiab IR Chaw Taws Teeb thiab Android App: 5 Kauj Ruam (nrog Duab)
8 Relay Tswj Nrog NodeMCU thiab IR Txais Txais Siv WiFi thiab IR Chaw Taws Teeb thiab Android App: Tswj 8 qhov hloov pauv hloov siv nodemcu thiab ir tus txais tshaj wifi thiab ir chaw taws teeb thiab hauv app.the ir tej thaj chaw deb ua haujlwm ywj pheej ntawm wifi txuas. NTUJ
Acurite 5 in 1 Weather Station Siv Raspberry Pi thiab Weewx (lwm Cov Chaw Huab Cua Tau Tshaj): 5 Cov Kauj Ruam (nrog Duab)
Acurite 5 in 1 Weather Station Siv Raspberry Pi thiab Weewx (lwm Lub Chaw Huab Cua Puas Tau Tshaj): Thaum kuv tau yuav Acurite 5 hauv 1 lub chaw nres tsheb huab cua Kuv xav kom tuaj yeem tshawb xyuas huab cua ntawm kuv lub tsev thaum kuv nyob deb. Thaum kuv los txog tsev thiab teeb tsa kuv pom tias kuv yuav tsum muaj cov khoom txuas nrog lub khoos phis tawj lossis yuav lawv lub hauv paus ntse
Kub thiab Vaum Zaub thiab Sau Cov Ntaub Ntawv Nrog Arduino thiab Ua: 13 Kauj Ruam (nrog Duab)
Kub thiab Vaum Zaub thiab Sau Cov Ntaub Ntawv Nrog Arduino thiab Ua: Intro: Qhov no yog Txoj Haujlwm uas siv Arduino board, Sensor (DHT11), lub khoos phis tawj Windows thiab Kev Ua Haujlwm (rub tawm dawb) program los tso saib Kub, Cov ntaub ntawv vaum hauv digital thiab bar kab ntawv, tso tawm lub sijhawm thiab hnub tim thiab suav lub sijhawm suav