Cov txheej txheem:

Yuav Ua Li Cas Tsim Tib Neeg Suav Nrog Raspberry Pi thiab Ubidots: 6 Cov Kauj Ruam
Yuav Ua Li Cas Tsim Tib Neeg Suav Nrog Raspberry Pi thiab Ubidots: 6 Cov Kauj Ruam

Video: Yuav Ua Li Cas Tsim Tib Neeg Suav Nrog Raspberry Pi thiab Ubidots: 6 Cov Kauj Ruam

Video: Yuav Ua Li Cas Tsim Tib Neeg Suav Nrog Raspberry Pi thiab Ubidots: 6 Cov Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
Yuav Ua Li Cas Tsim Tib Neeg Suav Nrog Raspberry Pi thiab Ubidots
Yuav Ua Li Cas Tsim Tib Neeg Suav Nrog Raspberry Pi thiab Ubidots
Yuav Ua Li Cas Tsim Tib Neeg Suav Nrog Raspberry Pi thiab Ubidots
Yuav Ua Li Cas Tsim Tib Neeg Suav Nrog Raspberry Pi thiab Ubidots

Hauv txoj haujlwm yooj yim no peb yuav siv lub ntsuas suab txav mus kuaj yog tias ib qho khoom hla dhau ntawm peb Raspberry Pi. Tom qab ntawd peb yuav suav pes tsawg zaus uas tshwm sim, thiab xa tus nqi no mus rau Ubidots.

Cov neeg suav khoom feem ntau yog cov cuab yeej kim siv hauv kev lag luam muag khoom kom nkag siab tias cov neeg yuav khoom coj li cas. Ua tsaug rau Raspberry Pi thiab Ubidots, peb muaj peev xwm tsim cov neeg ua haujlwm zoo hauv ob peb teev thiab nrog ob peb nyiaj!

Thaum peb xa cov neeg suav cov ntaub ntawv mus rau Ubidots, peb tuaj yeem tsim cov duab zoo rau kev tshuaj xyuas, nrog rau SMS/Email ceeb toom.

Kauj Ruam 1: Tau Txais Cov Khoom Zoo

Tau Txais Cov Khoom Zoo
Tau Txais Cov Khoom Zoo
Tau Txais Cov Khoom Zoo
Tau Txais Cov Khoom Zoo
Tau Txais Cov Khoom Zoo
Tau Txais Cov Khoom Zoo
Tau Txais Cov Khoom Zoo
Tau Txais Cov Khoom Zoo

Txhawm rau ua tiav txoj haujlwm no koj yuav xav tau:

  1. Raspberry Pi Qauv B.
  2. PIR Sensor los ntawm Parallax
  3. Raspberry Pi tau tshaj USB WiFi Dongle
  4. Ib lub roj teeb USB ntim rau lub hwj chim Raspberry Pi (qhov no yog nyob ntawm qhov xwm txheej koj xav tawm hauv Pi kom tsis muaj wireless kiag li)
  5. Peb tus poj niam-poj niam jumper xov hlau
  6. Ubidots tus account - lossis - STEM License

Kauj Ruam 2: Txuas Cov Khoom Txuas

Txuas Cov Khoom
Txuas Cov Khoom
Txuas Cov Khoom
Txuas Cov Khoom

PIR tsab ntawv tsa suab sensor yog qhov yooj yim siv vim tias nws tsuas muaj peb tus pin:

  • V+ ua
  • GND
  • Lub cim teeb liab uas tawm "1" thaum muaj kev txav mus los thiab "0" thaum tsis muaj.

Tsis tas yuav tsum ua dab tsi los xij, lossis sau qhov nyuaj I2C lossis cov haujlwm ua haujlwm kom pom lub teeb liab no; tsuas yog ntsaws cov kab ncaj ncaj rau GPIO pins ntawm koj Raspberry Pi thiab nws yuav ua haujlwm!

Kauj ruam 3: Casing

Casing
Casing
Casing
Casing

Vim tias PIR lub ntsuas hluav taws xob nkag tau yooj yim heev, kuv tau siv lub jumper hloov tom qab nws los teeb tsa qhov qis tshaj plaws. Tsis tas li ntawd, Kuv tau nqa cov ntaub ntawv qub los ntawm ob lub looj tsom iav thiab ua lub qhov nyob hauv nws, tom qab ntawd muab RPi thiab PIR sensor tso rau hauv. Txoj kev no, lub suab txav txav tau tsom mus rau ib qho, tsis txhob ua txhua yam.

Kauj Ruam 4: Coding Koj RPi

Txog ntawm qhov no, peb yuav xav tias koj tau ua tiav kev teeb tsa yooj yim ntawm koj li Raspberry Pi thiab koj tab tom saib nws cov kab hais kom ua Linux. Yog tias tsis yog, peb pom zoo kom hla dhau phau ntawv qhia no ua ntej. Koj tseem tuaj yeem tshawb xyuas cov ntawv no hais txog kev siv Wicd los teeb tsa WiFi ntawm koj li Raspberry Pi.

Cia peb pib los ntawm kev ua kom ntseeg tau tias peb muaj txhua lub tsev qiv ntawv xav tau:

$ sudo apt-tau hloov tshiab $ sudo apt-tau upgrade $ sudo apt-tau nruab python-setuptools $ sudo easy_install pip $ pip nruab ubidots

Tsim cov ntawv tshiab hu ua "peoplecounter.py":

$ sudo nano peoplecounter.py

Thiab sau rau hauv nws cov cai hauv qab no. Nco ntsoov hloov qhov tseem ceeb ntawm tus lej API thiab tus lej sib txawv nrog tus lej hauv koj tus kheej Ubidots tus account. (Nco tseg: tus lej tsis zoo nkauj heev, tab sis hav kuv tsis yog Python tus tsim tawm, tsuas yog tus txiv neej kho vajtse:)

Tsab ntawv suav nrog lub voj uas txheeb xyuas lub xeev tus pin #7 (lub suab txav). Yog nws nyeem "1", txhais tau tias muaj kev txav mus los, tom qab ntawd nws nce "cov neeg suav" sib txawv thiab tos 1.5 vib nas this kom lub suab txav mus rov zoo li qub. Qhov no ua tiav 10 zaug, ua kom ntseeg tau tias muaj tsawg kawg 1 thib ob ntawm txhua lub voj voog, tom qab ntawd nws xa tag nrho cov "txav" mus rau Ubidots. Yog tias koj xav tau ntsuas tus neeg suav, koj yuav tsum ua si nrog kab "time.sleep" nrog rau lwm qhov txiaj ntsig.

los ntawm ubidots ntshuam ApiClient

ntshuam RPi. GPIO ua GPIO

lub sij hawm ntshuam

GPIO.setmode (GPIO. BCM)

GPIO.setup (7, GPIO. IN)

sim:

api = ApiClient ("a21ebaf64e14d195c0044fcc3b9f6dab9d653af3")

neeg = api.get_variable ("5238cec3f91b282c7357a140")

tshwj tsis yog: luam tawm "Tsis tuaj yeem txuas rau API, txheeb xyuas koj li Internet txuas"

cov = 0

neeg = 0

thaum (1):

muaj = GPIO.input (7)

yog (muaj):

neeg suav = = 1

muaj = 0

sijhawm.sleep (1.5)

sijhawm.sleep (1)

tus nqi += 1

yog (counter == 10):

luam cov neeg

neeg.save_value ({'tus nqi': neeg coob})

cov = 0

neeg = 0

Kauj Ruam 5: Tso Koj Cov Ntaub Ntawv

Zaub Koj Cov Ntaub Ntawv
Zaub Koj Cov Ntaub Ntawv
Zaub Koj Cov Ntaub Ntawv
Zaub Koj Cov Ntaub Ntawv
Zaub Koj Cov Ntaub Ntawv
Zaub Koj Cov Ntaub Ntawv
Zaub Koj Cov Ntaub Ntawv
Zaub Koj Cov Ntaub Ntawv

Thaum kawg, mus rau koj lub Ubidots dashboard thiab ntxiv cov cuab yeej ntawm hom "Nqe lus". Qhov no yuav tso tawm tag nrho cov neeg tau kuaj pom nyob rau lub sijhawm uas koj qhia

Kauj Ruam 6: Ua kom tiav

Muab qhwv
Muab qhwv

Txoj haujlwm no muab cov lus qhia ntawm cov neeg hla dhau qhov tshwj xeeb. Nws tsis muab pes tsawg tus neeg, muab cov kev txwv ntawm lub suab sensor, tab sis hauv qee daim ntawv thov qhov no yuav txaus.

Cov ntaub ntawv sau tuaj yeem xa tau yooj yim mus rau Ubidots Cloud, qhov twg nws tuaj yeem txhais los ntawm kev tsim kev ceeb toom, nyob dashboards lossis txawm tias sib qhia cov ntaub ntawv no hauv kev tshaj xov xwm, raws li cov lej nkag, lossis tsuas yog hauv qhov txuas rau pej xeem. Koj tseem tuaj yeem nyeem cov ntaub ntawv no los ntawm lwm daim ntawv thov siv Ubidots API.

Pom zoo: