Cov txheej txheem:
- Kauj Ruam 1: Txuas Cov Khoom Kho Vajtse rau Pi
- Kauj Ruam 2: Coding Cov Txheej Txheem Tseem Ceeb
- Kauj Ruam 3: Tsim Database
- Kauj ruam 4: Khoos phis tawj khoos phis tawj
Video: Beargardian: 5 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:29
Hav cov menyuam rau tsev kawm ntawv Kuv xav tau lub tswv yim rau ib qhov project. Yog li kuv tau xav, nws yuav tsum yog qhov haujlwm nrog raspberry pi thiab nws yog hauv zos. Mam li nco dheev kuv muaj lub tswv yim zoo thiab tsis nug kuv li cas kuv tau txais lub tswv yim ntawd tab sis kuv xav txog kev hloov kho rau tus saib xyuas menyuam. Tsuas yog xav txog qhov thib ob txog lub tswv yim ntawd, cov menyuam saib feem ntau tsuas muaj lub luag haujlwm los mloog tus menyuam chav.
Cov yam ntxwv
- Lub teeb me me qhia nrog kho xim
- Lub koob yees duab uas qhia koj cov duab nyob
- Tus hais lus los ua suab paj nruag
- Sensors los ntes tus menyuam txav
- Txhua yam uas qhia ntawm lub vev xaib
Cov ntaub ntawv luv
Letme piav qhia qhov no hauv luv luv version. Yog li peb xav tau lub vev xaib thiab rau qhov haujlwm no kuv siv Flask, peb kuj xav tau lub hauv paus thiab kuv siv mysql, kuj yog tsab ntawv uas ua haujlwm kho vajtse thiab qhov no yog nrog nab hab sej (3) thiab thaum kawg peb xav tau teeb tsa server uas yuav yog nginx ntawm PI.
Peb xav tau dab tsi
- Lub Raspberry Pi 3
- Cov kauj ruam 28BYJ
- Tus tsav tsheb kauj vab ULN2003 stepper module
- Ib rgb coj nrog 3 tus tiv thaiv 330Ohm
- Pi NoIR lub koob yees duab V2
- Ultrasonic sensor HC-SR04
- Lub micro module los ntawm ardiuno
- MAX 98357 UA
- Tus neeg hais lus 8Ohm
- Thiab tsis txhob hnov qab yuav tus dais
Teeb raspberry pi ----------------------------------------------- ----------------------------------------------------------------------- ------------------------------ ua tsaug
Thaum xub thawj peb yuav tsum teeb tsa Pi. Pib twb nkag rau ntawm putty, yog tias koj tsis muaj putty Kuv xav kom koj rub tawm qhov no, tsuas yog ntaus koj tus ip zoo li qub ntawm Pi nrog ssh thiab koj mus nrog nws. Yog tias koj yuav tsum teeb tsa koj li Raspberry Pi ces kuv tau txais xov xwm tsis zoo, Kuv tsis piav qhia qhov no hauv qhov haujlwm no.
Nruab pob
sudo apt hloov tshiab
sudo apt install -y python3-venv python3-pip python3-mysqldb mysql-server uwsgi nginx uwsgi-plugin-python3
Ib puag ncig virtual
python3 -m pip nruab -hloov kho pip setuptools log virtualenv
mkdir {koj daim ntawv teev npe} && cd {koj qhov project foldname} python3 -m venv --system-site-packages env source env/bin/qhib cov nab npawb -m pip nruab mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask- MySQL mysql-connector-python passlib
Tam sim no koj yuav tsum clone qhov chaw cia khoom git hauv koj daim ntawv tais ceev tseg
github.com/NMCT-S2-Project-I/Project-I.git
Yog tias koj saib hauv koj cov phiaj xwm phiaj xwm koj yuav tsum pom 5 daim nplaub tshev
- conf
- ua env
- sensor
- sql ua
- web
Database
sudo systemctl xwm txheej mysql
ss -lt | grep mysql sudo mysql
tsim ib tus neeg siv hauv database nrog txhua txoj cai thiab ua koj li database
tsim cov neeg siv 'neeg siv'@'localhost' txheeb xyuas los ntawm 'tus password';
tsim database yourdatabasename; muab tag nrho cov cai hauv koj li databasename.* rau 'user'@'localhost' nrog rau kev xaiv;
Conf files rau server
Hauv uwsgi-flask.ini koj hloov 'module = …' rau 'module = web: app' thiab txoj hauv kev rau koj lub virtualenv uas koj tau tsim. Hauv lwm cov ntaub ntawv koj yuav tsum hloov txoj hauv kev mus rau qhov tseeb ntawm txoj hauv kev ntawm koj phau ntawv teev npe.
Thaum koj xam pom qhov ntawd koj tuaj yeem teeb tsa cov ntawv hauv qhov chaw raug.
sudo cp conf/project1-*. service/etc/systemd/system/
sudo systemctl daemon-reload sudo systemctl pib project1-* sudo systemctl xwm txheej project1-*
tam sim no peb yuav tsum teeb qhov no muaj
sudo cp conf/nginx/etc/nginx/sites-available/project1
sudo rm/etc/nginx/sites-enabled/default sudo ln -s/etc/nginx/sites-available/project1/etc/nginx/sites-enabled/project1 sudo systemctl restart nginx.service sudo nginx -t
Yog tias txhua yam ua tau zoo koj yuav tsum nyob zoo nrog lub ntiaj teb nrog cov lus txib no
wget -qO - localhost
Ua tiav! Zoo, qhov ntawd yog rau ib feem kom tso cai rau koj ua haujlwm ntawm…
Kauj Ruam 1: Txuas Cov Khoom Kho Vajtse rau Pi
siv BCM
audio MAX 98357A
- HLB to GPIO 18
- Cov ntaub ntawv rau GPIO 21
- HLB to GPIO 19
lub teeb
- liab rau GPIO 17
- ntsuab rau GPIO 27
- xiav rau GPIO 22
lub cev muaj zog module ULN2003
- pin 1 to GPIO 5
- pin 2 to GPIO 6
- pin 3 to GPIO 13
- pin 4 to GPIO 26
me me
D0 rau GPIO 21
ultrasonic qib sensor
- xa mus rau GPIO 16
- ncha mus rau GPIO 20
Kauj Ruam 2: Coding Cov Txheej Txheem Tseem Ceeb
Kuv tsis nkag mus rau cov ntsiab lus ntawm no tab sis koj tuaj yeem txheeb xyuas kuv tus lej hauv github.
Txhawm rau pib nrog kuv tau ua kuv li html thiab css, qhov ntsuas, nkag mus, sau npe, tshuaj ntsuam hauv tsev, nkauj, ntxiv nkauj, ntxiv suab, teeb, lub koob yees duab, teeb tsa lub koob yees duab, sensor, nplooj ntawv dashboard. Cov ntaub ntawv html yuav tsum muaj nyob hauv tus qauv thiab cov ntaub ntawv css hauv cov ntawv zoo li qub/css. Koj tuaj yeem hloov kho tus css zoo li koj xav tau.
Yog tias koj ua tiav ntu no koj yuav tsum teeb tsa koj lub hwj. Flask yog ib qho yooj yim siv tsuas yog piv txwv ntawm lub ntiaj teb nyob zoo
# ntshuam hwj chim thaum xub thawj
los ntawm cov raj ntshuam * @app.route ('/') def index (): rov render_template ('index.html')
Tam sim no hauv kuv tus lej qhov no twb tau ua tiav lawm, tsuas yog qhov koj yuav tsum tau ua yog hloov cov neeg siv database thiab tus lej zais rau qhov ntawd los ntawm koj thiab ofcourse ua tib lub database uas koj kuj tuaj yeem pom hauv github.
Kauj Ruam 3: Tsim Database
Txog cov kiv cua tiag tiag kuv yuav qhia koj li cas los tsim tib cov ntaub ntawv.
Yog li ua ntej peb yuav tsum tsim cov ntaub ntawv yog tias koj tsis nyob hauv qib ib.
tsim database beargardian;
Thaum koj ua qhov no koj tsim cov ntxhuav hauv mysql workbench lossis phpadmin
cov neeg siv lub rooj muaj
- userID
- thawj lub npe
- lub xeem
- npe menyuam yaus
- password nrog sha1
- userfolder
- playmusic (int)
- teeb pom kev zoo (int)
- playrecording (int) cov
music table muaj
- musicID
- nkauj
- txoj kev
- userfolder
- xwm txheej
- ntim
kaw lub rooj muaj
- kaw ID
- txoj kev
- userfolder
- sij hawm
- hnub
cov lus xim muaj
- colorID
- liab
- ntsuab
- xiav
- ci ntsa iab
- userID
dais rooj muaj
- bearID (zauv (8))
- userID default null
- bearname
sensor rooj muaj
- sensorID
- nrug deb
- me me
- bearID
- sij hawm
- hnub
- pw tsaug zog
Yog li tam sim no koj tau tsim cov ntaub ntawv ua tiav, cia peb mus rau kho vajtse.
Kauj ruam 4: Khoos phis tawj khoos phis tawj
Kuv yuav tau qhia me ntsis ntawm cov cai thiab qhia koj vim li cas kuv thiaj ua li ntawd.
Txhawm rau pib nrog kuv siv xov xov, dab tsi yuav tsum yog nyob hauv txoj haujlwm no. Dab tsi yog xov, hmmm cov lus nug zoo! Zoo hem nyob hauv nab hab sej yog kom ua haujlwm ntau lub program ib zaug. Yog li yog koj piv txwv hloov xim koj tuaj yeem sau tseg. Nws yooj yim siv tsis txhob txhawj.
ntshuam _threaddef function_name (ib yam, ib yam dab tsi_else): chaws kom khiav
_thread.start_new_thread (function_name, tuple_with_the_functions_variables)
Yog tias koj saib kuv qhov program koj pom logger.info ('…'). Nov yog qhov ua haujlwm luam tawm tab sis zoo dua, vim ntawm Pi koj tsis tuaj yeem luam cov khoom tawm yog li kuv ua cov ntawv thiab luam tawm hauv ntawd. Yoe tuaj yeem teev cov ntaub ntawv teev cia nrog tus lej no.
logger = logging.getLogger (_ npe _) logger.setLevel (logging. INFO) # tsim cov ntaub ntawv tus tuav tuav = logging. FileHandler ('logger.log') handler.setLevel (logging. INFO)
# tsim cov ntawv teev npe
formatter = logging. Formatter (' %(asctime) s - %(name) s - %(message) s') handler.setFormatter (formatter)
# ntxiv cov neeg lis haujlwm rau lub cav ntoo
logger.addHandler (tus tuav tes)
logger.info ('pib kho vajtse / n ---------------------------------------')
ntxiv hauv txoj cai nws tus kheej kuv piav txhua yam.
Pom zoo:
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom - Cov Kauj Ruam ntawm Kauj Ruam: 4 Kauj Ruam
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom | Cov kauj ruam ib kauj ruam: Hauv txoj haujlwm no, kuv yuav tsim qhov yooj yim Arduino Tsheb Rov Qab Tsheb Nres Tsheb Nres Sensor Siv Arduino UNO thiab HC-SR04 Ultrasonic Sensor. Qhov no Arduino raws Lub Tsheb Rov Qab ceeb toom tuaj yeem siv rau Kev Tshawb Fawb Txog Tus Kheej, Robot Ranging thiab lwm yam
Tsev Automation Kauj Ruam ntawm Kauj Ruam Siv Wemos D1 Mini Nrog PCB Tsim: 4 Kauj Ruam
Tsev Automation Kauj Ruam Ib Leeg Siv Wemos D1 Mini Nrog PCB Tsim: Tsev Automation Kauj Ruam los ntawm Kauj Ruam siv Wemos D1 Mini nrog PCB Tsim cov tub ntxhais kawm ntawv qib siab. Tom qab ntawd ib tus ntawm peb cov tswv cuab tuaj
RC Taug Qab Neeg Hlau Siv Arduino - Kauj Ruam Ib kauj ruam: 3 Kauj Ruam
RC Tracked Robot Siv Arduino - Kauj Ruam Ib Nrab: Hav guys, Kuv rov qab los nrog lwm tus neeg hlau txias chassis los ntawm BangGood. Vam tias koj tau dhau los ntawm peb cov phiaj xwm yav dhau los - Spinel Crux V1 - Tus Cwj Pwm Tswj Tus Neeg Hlau, Spinel Crux L2 - Arduino Xaiv thiab Muab Neeg Hlau nrog Robotic caj npab thiab Badland Braw
Kawm Yuav Ua Li Cas Kos Tus Tswm Ciab - Kauj Ruam Ib Kauj Ruam: 6 Kauj Ruam
Kawm Yuav Ua Li Cas Thiaj Li Tswmciab - Kauj Ruam Ib kauj ruam: Cov tswm ciab no siv sijhawm 10 feeb los kos yog tias koj ua raws kuv cov kauj ruam ua tib zoo
DIY Arduino Robotic Arm, Kauj Ruam ntawm Kauj Ruam: 9 Kauj Ruam
DIY Arduino Robotic Arm, Kauj Ruam ntawm Kauj Ruam: Cov ntawv qhia no yog qhia koj yuav tsim lub Caj Npab Caj Npab ntawm koj tus kheej li cas