Cov txheej txheem:

Tsim kom muaj Dej Txau Dej Siv Los Siv PiFace thiab Ubidots: 13 Kauj Ruam
Tsim kom muaj Dej Txau Dej Siv Los Siv PiFace thiab Ubidots: 13 Kauj Ruam

Video: Tsim kom muaj Dej Txau Dej Siv Los Siv PiFace thiab Ubidots: 13 Kauj Ruam

Video: Tsim kom muaj Dej Txau Dej Siv Los Siv PiFace thiab Ubidots: 13 Kauj Ruam
Video: Plab Plab Ntswg..(Pluav Pluav Ntswg) Maiv Twm New Song 2023-2024 2024, Hlis ntuj nqeg
Anonim
Image
Image

Nov yog qhov piv txwv txias uas qhia koj yuav siv Raspberry Pi, PiFace thiab Ubidots los ywg dej koj lub vaj los ntawm qhov deb. Koj tuaj yeem tuaj yeem tswj lub tshuab hluav taws xob nyob deb los ywg dej koj cov nroj tsuag los ntawm txhua qhov chaw, tsuas yog siv koj lub xov tooj.

Kauj Ruam 1: Koj Xav Tau Dab Tsi?

Koj Xav Tau Dab Tsi?
Koj Xav Tau Dab Tsi?
Koj Xav Tau Dab Tsi?
Koj Xav Tau Dab Tsi?
Koj Xav Tau Dab Tsi?
Koj Xav Tau Dab Tsi?

Zoo koj yuav xav tau qee cov ntaub ntawv:

1. Raspberry Pi Qauv B.

2. PiFace Digital

3. Lub Dej Dej - 12V

4. Ib txoj hlua yooj ywm (1Amp)

5. A DC Jack

6. Hwj chim adapter (12V-DC 1000mA)

7. 3/4 PVC xov txuas

8. Teflon daim kab xev

9. Hose

10. Sprinkler

11. Ubidots tus account - lossis - STEM License

Kauj Ruam 2: Txuas Cov Khoom Txuas

Txuas Cov Khoom
Txuas Cov Khoom

1. Txuas PiFace mus rau RaspberryPi yam tsis tau ntsaws rau hauv lub zog txuas.

2. Ua raws li daim duab saum toj no; Cov xaim dawb yog hauv av (GND) thiab nws tau txuas nrog lub davhlau ya nyob twg ntawm kev sib txuas ntawm PiFace, thaum cov hlau liab txuas nrog rau NO tus pin (Ib txwm Qhib).

Nco tseg: Raws li kev sib txuas hydraulic, nco ntsoov siv daim kab xev teflon ntawm txhua lub koomhaum txhawm rau tiv thaiv dej los ntawm xau.

Kauj Ruam 3: Tsim Cov Ntaub Ntawv Tshiab Hauv Ubidots

Tsim Cov Ntaub Ntawv Tshiab Hauv Ubidots
Tsim Cov Ntaub Ntawv Tshiab Hauv Ubidots

Yog tias koj tshiab rau Ubidots, mus rau www.ubidots.com thiab tsim tus account. Nkag mus rau "Cov Chaw" tab thiab nyem rau "Ntxiv Cov Ntaub Ntawv Tshiab".

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

Xaiv Raspberry Pi Raws Li Koj Cov Ntaub Ntawv Tshiab
Xaiv Raspberry Pi Raws Li Koj Cov Ntaub Ntawv Tshiab

Xaiv Raspberry Pi Icon thiab txuas ntxiv mus

Kauj Ruam 5: Tsim Ob Qhov Hloov Tshiab

Tsim Ob Qhov Hloov Tshiab
Tsim Ob Qhov Hloov Tshiab
Tsim Ob Qhov Hloov Tshiab
Tsim Ob Qhov Hloov Tshiab

Nyem rau ntawm koj cov ntaub ntawv qhov chaw thiab tsim ob qhov hloov pauv tshiab: "valve" thiab "relay_state".

Kauj Ruam 6:

Kauj Ruam 7: Coj Nco Ntsoov Koj Tus Kheej ID

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

Peb yuav xav tau tus lej ID ntawm qhov hloov pauv rau peb txoj haujlwm Raspberry Pi. Peb tseem yuav xav tau koj tus lej API Key.

Kauj ruam 8: Ntxiv Widgets rau Koj Dashboard

Ntxiv Widgets rau Koj Dashboard
Ntxiv Widgets rau Koj Dashboard

Nyem rau ntawm "Dashboard" tab thiab nyem rau ntawm "Ntxiv widget tshiab"

Kauj Ruam 9: Xaiv qhov Hloov Widget

Xaiv qhov Hloov Widget
Xaiv qhov Hloov Widget

Xaiv qhov hloov pauv Widget thiab khi nws mus rau qhov sib txawv "valve". Tus widget no yuav sau "1" lossis "0" mus rau "valve" sib txawv, uas peb yuav xaiv tom qab los ntawm peb Raspberry Pi.

Kauj ruam 10: Tsim Qhov Ntsuas Qhov Ntsuas

Tsim Qhov Ntsuas Qhov Ntsuas
Tsim Qhov Ntsuas Qhov Ntsuas

Tam sim no ntxiv lwm tus widget, xaiv qhov "ntsuas" hom widget thiab xaiv qhov sib txawv "valve_state"

Kauj ruam 11: Ua tiav

Ua tiav!
Ua tiav!

Tam sim no peb muaj lub dashboard txias, cia peb txuas ntxiv nrog cov cai.

Kauj Ruam 12: Coding Koj Raspberry Pi

Peb yuav xav tias koj muaj Raspberry Pi ua haujlwm uas txuas nrog Is Taws Nem. Yog tias tsis yog, txheeb xyuas cov ntawv blog no hais txog teeb tsa WiFi hauv Raspberry Pi. Tom qab ntawd nkag mus los ntawm lub davhlau ya nyob twg rau hauv koj li Raspberry Pi thiab teeb tsa SPI module sib tham nrog PiFace Digital:

sudo nano /etc/modprobe.d/raspi-blacklist.conf

Ntxiv tus cim "#" ua ntej kab spi-bcm2708, tom qab ntawd nias CTRL-X, ntaus Y thiab Enter. Qhov no ua rau SPI los ntawm khau raj. Tam sim no cia peb teeb tsa thiab teeb tsa PiFace Digital library:

sudo apt-tau hloov tshiabudo apt-tau nruab python3-pifacedigitalio python-pifacedigitalio

Pib dua koj Pi:

sudo rov pib dua

Zoo kawg! peb npaj tau pib coding peb qhov project. Tsim cov ntawv tshiab hu ua "valve.py" (los ntawm kev ntaus "nano valve.py") thiab muab cov lej hauv qab no tso rau hauv:

ntshuam pifacedigitalio #Library rau pifacedigitalio los ntawm ubidots ntshuam ApiClient #Library rau Ubidots

pifacedigital = pifacedigitalio. PiFaceDigital () #Declare piface object sim: api = ApiClient ("1fc7a56bf4b539725ace7a3f4aa623e9e9620612") #Tsis txhob hnov qab tso koj tus kheej Apikey valve = api.get_varable '.get_variable ("53ce95547625420403d81468") #Thov nov koj lub xeev ID tiag tiag tshwj tsis yog: luam tawm ("tsis tuaj yeem txuas") #Txheeb xyuas koj li Apikey, tus lej sib txawv thiab tus lej sib txuas hauv internet (Muaj tseeb): lastValue = valve.get_values (1) #Tau txais tus nqi kawg ntawm lub valve los ntawm Ubidots tso tawm = pifacedigital.relays [0].value #Save relay xeev valveState.save_value ({'tus nqi': tso tawm) #Xa lub xeev xa mus rau Ubidots rau hauv qhov kawgValue: luam tawm ['tus nqi'] yog (a ['tus nqi']): #Qhib lossis tshem tawm qhov txuas pifacedigital.output_pins [0].turn_on () lwm tus: pifacedigital.output_pins [0].turn_off ()

Kauj Ruam 13: Ua kom tiav

Muab qhwv
Muab qhwv

Ua tiav! Tam sim no koj muaj lub tshuab ua haujlwm nyob deb los ywg dej koj cov nroj tsuag los ntawm txhua qhov chaw tsuas yog siv koj lub xov tooj lossis ib lub web browser!

Pom zoo: