Cov txheej txheem:

Network ntawm Cov Ntsuas Kub: 6 Kauj Ruam
Network ntawm Cov Ntsuas Kub: 6 Kauj Ruam

Video: Network ntawm Cov Ntsuas Kub: 6 Kauj Ruam

Video: Network ntawm Cov Ntsuas Kub: 6 Kauj Ruam
Video: Plab Plab Ntswg..(Pluav Pluav Ntswg) Maiv Twm New Song 2023-2024 2024, Hlis ntuj nqeg
Anonim
Image
Image

Kub thiab av noo yog cov ntaub ntawv tseem ceeb hauv koj chav kuaj ntshav, chav ua noj, kab tsim khoom, chaw ua haujlwm, neeg hlau tua neeg, thiab txawm tias koj lub tsev. Yog tias koj xav tau los tshuaj xyuas ntau qhov chaw lossis chav nyob lossis thaj chaw koj xav tau qee yam uas ntseeg tau, cog lus, raug thiab raug. Koj tuaj yeem yuav cov ntsuas ntsuas kim tab sis yog tias koj tab tom saib xyuas ntau chav no tuaj yeem ua rau koj cov nuj nqis nce mus. Cov ntawv qhia no yuav qhia koj yuav ua li cas thiaj tsim cov ntsuas no thiab saib xyuas koj cov ntaub ntawv yam tsis tau ua txhaum lub txhab nyiaj.

Nov yog daim ntawv thov zoo tshaj rau $ 14 Raspberry Pi Zero WH raws li cov cuab yeej no yog qhov me me, pheej yig, muaj zog, thiab muaj WiFi built-in. Kev teeb tsa rau txhua qhov ntsuas qhov ntsuas yuav raug nqi ~ $ 31 ntxiv rau kev xa khoom, se, thiab rooj plaub. Koj tuaj yeem yooj yim tau txais txhua yam khoom saum toj no hauv qhov ntau kom txo tus nqi thauj khoom nrog rau kev zam ntawm Raspberry Pi Zero WH, uas tej zaum yuav nyuaj dua sab nraum UK. Koj tsis tuaj yeem nrhiav tus neeg muag khoom uas tso cai rau koj yuav ntau dua ib Xoom rau Raspberry Pi Foundation cov cai.

Peb tab tom siv $ 14 Zero WH tsis yog $ 10 Zero W txij li Zero WH muaj lub taub hau ua ntej muag, uas yuav ua rau peb txoj haujlwm sib dhos ua kom nrawm thiab yooj yim. Peb tab tom siv DHT22 qhov ntsuas kub/av noo vim nws qhov ntsuas kub (+/- 0.5 ° C), av noo ntau (0-100%), thiab tus nqi qis. Peb kuj xav tau qee yam yooj yim heev rau xaim tsis tas yuav ntxiv qhov rub tawm tus tiv thaiv.

Khoom siv

  • Raspberry Pi Zero WH ($ 14)
  • Micro SD daim npav ($ 4)
  • Raspberry Pi fais fab mov ($ 8)
  • DHT22 Kub/Vaum Sensor ($ 5)
  • (Tsis teb los tau) Raspberry Pi Zero W rooj plaub ($ 6)

Kauj ruam 1: Sib dhos

Los ua ke
Los ua ke

DHT22 yuav muaj peb tus pin uas koj yuav xav tau txuas rau koj Pi Zero WH: 5V, Av, thiab cov ntaub ntawv. Tus pin fais fab ntawm DHT22 yuav raug sau lo lus '+' lossis '5V'. Txuas qhov no mus rau tus pin 2 (tus lej sab saum toj, 5V) ntawm Pi Zero WH. Tus pin hauv av ntawm DHT22 yuav raug sau tias '-' lossis 'Gnd'. Txuas qhov no rau tus pin 6 (ob tus pin hauv qab 5V tus pin) ntawm Pi Zero WH. Tus pin ntxiv ntawm DHT22 yog tus pin cov ntaub ntawv thiab yuav sau tias 'tawm' lossis 's' lossis 'cov ntaub ntawv'. Txuas qhov no mus rau ib qho ntawm GPIO pins ntawm Zero WH xws li GPIO4 (tus pin 7). Koj qhov kev sib txuas yuav tsum zoo li cov duab suav nrog.

Kauj ruam 2: Teeb Software

Koj yuav xav tau tus saib xyuas thiab keyboard los teeb tsa koj Pi Zero WH thawj zaug. Thaum nws tau teeb tsa, koj yuav tsis xav tau lub monitor lossis keyboard los khiav thaum xa tawm hauv koj qhov chaw. Peb xav khaws txhua lub pob kom me me thiab cog lus ntau li ntau tau.

  1. Koj yuav tsum teeb tsa tus qauv Raspbian kev ua haujlwm kom koj Pi Zero WH yuav pib. Koj tuaj yeem ua raws cov lus qhia ntawm Raspberry Pi lub vev xaib txhawm rau teeb tsa koj Pi Zero WH.
  2. Txuas koj Pi Zero WH rau koj lub network WiFi. Koj tuaj yeem ua raws cov lus qhia ntawm Raspberry Pi lub vev xaib txhawm rau txuas koj Pi Zero WH rau WiFi.
  3. Nruab Adafruit DHT Python module ntawm koj tus Pi kom nyeem DHT22 sensor cov ntaub ntawv yooj yim heev. Sau cov hauv qab no hauv koj qhov kev hais kom ua:

$ sudo pip nruab Adafruit_DHT

Tam sim no koj muaj txhua yam koj xav tau los sib txuas lus nrog koj lub sensor. Tom ntej no, koj xav tau lub hom phiaj rau koj cov ntaub ntawv sensor yog li koj tuaj yeem tig cov ntaub ntawv ntawd mus rau hauv lub dashboard txaus lossis SMS/email ceeb toom. Peb yuav siv Thawj Lub Xeev rau cov kauj ruam ntawm txoj haujlwm no.

  1. Sau npe rau tus as khauj ntawm
  2. Nruab ISStreamer module ntawm koj qhov kev hais kom ua:

$ sudo pip nruab ISStreamer

Kauj ruam 3: Python Script

Nrog peb cov txheej txheem ua haujlwm nruab nrog peb ob lub Python cov qauv rau nyeem cov ntaub ntawv sensor thiab xa cov ntaub ntawv mus rau Lub Xeev Pib, peb tau npaj sau peb tsab ntawv Python. Cov ntawv hauv qab no yuav tsim/txuas ntxiv mus rau Thawj Lub Xeev cov ntaub ntawv thoob, nyeem DHT22 cov ntaub ntawv ntsuas, thiab xa cov ntaub ntawv ntawd mus rau lub sijhawm tiag tiag dashboard. Txhua yam koj yuav tsum tau ua yog hloov kab 6–11.

ntshuam Adafruit_DHT

los ntawm ISStreamer. Streamer ntshuam lub sijhawm Streamer ntshuam # --------- Cov Chaw Siv --------- SENSOR_LOCATION_NAME = "Chaw Haujlwm" BUCKET_NAME = ": ib nrab_sunny: Chav Kub" BUCKET_KEY = "rt0129" ACCESS_KEY = "PLACE KOJ TUS NEEG NYOB HAUV TSEV KAWM NTAWV ACCESS KEY NTAWM NO" MINUTES_BETWEEN_READS = 10 METRIC_UNITS = Tsis tseeb # --------------------------------- streamer = Streamer (bucket_name = BUCKET_NAME, bucket_key = BUCKET_KEY, access_key = ACCESS_KEY) thaum Muaj tseeb: av noo, temp_c = Adafruit_DHT.read_retry (Adafruit_DHT. DHT22, 4) yog METRIC_UNITS: streamer.log (SENSOR_LOCATION_NAME + "Kub (C)), Kub (C) lwm tus: temp_f = format (temp_c * 9.0 / 5.0 + 32.0, ".2f") streamer.log (SENSOR_LOCATION_NAME + "Kub (F)", temp_f) humidity = format (humidity, ".2f") streamer.log (SENSOR_LOCATION_NAME + "Vaum (%)", av noo) streamer.flush () time.sleep (60*MINUTES_BETWEEN_READS)

  • Kab 6 - Tus nqi no yuav tsum yog qhov tshwj xeeb rau txhua qhov ntsuas/ntsuas kub. Qhov no tuaj yeem yog koj lub cim ntsuas lub npe chav, qhov chaw nyob, tus cim tshwj xeeb, lossis ib yam dab tsi. Tsuas yog xyuas kom nws yog qhov tshwj xeeb rau txhua lub node kom ntseeg tau tias cov ntaub ntawv los ntawm qhov ntawm no mus rau nws tus kheej cov ntaub ntawv ntws hauv koj lub dashboard.
  • Kab 7 - Nov yog lub npe ntawm cov thoob cov ntaub ntawv. Qhov no tuaj yeem hloov pauv txhua lub sijhawm hauv Initial State UI.
  • Kab 8 - Nov yog koj lub thoob qhov tseem ceeb. Nws yuav tsum yog tib lub thoob qhov tseem ceeb rau txhua lub node koj xav pom hauv tib lub dashboard.
  • Kab 9 - Nov yog Koj Tus Thawj Xib Fwb nkag mus rau tus lej nkag. Luam+muab tus yuam sij no los ntawm koj lub Xeev Tus Thawj Kav Xwm.
  • Kab 10 - Nov yog lub sijhawm nruab nrab ntawm kev nyeem ntawv. Hloov raws li.
  • Kab 11 - Koj tuaj yeem hais qhia qhov ntsuas lossis ntsuas chav nyob.

Tom qab koj tau teeb tsa kab 6-11 hauv koj tsab ntawv Python ntawm koj Pi Zero WH, txuag thiab tawm ntawm cov ntawv sau. Khiav tsab ntawv nrog cov lus txib hauv qab no:

$ python tempsensor.py

Rov ua cov kauj ruam no rau txhua qhov sensor. Tsuav yog txhua txoj kab xa cov ntaub ntawv mus rau Lub Xeev Pib siv tib tus yuam sij nkag thiab tus yuam sij thoob, txhua cov ntaub ntawv yuav nkag mus rau tib lub thoob cov ntaub ntawv thiab nthuav tawm ntawm tib lub dashboard.

Kauj ruam 4: Dashboard

Dashboard
Dashboard
Dashboard
Dashboard

Mus rau koj Tus Thawj Xibfwb Lub Xeev, nyem rau ntawm lub thoob lub npe ntawm koj lub thoob ntim khoom, thiab saib koj cov ntaub ntawv hauv koj lub dashboard. Koj tuaj yeem hloov kho koj lub dashboard thiab teeb tsa SMS/email ua rau. Cov duab suav nrog qhia pom lub dashboard nrog peb lub ntsuas ntsuas ntsuas kub thiab av noo rau peb chav sib txawv.

Koj tuaj yeem xaiv ntxiv cov duab keeb kwm yav dhau rau koj lub dashboard.

Kauj Ruam 5: Pib Pib & Saib Xyuas Txheej Txheem thiab IP

Pib Pib & Saib Xyuas Txheej Txheem thiab IP
Pib Pib & Saib Xyuas Txheej Txheem thiab IP

Thaum koj muaj ntau lub chaw xa mus, koj yuav xav tau txoj hauv kev los saib xyuas txhua qhov ntawm kom ntseeg tau tias nws ua haujlwm. Tej zaum koj yuav khiav txhua lub sensor tsis muaj tus saib lossis keyboard/nas kom nws compact. Qhov ntawd txhais tau tias koj yuav xav kom txhua lub hauv paus rau khau raj thiab khiav koj cov ntawv sau cia. Koj tuaj yeem siv koj li Nyiaj Txiag Hauv Xeev los tsim cov txheej txheem yooj yim/IP chaw nyob dashboard raws li qhia saum toj no. Cov ncauj lus qhia ntxaws txog kev tsim lub dashboard no thiab teeb tsa koj Pi Zero WH kom pib siv koj li Python tsab ntawv ntawm khau raj tuaj yeem pom ntawm no.

Kauj Ruam 6: Xaus

Xaus
Xaus

Thaum koj tau txais ib lub sensor ntawm qhov nce thiab khiav, nws yog ib qho yooj yim thiab tsis kim kom rov ua koj cov teeb tsa ntau zaus raws li xav tau. Siv Pi Zero WH muab rau koj hloov pauv los ua lwm txoj haujlwm vim nws muaj lub zog ntau heev. Piv txwv li, koj tuaj yeem siv ib qho ntawm Pi Zero WH's los rub cov ntaub ntawv huab cua hauv ib cheeb tsam los ntawm huab cua API thiab ntxiv rau koj lub dashboard sensor. Yog tias koj txiav txim siab tshem tawm koj lub cim ntsuas, koj tuaj yeem siv koj li Pi Zero WH rau lwm txoj haujlwm. Qhov kev hloov pauv no pab yav tom ntej-pov thawj koj qhov peev txheej.

Pom zoo: