Cov txheej txheem:

Mini-Serre: 11 Kauj Ruam
Mini-Serre: 11 Kauj Ruam

Video: Mini-Serre: 11 Kauj Ruam

Video: Mini-Serre: 11 Kauj Ruam
Video: #11 Growing a Small Vegetable Garden on my Balcony (8sqm) (2020) 2024, Hlis ntuj nqeg
Anonim
Mini-Siab
Mini-Siab
Mini-Siab
Mini-Siab

Raws li tub ntxhais kawm, Kuv muaj tus cwj pwm tsis zoo ntawm kev hnov qab yam khoom. Vim li ntawd, yog tias kuv xav cog qee hom cog, kuv ib txwm tsis nco qab txog nws thiab nws tuag vim tsis muaj leej twg saib xyuas nws.

Kuv yuav sim kho qhov teeb meem no nrog Mini-Serre. Mini-Serre yog lub tshuab ua haujlwm saib xyuas lub vaj uas xa cov ntaub ntawv ntawm ntau hom kev ntsuas uas tau teeb tsa rau lub vev xaib uas khiav ntawm Raspberry Pi. Txoj hauv kev no tus neeg siv tuaj yeem tshuaj xyuas lawv cov nroj tsuag ntawm lub vev xaib tsis hais lawv nyob qhov twg. Lub tswv yim no tau tsim los ua qhov phiaj xwm zaum kawg hauv thawj xyoo ntawm kev siv xov tooj cua thiab kev sib txuas lus, ntawm Howest Kortrijk, Belgium.

Kauj Ruam 1: Cov Khoom Siv

Cov Khoom
Cov Khoom

Txhawm rau tsim txoj haujlwm no, koj yuav xav tau cov khoom hauv qab no:

Electronics

  1. Raspberry pi 3 - cov khoom siv
  2. Cov qhob cij
  3. Txiv neej-rau-txiv neej txuas
  4. Txiv neej-rau-poj niam txuas
  5. Dallas 18B20 (ntsuas kub)
  6. Photoresistor Kev Tshawb Fawb Photosensitive Teeb Sensor
  7. YWB 3008
  8. Potentiometer
  9. LCD-zaub
  10. Resistors
  11. Xiav LED
  12. RGB LED

Casing:

13. Central Park kweekkas (https://www.brico.be/nl/tuin-buitenleven/moestuin/…) 14. Ntoo phaj (hauv qab ntawm rooj plaub) 15. Nails 16. Screws

Cov Cuab Yeej:

17. Rauj 18. Pom 19. Ntsia Hlau 20. Laum

Kauj ruam 2: Ua Circuit Court

Ua Circuit
Ua Circuit
Ua Circuit
Ua Circuit

Hauv kauj ruam 2 peb yuav ua qhov Circuit Court rau txoj haujlwm no. Qhov no yog qhov tsawg kawg nkaus uas koj xav tau yog tias koj xav kom nws ua haujlwm. Siv lub fritzing lub rooj thiab daim duab los ua daim qauv ntawm daim phiaj. Nov yog qhov uas koj xav tau tag nrho cov khoom siv hluav taws xob los ntawm theem 1.

Cov ntaub ntawv hais txog lub Circuit Court:

Peb muaj 2 lub cim txuas nrog MCP3008 uas yog lub teeb pom kev zoo thiab cov av noo noo. Qhov ntsuas kub muaj qhov tso tawm digital thiab siv GPIO-pin ntawm Raspberry Pi.

Ntxiv:

Kuv kuj tau siv LCD-zaub uas yuav ua rau nws yooj yim dua tom qab los txuas rau Raspberry Pi yam tsis tas yuav tsum txuas rau koj lub khoos phis tawj. Qhov no tsis tsim nyog tab sis nws tau pom zoo heev.

Kauj Ruam 3: Tsim Database

Tsim Database
Tsim Database

Nws yog ib qho tseem ceeb heev los khaws koj cov ntaub ntawv los ntawm cov ntsuas hauv kev teeb tsa tab sis kuj tseem muaj kev nyab xeeb. Qhov no yog vim li cas kuv thiaj txiav txim siab khaws kuv cov ntaub ntawv hauv chaw khaws ntaub ntawv. Txoj kev no tsuas yog kuv tuaj yeem nkag mus rau cov ntaub ntawv no (nrog tus as khauj tus kheej) thiab khaws nws kom zoo. Hauv daim duab saum toj no koj tuaj yeem pom kuv cov phiaj xwm los ntawm kuv cov ntaub ntawv khaws tseg thiab hauv qab cov ntaub ntawv xa tawm cov ntaub ntawv mus rau qhov program database, piv txwv li MySQL.

Database-programIt yog qhov tseem ceeb uas peb cov ntaub ntawv tuaj yeem ua haujlwm ntawm nws tus kheej los ntawm peb Raspberry Pi. Koj tuaj yeem ua qhov no los ntawm rub tawm MySQL lossis MariaDB rau Raspberry Pi. Koj xub xav ua lub hauv paus ntawm koj lub computer hauv MySQL Workbench. Tom ntej no koj xa cov ntaub ntawv no raws li tus kheej muaj cov ntaub ntawv. Tam sim no txuas rau koj li Raspberry Pi lub database ntawm MySQL Workbench thiab rov kho cov ntaub ntawv khaws cia ntawm no. Tam sim no koj muaj cov ntaub ntawv khaws cia ntawm koj li Raspberry Pi!

Kauj Ruam 4: Sau Cov Ntaub Ntawv Sensor mus rau Database

Tom qab cov chaw khaws ntaub ntawv tau khiav ntawm koj li Raspberry Pi peb xav kom peb lub ntsuas cua tuaj yeem khaws lawv cov ntaub ntawv hauv nws. Peb tuaj yeem ua qhov no los ntawm kev tsim 3 cov ntawv cais (uas tau ua hauv PyCharm). Ib qho zoo uas muaj nyob hauv PyCharm yog tias koj tuaj yeem txuas rau koj Pi thiab txoj hauv kev no koj tuaj yeem nkag mus rau koj lub database thiab sau ncaj qha rau nws. Cov ntaub ntawv kuj tseem tau nyeem ncaj qha los ntawm Raspberry Pi thiab LED's yuav ci ntsa iab raws li qhov koj xav tau.

Blue LED teeb tsa: Cov av tsis ntub txaus. RGB LED teeb ntsuab: txhua yam yog qhov zoo. RGB LED teeb liab: nws kub dhau, qhib lub ru tsev kom txias nws me ntsis. RGB LED teeb ci xiav: nws txias heev, kaw lub ru tsev yog nws qhib.

Koj tuaj yeem rub tawm txhua cov ntawv sau los ntawm kuv qhov chaw cia khoom github:

Nco tseg: Kuv siv kuv tus kheej cov ntaub ntawv nkag mus rau cov chaw khaws ntaub ntawv yog li koj yuav tau hloov nws kom haum rau koj li.

Nco tseg: Daim nplaub tshev DB1 muaj chav kawm 'database' uas tau nkag rau hauv cov cai uas yuav txuas rau koj lub database.

Kauj Ruam 5: Qhia Koj Tus IP ntawm Zaub

Qhia Koj Tus IP ntawm Zaub
Qhia Koj Tus IP ntawm Zaub

Cov zaub qhia pom IP-chaw nyob uas koj Raspberry Pi tab tom khiav, txoj hauv kev no koj tuaj yeem txuas tau yooj yim yam tsis muaj xov hlau rau koj Raspberry Pi. Kuv kuj tau sau ib tsab ntawv rau qhov no uas nyeem IP ntawm koj tus pi thiab qhia nws ntawm cov zaub (nco ntsoov tias koj GPIO-pins sib xws tsis li nws yuav tsis ua haujlwm). Raspberry Pi sau cov ntawv no cia li pib. Koj tuaj yeem ua qhov no los ntawm kev ntxiv qee qhov chaws rau rc.local cov ntaub ntawv ntawm koj li Raspberry Pi. Koj tuaj yeem mus txog ntawd los ntawm kev ntaus 'sudo nano /etc/rc.local', ua ntej kab kawg ntawm kab ntawv koj xav ntxiv 'Python3.5/home/user/filelocation &'.

Koj tuaj yeem pom cov ntawv ntawm no:

Nco tseg: qhov '&' thaum kawg, qhov no yuav ua rau cov ntawv sau ib zaug thiab nres tam sim ntawd kom lwm cov ntawv tuaj yeem ua haujlwm ib yam nkaus.

Kauj Ruam 6: Ntsuas Cov Ntsuas Hluav Taws Xob Txhua 10 feeb

Ntsuas cov Sensors Txhua 10 feeb
Ntsuas cov Sensors Txhua 10 feeb

Peb tsis xav kom peb cov ntaub ntawv khaws tseg los ntawm cov ntaub ntawv sensordata puas tau 0.001seconds, txwv tsis pub qhov no yuav ua rau nws nyuaj rau cov ntaub ntawv khaws cia nrog txhua cov ntaub ntawv nkag los thiab nws yuav tsoo. Qhov no yog vim li cas kuv thiaj ntxiv qhov scrapt rau 'crontab' ntawm Raspberry Pi. Crontab yog ib txoj haujlwm uas taug qab cov haujlwm uas tau teem tseg yog li txoj hauv kev no koj tuaj yeem yooj yim khiav cov ntawv txhua 10 feeb ib zaug.

Yuav teeb nws li cas:

Koj tuaj yeem teeb tsa qhov no los ntawm kev ntaus thawj hauv Raspberry Pi kab hais kom ua 'crontab -e', qhov no qhib tus kws kho mob rau crontab. Xaub mus rau hauv qab ntawm cov ntawv thiab ntxiv 3 kab, ib qho rau txhua qhov ntsuas.

' */10 * * * * python3.5/tsev/neeg siv/filepath/sensor1'

Nco tseg: Tus '*/10' yog 10 feeb uas peb xav kom nyob nruab nrab ntawm txhua qhov kev ntsuas. Cov cai kuv tau ntaus tom qab nws yog tus nab npawb version koj tab tom khiav thiab cov ntaub ntawv koj xav khiav yog li koj yuav tsum sau ib kab rau txhua qhov ntsuas vim tias lawv muaj nyob ntawm 3 cov ntaub ntawv sib txawv.

Kauj Ruam 7: Ua Lub Vev Xaib

Ua Lub Vev Xaib
Ua Lub Vev Xaib

Kuv ua kuv lub vev xaib hauv qhov program hu ua Atom. Nws yog qhov yooj yim heev rau siv txoj haujlwm thiab tawm tswv yim yog tias koj zoo nkauj tshiab los sau HTML thiab CSS zoo li kuv.

Koj tuaj yeem pom txhua tus lej thiab cov duab siv hauv qab no txuas:

Kuv tau ua ntej-kawg ntawm lub vev xaib hauv Visual Studio Code yog li yog tias koj tsis npaj rau kev ua HTML & CSS koj tus kheej koj tuaj yeem tsuas yog ntxiv cov ntawv rau hauv daim nplaub tshev tshiab hauv Visual Studio Code tsis yog Atom.

Kauj Ruam 8: Tsim Qhov Back-end

Sab nraub qaum thiab pem hauv ntej-kawg yuav yog yam uas ua rau muaj qee yam tshwm sim ntawm lub vev xaib peb nyuam qhuav ua. Hauv qab-kawg peb txuas rau peb cov database ib zaug ntxiv thiab tsis txhob muab cov ntaub ntawv tso rau hauv lub database. Tam sim no peb yuav nyeem tag nrho cov ntaub ntawv los ntawm cov ntsuas sib txawv thiab siv Socket. IO peb yuav xa nws mus rau peb lub hauv ntej-kawg kom peb tuaj yeem nthuav tawm nws ntawm lub vev xaib.

Koj tuaj yeem pom cov cai rau sab nraub qaum ntawm no:

Nco tseg: Peb siv chav kawm database peb siv ua ntej ua ntej yog li kuv tsis suav nrog qhov no hauv qhov chaw cia khoom no.

Kauj Ruam 9: Tsim Lub Hauv Paus-kawg

Pem hauv ntej-kawg yog qhov uas peb ua ke peb cov HTML & CSS code ua ke nrog JavaScript thiab peb Back-end. JavaScript uas kuv tau sau sim ua kom muaj kev sib txuas nrog rov qab kawg uas yuav tsum tau khiav. Tam sim no Back-end yuav xa tag nrho peb cov ntaub ntawv los ntawm cov ntsuas thiab peb tuaj yeem ua ob peb lub luag haujlwm hauv JavaScript uas kho cov ntawv HTML yog li nws haum rau peb qhov txiaj ntsig tam sim no.

JavaScript tuaj yeem pom ntawm no:

Nco tseg: nco ntsoov tias koj txuas hauv koj li HTML rau daim nplaub tshev raug ntawm qhov chaw ntawm koj li JavaScript tsis li nws yuav tsis ua haujlwm.

Kauj Ruam 10: Ua Lub Tsev Cog Khoom

Ua Tsev Ntsuab
Ua Tsev Ntsuab
Ua Tsev Ntsuab
Ua Tsev Ntsuab

Kuv yuav pob ua ntej los ntawm Brico:

Tsuas yog ua raws cov theem uas tuaj nrog pob. Tom qab qhov no ua tiav peb tsis tau npaj txhij tso peb Raspberry Pi nyob rau ntawd. Ua ntej peb yuav tsum tau ua 'hauv pem teb' lossis hauv qab rau lub Tsev Cog Khoom, koj tuaj yeem ua qhov no los ntawm kev siv lub phaj ntoo thiab ntsuas seb nws loj npaum li cas los ua kom haum. Kuv xub ua tus ncej ntoo kom cov phaj ntoo muaj ib yam dab tsi los so.

Kauj Ruam 11: Muab Txhua Yam Ua Ke

Muab Txhua Yam Ua Ke
Muab Txhua Yam Ua Ke
Muab Txhua Yam Ua Ke
Muab Txhua Yam Ua Ke
Muab Txhua Yam Ua Ke
Muab Txhua Yam Ua Ke

Peb yuav luag npaj txhij! Tsuas yog ib qib kawg no thiab koj npaj mus. Nqa Raspberry Pi thiab lub tsev cog khoom, ua ob peb qhov kom koj tuaj yeem tso lub LED hla nws, ua lub qhov rau cov zaub thiab lub qhov rau Raspberry Pi lub zog muab khoom. Muab txhua yam hauv lub tsev cog khoom, ntsaws rau Pi thiab koj tau teeb tsa! Koj tau txais koj tus kheej lub tsev cog khoom!

Pom zoo: