Cov txheej txheem:

Yuav Ua Li Cas Tsim Lub Chaw Nres Tsheb txhawm rau daws qhov mob ntawm Nrhiav Qhov Chaw Dawb: 12 Kauj Ruam
Yuav Ua Li Cas Tsim Lub Chaw Nres Tsheb txhawm rau daws qhov mob ntawm Nrhiav Qhov Chaw Dawb: 12 Kauj Ruam

Video: Yuav Ua Li Cas Tsim Lub Chaw Nres Tsheb txhawm rau daws qhov mob ntawm Nrhiav Qhov Chaw Dawb: 12 Kauj Ruam

Video: Yuav Ua Li Cas Tsim Lub Chaw Nres Tsheb txhawm rau daws qhov mob ntawm Nrhiav Qhov Chaw Dawb: 12 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim
Image
Image

Hauv qhov haujlwm no peb yuav tsim qhov chaw nres tsheb yooj yim uas siv Raspberry Pi. Nws hloov tawm tias txhua tag kis kuv yuav tsum ntsib cov lus nug no: Puas yog XAUS qhov chaw nres tsheb nyob rau ntawm kuv lub chaw haujlwm twb tau coj lawm? Vim tias thaum nws yog tiag tiag, Kuv yuav tsum mus ncig qhov thaiv thiab siv tsawg kawg 10 feeb ntxiv los nres tsheb thiab taug kev mus rau tom chaw ua haujlwm.

Yog li kuv xav tias nws yuav txias kom paub tias qhov chaw pub dawb lossis tsis yog, ua ntej txawm tias sim mus txog qhov ntawd. Thaum kawg, qhov tshwm sim yog lub cuab yeej zoo uas kuv tuaj yeem tshawb xyuas los ntawm kuv Ipod lossis xov tooj ntawm tes

Kauj ruam 1: Cov ntaub ntawv

Khoom siv
Khoom siv
Khoom siv
Khoom siv
Khoom siv
Khoom siv

1. Raspberry Pi Qauv B:

2. USB WiFi Dongle

3. Tsab ntawv tsa suab sensor los ntawm Parallax

4. Peb tus poj niam rau poj niam xaim

5. Ubidots tus account - lossis - STEM License

Kauj ruam 2: Kev thaiv kab

Thaiv
Thaiv

Lub suab txav tau yooj yim rau nruab vim nws tsuas muaj peb tus pin: GND, VCC (+5v) thiab OUT (digital signal "1" lossis "0"). Yog tias muaj kev txav ncig nws, nws yuav tso tawm "1", yog tias tsis muaj, "0".

Koj tuaj yeem pom qhov kev sib txuas hauv daim duab hauv qab no, cov hlua txuas ncaj qha mus rau GPIO pins ntawm Raspberry Pi. Yog tias koj xav tau cov ntaub ntawv ntau ntxiv txog GPIO pins koj tuaj yeem mus ntsib phau ntawv qhia no los ntawm makezine.com; nws yog qhov chaw zoo los paub nrog Raspberry Pi pins.

Kauj Ruam 3: Teeb Koj Li Ubidots Account thiab Cov Hloov

Teeb Koj Li Ubidots Account thiab Cov Hloov
Teeb Koj Li Ubidots Account thiab Cov Hloov

Yog tias koj tshiab rau Ubidots, tsim ib tus as khauj ntawm no.

Nkag mus rau "Cov Chaw" tab thiab ntxiv qhov tshiab

Kauj Ruam 4: Xaiv Raspberry Pi Raws Li Koj Cov Ntaub Ntawv Tshiab thiab Ua Daim Ntawv

Xaiv Raspberry Pi Raws Li Koj Cov Ntaub Ntawv Tshiab thiab Ua Daim Ntawv
Xaiv Raspberry Pi Raws Li Koj Cov Ntaub Ntawv Tshiab thiab Ua Daim Ntawv

Kauj Ruam 5: Tam sim no Nyem rau ntawm Qhov Chaw Tshiab "Kuv Raspberry Pi"

Tam sim no Nyem rau ntawm Qhov Chaw Tshiab
Tam sim no Nyem rau ntawm Qhov Chaw Tshiab

Kauj Ruam 6: Ntxiv qhov hloov pauv tshiab hu ua "pub dawb lossis tsis khoom" thiab tsis txhob hnov qab ua kom tiav Cov Npe Lub Npe thiab Chav

Ntxiv qhov hloov pauv tshiab hu
Ntxiv qhov hloov pauv tshiab hu

Kauj Ruam 7: Nco Ntsoov Koj Tus Kheej Tus ID

Nco Ntsoov Koj Tus Kheej Tus ID
Nco Ntsoov Koj Tus Kheej Tus ID

Nco tseg ntawm koj tus lej API pom hauv "Kuv Cov Ntaub Ntawv - API Ntsiab Lus"

Kauj Ruam 8: Coding Koj Raspberry Pi

Koj yuav tsum tau teeb tsa koj li Raspberry Pi, muaj Internet nkag tau los ntawm nws. Yog tias tsis yog, ua raws phau ntawv qhia no, lossis tshawb xyuas qhov blog no hais txog teeb tsa WiFi.

Thaum npaj txhij, nkag mus rau koj li Raspberry Pi los ntawm lub davhlau ya nyob twg (LxTerminal yog tias koj nkag mus rau koj tus Pi ncaj qha los ntawm nws GUI), mus rau lub nplaub tshev uas koj xav khaws qhov haujlwm no thiab tsim cov ntaub ntawv tshiab hu ua "presence.py"

$ sudo nano វត្តមាន.py

Tam sim no muab tshuaj txhuam cov cai hauv qab no:

ntshuam RPi. GPIO li GPIO ## GPIO lub tsev qiv ntawv los ntawm ubidots ntshuam ApiClient ## Ubidots Library lub sijhawm ntshuam ## lub sijhawm qiv ntawv rau qeeb GPIO.setmode (GPIO. BCM) ## teeb tsa BCM ua tus lej lej rau nkag GPIO.setup (7, GPIO. IN) ## Tshaj tawm GPIO7 ua cov tswv yim rau lub ntsuas

sim:

api = ApiClient ("75617caf2933588b7fd0da531155d16035138535") ## muab koj tus kheej apikey cov neeg = api.get_variable ("53b9f8ff76254274effbbace") ## tso koj tus kheej tus lej sib txawv tshwj tsis yog: luam "cant txuas" ## yog tias qhov no tshwm sim koj li internet): muaj = GPIO.input (7)#)#txuag tus nqi ntawm lub sensor yog (muaj == 0): ## yog tias muaj yog xoom uas txhais tau tias lwm lub tsheb tseem muaj: (people.save_value ({'tus nqi ': វត្តមាន}) ## xa tus nqi mus rau ubidots time.sleep (1) ## txheeb xyuas txhua 5 vib nas this yog tias lwm lub tsheb txav luam "cero" yog (muaj): people.save_value ({' value ': presence})# #lwm lub tsheb sab laug tam sim no yog khoob tam sim no:) sijhawm.sleep (1) luam "uno" GPIO.cleanup () ## rov pib dua cov xwm txheej ntawm GPIO pins

Khiav koj qhov program:

$ sudo nab hab sej muaj nyob.py

Kauj Ruam 9: Tsim Qhov Taw Qhia hauv Ubidots Dashboard

Tsim Qhov Taw Qhia hauv Ubidots Dashboard
Tsim Qhov Taw Qhia hauv Ubidots Dashboard

Tam sim no peb tab tom tau txais cov ntaub ntawv nyob los ntawm lub cuab yeej, peb yuav tsum tsim tus txheej txheem tshwj xeeb uas qhia peb tias qhov chaw nres tsheb raug coj los lossis tsis. Nyem rau ntawm lub dashboard tab, tom qab ntawd ntxiv cov cuab yeej tshiab:

Kauj Ruam 10: Xaiv "Qhov Taw Qhia" Widget thiab Ua Raws Cov Kauj Ruam:

Xaiv
Xaiv

Kauj Ruam 11: Tam sim no Koj Muaj Koj Qhov Ntsuas

Tam sim no koj muaj koj Qhov Ntsuas
Tam sim no koj muaj koj Qhov Ntsuas

Zoo kawg! tam sim no koj yuav tsum pom tus widget nyob qhia lub xeev ntawm qhov chaw nres tsheb. Btw koj tuaj yeem teeb tus widget no hauv ib lub vev xaib lossis mobile app:

Kauj Ruam 12: Xaus

Qhov ntawd yog txhua yam rau txoj haujlwm no! Peb tau kawm paub yuav ua li cas txhawm rau ntsuas lub suab txav mus rau Ubidots huab siv Raspberry Pi thiab tso tawm nws cov ntaub ntawv hauv cov widget nyob. Txoj haujlwm tuaj yeem txhim kho los ntawm kev siv lub ntsuas ntsuas lub ntsej muag thiab tsis yog lub suab txav (uas rov qab mus rau "0" tom qab lub zog txav mus lawm). Nws kuj tseem tuaj yeem txuas ntxiv los ntawm teeb tsa SMS lossis Email ceeb toom, uas tuaj yeem tsim nyob hauv "Cov Txheej Txheem" tab hauv koj tus lej Ubidots.

Muaj lus nug? xav tias dawb los tawm tswv yim hauv qab no lossis tawm ib daim pib hauv peb nplooj ntawv txhawb nqa.

Nov yog lwm qhov haujlwm txias siv Raspberry Pi thiab lub suab txav:

Pom zoo: