Cov txheej txheem:

DIY Raspberry Pi Kub Kub Nrog Ubidots: 7 Cov Kauj Ruam (nrog Duab)
DIY Raspberry Pi Kub Kub Nrog Ubidots: 7 Cov Kauj Ruam (nrog Duab)

Video: DIY Raspberry Pi Kub Kub Nrog Ubidots: 7 Cov Kauj Ruam (nrog Duab)

Video: DIY Raspberry Pi Kub Kub Nrog Ubidots: 7 Cov Kauj Ruam (nrog Duab)
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
DIY Raspberry Pi Kub Kub Nrog Ubidots
DIY Raspberry Pi Kub Kub Nrog Ubidots

Kev ntsuas ntsuas qhov ntsuas kub muab kev nkag siab zoo hauv ob qho lag luam thiab kev lag luam kom txo qis kev ua haujlwm tsis zoo lossis tswj hwm cov khoom lag luam thiab lawv cov txiaj ntsig zoo. Yuav ua li cas yog tias kuv hais rau koj tias koj tuaj yeem saib xyuas qhov kub ntawm koj tus kheej ua cawv txiv hmab-cellar lossis koj tsev neeg cov thoob dej yug ntses hauv tsev siv tib lub cuab yeej. Ntxiv mus, yuav ua li cas yog tias kuv tau hais rau koj tias tib lub cuab yeej tuaj yeem siv los saib xyuas huab cua thiab kua dej kub ntawm cov kua hauv koj lub hoobkas thiab? Cov neeg tsim khoom ntawm peb lub ntiaj teb tau ua qhov no ua tau thiab phau ntawv qhia no nyob ntawm no los pab pib koj li kev pib ua tom tsev lossis tom khw.

Phau ntawv qhia no yuav yog koj cov lus qhia rau kev yooj yim DIY ntsuas qhov ntsuas kub uas tseem tsis muaj dej rau khau raj. Siv Raspberry Pi thiab Ubidots peb yuav qhia koj li cas txuas koj Pi thiab tso saib hauv lub sijhawm tiag tiag koj qhov ntsuas kub ntsuas. Siv Ubidots, koj tseem tuaj yeem tsim email lossis SMS cov xwm txheej kom ntseeg tau tias koj "hloov pauv" (hauv qhov no, qhov kub thiab txias) tseem nyob hauv cov txheej txheem uas tau teev tseg los ntawm koj los xyuas kom zoo thiab ua haujlwm tau zoo ntawm koj cov txheej txheem.

Rau qhov haujlwm no peb yuav siv 1-wirepre-wired thiab waterproof version ntawm DS18B20 sensor. 1-xaim yog dab tsi? Nws yog kev sib txuas lus txheej txheem uas ua rau txuas koj lub IoT sensors yooj yim dua los ntawm kev sib sau tag nrho cov cabling rau hauv yog ib qho xaim (… qhov tseeb nws yog peb, ob yog hauv av thiab txuas hluav taws xob rau lub zog, qhov thib peb yog 1-xaim rau cov ntaub ntawv xa mus).

CEEB TOOM CEEB TOOM: Lub 1-Wire kub sensor muaj ntau yam sib txawv rau kev muag; ib qho nrog tus tiv thaiv sib xyaw ua ke rau hauv lub sensor thiab lwm yam tsis muaj. Thaum yuav khoom lossis teeb tsa koj lub khoos phis tawj, zoo tshaj kom paub tseeb tias koj lub cuab yeej thiab cov khoom siv tau sib xws ua ntej mus txuas ntxiv hauv qhov kev qhia no.

Kauj ruam 1: Yuav tsum tau ua

  • Raspberry Pi 3 Qauv (Tau teeb tsa lawm)
  • OneWire Kub Sensor - DS18B20
  • Ubidots tus account - lossis - STEM License

Kauj ruam 2: Teeb Teeb

Teeb Teeb
Teeb Teeb
Teeb Teeb
Teeb Teeb
Teeb Teeb
Teeb Teeb

Raws li tau hais yav dhau los, OneWire qhov ntsuas kub tau muag nrog cov qauv sib txawv uas muaj cov tiv thaiv. Txog qhov kev qhia no, peb yuav qhia ob qho tib si – nrog thiab tsis muaj tus tiv thaiv. Tsis muaj teeb meem dab tsi uas koj xaiv rau koj li kab ke, nco ntsoov xyuas ob qho kev sib txuas kom raug raws li cov duab hauv qab no thiab cov duab.

    Nrog resistor ua ke - nrog tsob ntoo txuas

Thov ua raws cov lus thiab cov duab saum toj no txhawm rau ua qhov sib txuas raug rau koj OneWire qhov ntsuas kub nrog qhov tiv thaiv.

TSWV YIM: Arduberry yog phiaj xwm tshiab hauv Kickstarter, uas coj txoj hauv kev yooj yim thiab tsis kim kom coj Arduino cov ntaub thaiv npog rau Raspberry Pi. Qhov kev xaiv tsis txaus ntseeg no yog txoj hauv kev yooj yim los pib txuas koj lub suab paj nruag sensors siv Arduino Grove daim ntaub thaiv. Yog xav paub ntxiv txog qhov no, thov siv rau kev tawm suab:)

    Tsis muaj tus tiv thaiv kev sib xyaw- tsis muaj cov ntoo txuas

Tus tiv thaiv hauv qhov teeb tsa no yog siv los rub tawm rau cov ntaub ntawv-kab, thiab yuav tsum txuas nrog ntawm cov ntaub ntawv xov hlau thiab lub xov tooj hluav taws xob. Qhov no ua kom ntseeg tau tias cov kab ntawv cov ntaub ntawv nyob ntawm qib kev nkag siab, thiab txwv kev cuam tshuam los ntawm hluav taws xob suab nrov yog tias peb tus pin tau sab laug.

Siv tus 4.7kΩ (lossis 10kΩ) tus tiv thaiv thiab ua raws daim duab saum toj no kom ua qhov sib txuas raug. Nco ntsoov tias cov pins txuas hauv Raspberry Pi yog tib yam siv hauv lub rooj.

Kauj Ruam 3: Teeb Sensor

Teeb Sensor
Teeb Sensor
Teeb Sensor
Teeb Sensor

1. Nrog koj Raspberry Pi txuas nrog internet, txheeb xyuas tus IP chaw nyob uas muab rau pawg thawj coj saib siv ssh hauv koj lub computer lub davhlau ya nyob twg:

ssh pi@{IP_Address_assigned}

Yog tias koj tseem tsis tau teeb tsa daim ntawv pov thawj ntawm koj li Raspberry Pi, nco ntsoov tias koj yuav tsum tau siv cov ntawv pov thawj tsis raug muab:

  • username: pib
  • lo lus zais: raspberry

Thaum koj tus pi tau teeb tsa thiab txuas nrog kom raug, tus neeg siv ntawm koj lub davhlau ya nyob twg tau teev tseg raws li: pi@raspberrypi

2. Tam sim no cia hloov kho qee pob khoom thiab nruab pip, Python tus thawj tswj hwm pob ntawv. Luam thiab muab cov lus hauv qab no tso rau hauv koj lub davhlau ya nyob twg thiab nias "nkag" tom qab txhua tus los ua cov lus txib.

sudo apt-tau hloov tshiab> sudo apt-tau hloov tshiab

sudo apt-tau nruab python-pip sej-dev tsim-qhov tseem ceeb

3. Tom qab ntawd, teeb tsa Thov lub tsev qiv ntawv, uas yog lub tsev qiv ntawv Python nrov uas yooj yim ua HTTP thov. Luam thiab muab cov lus txib hauv qab no tso rau hauv koj lub davhlau ya nyob twg thiab nias "nkag" khiav cov lus txib.

$ pip teeb tsa thov

4. Raspberry Pi los nruab nrog ntau yam ntawm cov tsav tsheb rau cuam tshuam. Hauv qhov no, kom muaj peev xwm thauj tau 1-Wire sensor tus tsav tsheb ntawm GPIO pins, peb yuav tsum siv cov hauv qab no ob tus neeg tsav tsheb. Cov tsav tsheb no yog li ntawd khaws cia raws li cov loadable modules thiab cov lus txib modprobe tau ua haujlwm los khau raj lawv rau hauv Linux ntsiav thaum xav tau.

Khiav cov lus txib hauv qab no:

$ sudo modprobe w1-gpio> $ sudo modprobe w1-therm

5. Tam sim no, peb yuav tsum hloov cov npe rau peb 1-Wire ntaus ntawv nplaub tshev thiab sau cov khoom siv txhawm rau txhawm rau xyuas kom ntseeg tau tias peb lub sensor tau thauj khoom raug. Luam thiab muab cov lus hauv qab no tso rau hauv koj lub davhlau ya nyob twg thiab nias "nkag" tom qab txhua tus los ua cov lus txib.

$ cd/sys/bus/w1/devices/> $ ls

Lub sijhawm no koj lub sensor twb tau sib sau ua ke thiab txuas nrog thiab yuav tsum tau teev tseg ua cov lej thiab cov ntawv. Hauv peb qhov xwm txheej, lub cuab yeej tau sau npe ua 28-00000830fa90, tab sis koj cov ntaub ntawv yuav txawv ntawm cov tsiaj ntawv thiab tus lej, yog li hloov peb tus lej xov tooj nrog koj tus kheej thiab khiav cov lus txib.

$ cd 28-00000830fa90

Tus ntsuas ib ntus sau rau w1_slave cov ntaub ntawv, txhawm rau nyeem koj lub ntsuas kub, thov khiav cov lus txib hauv qab no:

$ miv w1_slave

Cov lus txib no yuav qhia koj ob kab ntawv ntawm cov ntawv t = tso tawm qhov ntsuas kub hauv degrees Celsius. Thov nco ntsoov tias yuav tsum muab tus lej zauv tom qab thawj ob tus lej (qhov no tau muab qhia hauv qhov chaws kawg- tsis txhob txhawj); piv txwv li, qhov ntsuas kub peb tau txais yog 29.500 degrees Celsius.

Tam sim no koj tuaj yeem ntsuas ntsuas kub, nws yog lub sijhawm los tshaj tawm lawv rau Ubidots!

Kauj Ruam 4: Xa Cov Ntaub Ntawv mus rau Ubidots kom pom kev

Xa Cov Ntaub Ntawv rau Ubidots rau Kev Pom Kev
Xa Cov Ntaub Ntawv rau Ubidots rau Kev Pom Kev
Xa Cov Ntaub Ntawv rau Ubidots rau Kev Pom Kev
Xa Cov Ntaub Ntawv rau Ubidots rau Kev Pom Kev
Xa Cov Ntaub Ntawv rau Ubidots rau Kev Pom Kev
Xa Cov Ntaub Ntawv rau Ubidots rau Kev Pom Kev

Tam sim no nws yog lub sijhawm rau code!:) Tsim thiab khiav cov ntawv Python hauv koj lub computer lub davhlau ya nyob twg:

$ nano onewire_temp_ubidots.py

Tom qab ntawv muab tshuaj txhuam thiab khaws cov cai hauv qab no rau koj lub davhlau ya nyob twg: Nias ntawm no kom tau txais txoj cai

Nco ntsoov hloov tus lej lej 28-00000830fa90 nrog koj li, thiab muab koj tus lej Ubidots tus lej cim rau hauv qhov kev thov URL. Yog tias koj tsis paub yuav ua li cas kom tau txais koj li Ubidots Token, thov siv kab lus hauv qab no rau kev pab:

Nrhiav koj TOKEN los ntawm koj tus lej Ubidots

Tam sim no cia peb sim cov ntawv. Muab tshuaj txhuam thiab khiav cov ntawv hauv qab no hauv koj lub computer lub davhlau ya nyob twg.

python onewire_temp_ubidots.py

Yog tias nws ua haujlwm tau zoo, koj yuav pom lub cuab yeej tshiab hauv koj tus lej Ubidots nrog ob qhov hloov pauv: temp_c Celsius thiab temp_fahrenheit

Kauj Ruam 5: Yeem Cov Kauj Ruam: Hloov Npe Cov Ntaus thiab Cov Hloov

Yeem Cov Kauj Ruam: Hloov Npe Cov Ntaus thiab Cov Hloov
Yeem Cov Kauj Ruam: Hloov Npe Cov Ntaus thiab Cov Hloov
Yeem Cov Kauj Ruam: Hloov Npe Cov Ntaus thiab Cov Hloov
Yeem Cov Kauj Ruam: Hloov Npe Cov Ntaus thiab Cov Hloov

Cov npe ntawm cov kev hloov pauv tau tsim yog zoo ib yam li cov ntawv API, uas yog IDs siv los ntawm API. Qhov no tsis txhais tau tias lawv cov npe tsis tuaj yeem hloov pauv, yog li nws tau pom zoo kom hloov cov npe ntawm koj li khoom siv thiab cov hloov pauv kom lawv ua phooj ywg zoo rau koj lub npe. Txhawm rau kawm paub yuav hloov pauv koj lub npe hloov pauv li cas, saib hauv qab no:

Yuav hloov kho Lub Npe Lub Npe thiab lub npe hloov pauv li cas

Koj tseem tuaj yeem ntxiv thiab kho cov chav ntawm txhua qhov sib txawv los ntawm koj cov npe xaiv.

Raws li koj tuaj yeem pom saum toj no, peb tau muab cov chav sib txawv rau txhua qhov sib txawv, thiab tseem tau muab ntau lub npe phooj ywg kom haum rau peb cov phiaj xwm npe. Qhov no tau pom zoo rau cov neeg siv nrhiav kev xa tawm ntawm 100s lossis khoom siv.

Kauj Ruam 6: Teeb Txheej Txheem

Ib qho xwm txheej (lossis ceeb toom) yog ib qho kev ua uas tshwm sim thaum cov ntaub ntawv ua tiav lossis tshaj li txoj cai tsim. Piv txwv li, email lossis SMS tuaj yeem xa tau txhua lub sijhawm uas lub ntsuas hluav taws xob nres xa cov ntaub ntawv lossis qhov ntsuas kub siab tshaj qhov siab tshaj lossis qhov tsawg kawg nkaus.

Txhawm rau tsim qhov xwm txheej, thov siv kab lus hauv qab no:

Cov Txheej Txheem: Tsim Cov Ntawv Xov Xwm Txheej Txheem (SMS, Email, thiab Telegram)

Kauj Ruam 7: Qhov tshwm sim

Hauv ob peb feeb koj tau tsim qhov yooj yim DIY ntsuas qhov ntsuas kub. Tam sim no tso koj lub ntsuas qhov xav tau thiab pib ntsuas qhov kub los ntawm koj lub cuab yeej niaj hnub no!

Zoo siab hacking:)

Pom zoo: