Cov txheej txheem:

Cog kuv: 6 Kauj Ruam (nrog Duab)
Cog kuv: 6 Kauj Ruam (nrog Duab)

Video: Cog kuv: 6 Kauj Ruam (nrog Duab)

Video: Cog kuv: 6 Kauj Ruam (nrog Duab)
Video: Tseem Ev Lub Kawm - Koos Loos 2024, Hlis ntuj nqeg
Anonim
Tsob ntoo
Tsob ntoo

Raws li feem ntau ua, Kuv nyiam muaj cov ntoo nyob ib ncig ntawm lub tsev. Hmoov tsis zoo, lawv yuav luag tas li tuag hauv ob peb lub lis piam. Yog li thaum qhov kawg ntawm kuv thawj xyoo ua tub ntxhais kawm ntawm MCT ntawm Howest Kuv tau ua lub luag haujlwm los tsim txoj haujlwm uas yuav qhia txhua yam uas kuv tau kawm txog tam sim no, Kuv xav ua qee yam uas yuav txo cov nroj tsuag tuag nyob ib ncig ntawm lub tsev. Thiab yog li Plant'm tau yug los.

Kuv tig rov qab mus rau kuv cov nroj tsuag yav dhau los thiab sim xav txog ntau yam laj thawj uas lawv tsis muaj sia nyob. Feem ntau qhov no yog vim kuv tsis nco qab ywg dej rau lawv, ywg dej ntau dhau, lossis tsis txhob cia lawv pom qhov kaj ntawm ib hnub. Nov yog qhov chaw Plant'm nqis tes ua thiab saib xyuas cov khoom no rau koj.

Khoom siv

Electronics:

  • Raspberry pi 4 + GPIO tawg
  • SD daim npav 16 GB lossis ntau dua
  • Ua kua theem sensor
  • LM35
  • Av noo noo sensor
  • LDR
  • Kev hloov pauv (BC337)
  • Dej twj
  • LED sawb
  • Breadboard + fais fab mov
  • LCD zaub
  • Muaj ntau lub jumper cables ob leeg txiv neej-txiv neej thiab poj niam-txiv neej

Khoom siv

  • Cov cawv txiv hmab qub
  • Qub rooj teeb
  • Ntsia hlau thiab ntsia liaj qhov rooj
  • Hinges
  • Ntsia
  • Kua nplaum thiab kab xev

Kauj Ruam 1: Teeb tsa Raspberry Pi

Koj tuaj yeem rub tawm cov duab xav tau rau Pi ntawm no. Kuv feem ntau xaiv qhov tsis muaj lub desktop vim kuv tsuas txuas rau Pi los ntawm PuTTY. Thaum koj tau sau daim duab rau SD daim npav, koj yuav tsum hloov pauv thiab ntxiv qee cov ntaub ntawv. Hauv cov ntawv "cmdline.txt" (tsis txhob qhib cov ntawv no hauv notepad, qhib nws hauv Notepad ++ lossis lwm yam IDE) koj yuav tsum ntxiv "ip = 169.254.10.1" thaum kawg. Qhov no yuav ua kom ntseeg tau tias koj tuaj yeem txuas rau peb lub cuab yeej hla ethernet (nco ntsoov tias koj tsis ntxiv ENTERS thaum kawg ntawm koj cov ntaub ntawv lossis koj yuav muaj teeb meem).

Tam sim no koj tuaj yeem ntxig daim npav SD, txuas Pi rau koj lub khoos phis tawj ntawm ethernet thiab khau raj Pi. Nws tuaj yeem siv sijhawm me ntsis rau Pi pib thawj zaug. Thaum koj tuaj yeem nkag mus rau qhov ntawd nrog tus neeg siv tsis raug "pi" nrog nws tus password "raspberry". Koj tuaj yeem hloov qhov no tom qab.

Ua ntej koj yuav tau hloov qee qhov kev teeb tsa. Siv "sudo raspi-config" los qhib cov ntawv qhia zaub mov teeb tsa thiab hauv no peb yuav mus rau Kev Xaiv Kev cuam tshuam. Hauv qab no peb yuav hloov qhov kev xaiv hauv qab no ntawm SPI.

Tam sim no koj tuaj yeem teeb tsa kev sib txuas wireless raws li tau piav qhia ntawm no. Tam sim no peb muaj kev sib txuas hauv is taws nem peb tuaj yeem rub tawm qee pob khoom raws li hauv qab no:

  1. "sudo apt hloov tshiab && apt upgrade -y" Qhov no yuav tau txais qhov hloov tshiab kawg rau Pi.
  2. "sudo apt install mariadb-server apache2" Cov no yuav ua haujlwm webserver thiab database feem.
  3. "sudo pip3 install Flask Flask-Cors Flask-SocketIO gevent gevent-websocket greenlet spi SPI-Pyspidev" Cov no yog qee cov sej pob uas xav tau los ua haujlwm rov qab rau txoj haujlwm no.
  4. Thiab thaum kawg "sudo apt install python3 -mysql.connector -y" txuas rau lub database

Tom ntej no peb yuav tsim tus neeg siv ntawm lub database. Siv "sudo mysql -u root" txhawm rau nkag mus rau hauv koj li MySQL server, nyob ntawm no peb yuav tsim ib tus neeg siv hu ua db_admin nrog nws tus lej nkag mus, khaws tus password no sau tseg rau lwm qhov tom qab hauv cov lus qhia. "@"%"IDENTIFIED BY" yourPasswordHere "Nrog rau kev xaiv zoo Tam sim no koj tuaj yeem mus ntsib lub vev xaib ntawm tus IP chaw nyob peb tau ntxiv ua ntej.

Kauj ruam 2: Tsim Circuit Court

Tsim lub Circuit
Tsim lub Circuit
Tsim lub Circuit
Tsim lub Circuit
Tsim lub Circuit
Tsim lub Circuit

Txhawm rau tsim lub voj voog koj tuaj yeem ua raws nrog siv cov txheej txheem thiab daim ntawv qhia zaub mov ntxiv nrog lwm cov duab.

Kauj Ruam 3: Tsim Rooj Plaub

Tsim Rooj Plaub
Tsim Rooj Plaub
Tsim Rooj Plaub
Tsim Rooj Plaub
Tsim Rooj Plaub
Tsim Rooj Plaub
Tsim Rooj Plaub
Tsim Rooj Plaub

Cov ntaub ntawv no yog ua los ntawm 4 lub thawv cawv qub, 3 ntawm uas tau tawg sib nrug. Kuv drilled qee qhov hauv rooj plaub tseem ceeb txhawm rau txuas cov zaub, teeb, txuas txuas txuas, thiab ntsuas kub los ntawm.

Siv qee qhov khawm, Kuv txuas 2 lub hau. Ib qho los muab kev nkag mus rau cov chaw tso dej. Hauv lwm qhov, Kuv txiav tawm lub qhov rau kuv cov nroj tsuag kom loj tuaj, thiab 2 qhov ntxiv rau lub teeb pom kev kom dhau mus. Nws kuj muaj qhov txiav tawm rau lub teeb.

Txhawm rau kom cov khoom siv hluav taws xob cais los ntawm dej, Kuv tsim qib thib ob rau cov dej tso dej kom zaum ntawm siv lwm tus ntoo thiab 4 ntsia hlau thiab ntsia hlau. Kuv txiav qee qhov ntxiv hauv qhov no rau cov thaiv thiab muab qee chav ntxiv kom dhau lub teeb.

Raws li lub hauv paus rau lub teeb, Kuv siv lub teeb rooj qub uas tsis ua haujlwm ntxiv lawm. Kuv tshem tag nrho cov ntu sab hauv vim tias lawv tsis xav tau ntxiv lawm. Tom qab ntawd kuv tau muab tso rau hauv qhov chaw ntawm cov hlua coj thiab txuas 2 lub raj hlau nrog qee qhov PVC tubing thiab muaj cov kua nplaum ntau.

Kauj ruam 4: Txoj Cai

Koj tuaj yeem pom cov cai ntawm no. Tsuas yog rub tawm nws.

Tam sim no mus rau tso cov ntaub ntawv. Luam tag nrho cov ntaub ntawv hauv "Code/Frontend" nplaub tshev rau hauv "/var/www/html" ntawm Pi. Cov no yog cov ntaub ntawv rau lub vev xaib. Yuav muaj feem ntau yuav yog cov ntaub ntawv hu ua "index.html" hauv daim nplaub tshev no, koj tuaj yeem tshem tawm qhov ntawd. Cov ntaub ntawv hauv "Backend" nplaub tshev tuaj yeem tso rau hauv daim nplaub tshev tshiab hauv "home/pi" directory. Koj yuav tsum tau siv koj tus kheej tus lej cim thiab cov npe siv hauv "config.py".

Txhawm rau kom nws pib thaum koj ntsaws rau hauv, peb yuav tsum tau ua nws qhov kev pabcuam. Koj tuaj yeem kawm paub teeb tsa cov kev pabcuam ntawm no. Koj yuav tsum tsim cov ntawv hauv daim nplaub tshev "/etc/systemd/system". Hauv daim ntawv no theej thiab luam cov hauv qab no:

[Chav]

Nqe lus piav = Plant'm

Tom qab = network.target

[Kev pabcuam]

ExecStart =/usr/bin/python3 -u app.py

WorkingDirectory =/home/ine/project1

StandardOutput = qub txeeg qub teg

StandardError = qub txeeg qub teg

Rov pib dua = ib txwm

User = ib

[Nruab]

WantedBy = ntau-user.target

Koj yuav tsum tau hloov Chaw Ua Haujlwm Cov Ntaub Ntawv mus rau qhov chaw uas koj khaws cov ntaub ntawv backend thiab cov neeg siv rau koj tus kheej lub npe siv. Thaum koj tau ua tiav uas siv "sudo systemctl pib myscript.service" los ntsuas seb qhov kev pabcuam ua haujlwm li cas. Yog tias nws ntaus "sudo systemctl pab kom myscript.service" kom nws pib cia li pib dua.

Kauj ruam 5: Teem Up Database

Kev teeb tsa lub Database
Kev teeb tsa lub Database

Txog qhov no, peb yuav siv MySQL Workbench. Pib tawm koj yuav tsim kev sib txuas tshiab rau pi. Koj tuaj yeem pom kuv cov kev teeb tsa hauv qhov screenshot nrog. Tsuas yog tsis txhob hnov qab siv koj tus kheej lub npe siv thiab tus lej zais. Thaum koj tau ua tiav hauv qhov chaw nias "Test txuas" kom paub tseeb tias nws ua haujlwm.

Thaum qhov kev txuas tau ua tiav, mus tom ntej thiab txuas. Tam sim no peb yuav siv cov ntawv hauv "Database-export" nplaub tshev. Qhib cov ntaub ntawv SQL thiab khiav nws. Qhov no yuav tsim cov ntaub ntawv thiab tag nrho nws cov ntxhuav. Kuv kuj tau ntxiv hauv qee cov ntaub ntawv xeem kom pom hauv lub vev xaib.

Kauj Ruam 6: Saib Cov Nroj Tsuag Loj Hlob

Saib Cov Nroj Tsuag Loj Hlob
Saib Cov Nroj Tsuag Loj Hlob
Saib Cov Nroj Tsuag Loj Hlob
Saib Cov Nroj Tsuag Loj Hlob

Nrog txhua yam ua tiav, tam sim no peb muaj txoj haujlwm ua haujlwm uas yuav saib xyuas peb cov nroj tsuag.

Yog tias koj ntsib teeb meem, muaj lus nug lossis lus qhia, tsis txhob tawm lus. Kuv yuav sim rov qab los rau koj sai li kuv tuaj yeem ua tau.

Pom zoo: