Cov txheej txheem:

Tsis Siv Neeg Daim Npav Xa Ntawv: 7 Kauj Ruam
Tsis Siv Neeg Daim Npav Xa Ntawv: 7 Kauj Ruam

Video: Tsis Siv Neeg Daim Npav Xa Ntawv: 7 Kauj Ruam

Video: Tsis Siv Neeg Daim Npav Xa Ntawv: 7 Kauj Ruam
Video: Plab Plab Ntswg..(Pluav Pluav Ntswg) Maiv Twm New Song 2023-2024 2024, Kaum ib hlis
Anonim
Tsis Siv Neeg Daim Npav Muag Khoom
Tsis Siv Neeg Daim Npav Muag Khoom

Kuv tau xaiv tus xa daim npav ntse raws li kuv thawj qhov haujlwm vim kuv nyiam ua si game card. Qhov kuv tsis nyiam tshaj plaws yog kev ua daim npav. Koj yuav tsum nco ntsoov rau txhua qhov kev ua si pes tsawg daim npav txhua tus neeg tau txais. Qhov ntawd ua rau tsis meej pem thaum koj paub ntau daim npav ua si. Kuv txoj haujlwm tseem yuav pab cov neeg uas muaj teeb meem nrog kev faib daim npav zoo li cov neeg laus thiab cov neeg uas muaj mob Parkinson.

Khoom siv

  • 1 Raspberry Pi (Kuv siv Raspberry Pi 4)
  • SD daim npav (16GB pom zoo)
  • 1 Daim ntawv tawm rau Raspberry Pi (T-thooj)
  • 2 daim ntawv qhia zaub mov
  • 1 Cov khoom siv hluav taws xob rau lub thawv ntawv, 5V thiab 3V3
  • 1 LCD zaub
  • 1 Potentiometer
  • 1 MPU6050 (ntsuas lub ntsuas thiab ntsuas lub ntsej muag)
  • 1 NPN transistors
  • 1 PCF8574N I/O nthuav dav
  • 1 stepper tsav
  • 1 ULN2003 pawg thawj coj saib xyuas kev tswj kom tsis txhob tsav lub cav
  • 1 HC-SR04 ultrasonic sensor
  • 15V DC tsav
  • 1 ib diode
  • 6 470 Ohm resistors
  • 4 10K Ohm resistors
  • Hluav taws xob xaim txuas txhua yam

Muaj txiaj ntsig kom muaj thaum ua:

  • Soldering hlau
  • Solder
  • Dremel lossis jig pom (qee yam los txiav ntoo thiab yas yas)

Software:

  • Putty
  • MySQL workbench
  • Win32 Disk Imager
  • Code editor (Kuv pom zoo Visual Studio Code)
  • WinSCP
  • Raspbian duab

Kauj Ruam 1: Npaj Rasperry Pi

Ua ntej peb yuav tsum npaj Raspberry Pi ua ntej peb ua lwm yam. Vim tias txhua yam yuav khiav ntawm Pi yog li qhov no yog ib qho tseem ceeb tshaj plaws ntawm daim npav faib khoom.

Kev teeb tsa:

Rub tawm Raspbian duab los ntawm

  1. Rub tawm ZIP-file
  2. Luam tawm ZIP-cov ntaub ntawv qhov twg koj tuaj yeem pom nws yooj yim
  3. Qhib Win32 Disk Imager thiab xaiv cov duab rho tawm
  4. Xaiv daim npav SD hauv cov ntawv qhia zaub mov nco thiab nyem sau
  5. Thaum cov txheej txheem sau tiav koj tuaj yeem kaw Win32 Disk Imager

Tam sim no peb yuav tsum ua ob peb yam ntxiv ua ntej peb tuaj yeem txuas rau Pi

  1. Nkag mus rau khau raj nplaub tshev ntawm SD card
  2. Qhib cov ntaub ntawv cmdline.txt
  3. Ntxiv 'ip = 169.254.10.1' tom kawg ntawm kab sib cais nrog qhov chaw
  4. Txuag thiab tawm cov ntawv
  5. Tsim hauv tib phau ntawv hu ua ssh thiab tshem qhov txuas ntxiv (qhov no yuav pab tau ssh ntawm thawj khau raj yog li peb tuaj yeem txuas rau Pi)
  6. Kev nyab xeeb tshem tawm daim npav SD thiab muab tso rau hauv Pi

Tam sim no peb tuaj yeem txuas rau Pi:

  1. Lob tus ethernet cable thiab ntxig ib kawg hauv Pi thiab lwm qhov kawg hauv koj lub computer
  2. Qhib Putty
  3. Nkag mus rau 169.254.10.1 hauv tus tswv lub npe teb
  4. Nco ntsoov xaiv SSH thiab chaw nres nkoj yog 22
  5. Nyem qhib
  6. Yog tias koj tau txais kev ceeb toom koj tuaj yeem txuas ntxiv thiab tsis quav ntsej nws
  7. Lub npe siv yog pi thiab tus password yog raspberry

Kev teeb tsa thiab teeb tsa software:

Qhib raspi-teeb tsa nrog cov lus txib hauv qab no:

sudo raspi-teeb tsa

Xaiv qhov kev xaiv thib 5: Kev xaiv cuam tshuam

Pab kom SPI thiab I2C

Lov tes taw cov hauv qab no hauv qhov kev xaiv thib 3: Kev xaiv khau raj:

  • Txau npo
  • Xaiv cli rau kev pib thiab tsis yog desktop

Kev teeb tsa Wifi:

Wifi muaj txiaj ntsig yooj yim mus rau lub vev xaib. Xyuas kom koj muaj koj li ntawv pov thawj wifi kaw.

Txhawm rau teeb tsa wifi peb xav tau qee yam:

Ntxiv koj lub wifi los ntawm kev siv cov lus txib no thiab hloov SSID thiab PASSWORD rau koj cov ntaub ntawv:

sudo wpa_passphrase "SSID" "PASSWORD" >> /etc/wpa_supplicant/wpa_supplicant.conf

Ua cov lus txib no kom rov teeb tsa koj lub wifi:

sudo wpa_cli cov

Xaiv qhov tseeb interface:

wb wl0

Configure tus interface:

rov tsim dua tshiab

Txheeb xyuas yog tias kev rov tsim kho tau ua tiav nrog cov lus txib no:

ip aw

Yog tias koj pom tus IP-chaw nyob ntawm wlan0 interface ces txhua yam tau teeb tsa.

Hloov kho qhov kev ua haujlwm

Hloov kho cov txheej txheem ua haujlwm nrog 2 cov lus txib no:

sudo apt hloov tshiab

sudo apt puv-txawj tej yam ntxiv

Teeb tsa MariaDB:

Txhim kho Apache Webserver:

sudo apt nruab apache2 -y

lnstalling MariaDB server:

sudo apt nruab mariadb -server -y

Tam sim no peb yuav tsum tau reboot:

sudo rov pib dua

Nws tau pom zoo kom ruaj ntseg rau MariaDB kev teeb tsa. Koj tuaj yeem ua nws los ntawm kev ua cov lus txib no:

sudo mysql_secure_installation

Ua ntej koj yuav raug nug rau tus lej nkag mus tam sim no tab sis lub hauv paus teeb tsa tsis muaj ib qho yog li nias nkag mus.

Tom ntej no koj yuav raug nug yog tias koj xav teeb tus password hauv paus, ntaus y. Nco ntsoov koj tuaj yeem nco qab tus password!

  • Sau y tshem tawm cov neeg siv tsis qhia npe
  • Nkag mus y txhawm rau lov tes taw lub hauv paus nkag mus deb
  • Nkag mus y tshem tawm cov ntawv xeem thiab nkag mus rau nws
  • Sau y txhawm rau rov ua dua priveleges

Koj qhov kev teeb tsa MariaDB yuav tsum muaj kev nyab xeeb!

Tam sim no peb tuaj yeem tsim tus neeg siv tshiab:

Nkag mus rau mysql plhaub nrog cov lus txib no:

sudo siv mysql

Tsim tus neeg siv nrog lub npe siv mysql thiab tus password (your_password) cov lus txib hauv qab no:

tsim cov neeg siv mysql@localhost txheeb xyuas los ntawm 'your_password';

muab tag nrho cov priveleges ntawm *. * rau mysql@localhost;

NTSEEG NTAWV QHOV TSEEB;

Tawm ntawm lub plhaub mysql nrog cov lus txib no:

tawm;

Nab hab sej pob:

Nab hab sej yuav tsum tau teeb tsa tshwj tsis yog tias koj xaiv Lite version:

sudo apt nruab python3-pip

Peb xav tau tus nqi Python zoo, koj tuaj yeem txhim kho lawv txhua tus nrog cov lus txib hauv qab no:

pip3 teeb tsa mysql-txuas-sej-flask-socketio flask-cors gevent gevent-websocket

Tam sim no peb yuav tsum rov pib dua ib zaug ntxiv

sudo rov pib dua

Kauj Ruam 2: Teeb Pom Visual Studio Code thiab MySQL Workbench

Txuas mus rau Pi nrog MySQL Workbench:

Qhib MySQL Workbench

Ua qhov txuas tshiab rau Pi nrog cov ntaub ntawv hauv qab no:

  • Kev sib txuas lub npe: Raspi
  • Txoj Kev Sib Txuas: Txuj TCP/IP hla SSH
  • SSH Hostname: IP-chaw nyob ntawm Pi

Koj tuaj yeem tau txais IP-chaw nyob nrog cov lus txib no:

ip aw

  • SSH Username: pib
  • MySQL Hostname: 127.0.0.1
  • MySQL server Port: 3306
  • Tus neeg siv lub npe: mysql

Nyem ok thiab sau tus password rau tus neeg siv pi thiab tom qab ntawd nkag tus password rau tus neeg siv mysql.

Teeb tsa Visual Studio Code:

Qhib Visual Studio Code

Nruab 2 qhov txuas ntxiv no:

  • Tej thaj chaw deb - SSH
  • Tej thaj chaw deb - SSH: Kho cov ntaub ntawv teeb tsa

Nias hauv Visual Studio Code F1 thiab ntaus hauv ssh

Xaiv Chaw Nyob SSH: Ntxiv SSH tus tswv tsev tshiab

Sau hauv ssh pi@IP-address

Hauv cov kauj ruam tom ntej nias sau

Tam sim no kev sib txuas tau ua rau Pi. Koj tuaj yeem txuas rau Pi los ntawm kev nias F1 thiab xaiv txuas mus rau Tus tswv chaw deb.

Sau tus password kom Visual Studio Code nkag tau mus rau Pi.

Ib qho ntxiv: Nruab Python txuas ntxiv ntawm lub tshuab nyob deb kom koj tuaj yeem yooj yim khiav thiab debug code.

Kauj Ruam 3: Daim Duab Fritzing

Fritzing Daim duab
Fritzing Daim duab
Fritzing Daim duab
Fritzing Daim duab
Fritzing Daim duab
Fritzing Daim duab

Hauv cov kauj ruam no kuv yuav piav qhia qhov Circuit.

Cov duab qhia saum toj no yog ua nrog Fritzing.

DC lub cev muaj zog:

Txuas GPIO 18 mus rau lub hauv paus ntawm tus neeg sau khoom, tus lej nruab nrab ntawm tus npn transistor. Txuas hauv av ntawm lub cav mus rau tus neeg sau los ntawm transistor thiab lub zog ntawm lub cav mus rau 5V. Txuas hauv av ntawm transistor mus rau kab hauv av. Txuas lub diode hauv qhov thaiv hla lub cav kom nws thaiv qhov currunt los ntawm ntws ncaj qha mus rau transistor.

Stepper lub cev muaj zog:

Txuas tus tsav tsheb mus rau pawg tswj hwm. Ntawm pawg tswj hwm muaj ib sab pins txuas 5V thiab hauv av. Lwm tus pin yog tswj pins. Cov pins no tswj cov hlau nplaum hauv lub cav kom nws tig tau. Txuas cov pins no mus rau GPIO 12, 16, 20 thiab 21 ntawm Raspberry Pi.

HC-SR04 Ultrasonic:

Qhov ntsuas no tuaj yeem ntsuas qhov nrug mus txog 4.5 meters siv lub suab.

Txuas tus VCC tus pin mus rau 5V, tus pin ua rau GPIO 25, tus ncho tus pin nrog tus tiv thaiv ntawm 470 Ohm rau GPIO 24 thiab hauv av nrog tus tiv thaiv ntawm 470 Ohm rau hauv av.

MPU6050:

Txuas VCC tus pin rau 3V3, hauv av rau hauv av, scl rau scl ntawm Pi thiab sda rau sda ntawm Pi. Txog qhov ntsuas no kuv siv I2C los tswj nws. Koj tuaj yeem nyeem ntxiv txog nws ntawm no. Nov yog cov lus piav qhia yooj yim: Tus Pi yog tus tswv thiab MPU6050 yog tus qhev. Los ntawm kab kab scl Pi tswj lub sijhawm thiab kab sda tau siv los xa cov ntaub ntawv los ntawm tus tswv mus rau tus qhev lossis los ntawm tus qhev mus rau tus tswv. Tsuas yog tus tswv tuaj yeem pib xa cov ntaub ntawv.

Lub teeb nyob ntawm tus tiv thaiv:

Txhawm rau kom nyeem tau raug los ntawm LDR Kuv siv MCP3008 nti. Qhov no ua kom ntseeg tau tias kev nyeem los ntawm ldr ruaj khov thiab raug hloov pauv los ntawm analog rau digital cov cim.

Txuas 3V3 rau ib sab ntawm ldr nrog tus tiv thaiv ntawm 10K Ohm nruab nrab ntawm nws. Nruab nrab ntawm ldr thiab tus tiv thaiv txuas cov xov hlau mus rau channel 0 ntawm MCP3008. Tom qab ntawd txuas lwm sab ntawm ldr rau hauv av.

LCD zaub:

Koj tuaj yeem siv lub vijtsam LCD tsis muaj PCF8574 tab sis vim tias GPIO pins ntawm Pi raug txwv Kuv siv PCF8574 los cawm qee tus GPIO pins. Koj kuj tseem tuaj yeem siv cov npe hloov pauv tab sis kuv nyiam PCF8574. Koj tuaj yeem tswj hwm PCF8574 nrog SMbus raws tu qauv tab sis kuv tau sau kuv tus kheej chav kawm los tswj nws. Lub potentiometer tswj qhov sib piv.

LCD zaub pins:

  • VSS mus rau hauv av
  • VDD to 5V
  • V0 rau tus pin sib txawv ntawm cov potentiometer
  • RS mus GPIO 13
  • R/W rau hauv av vim tias kuv tsuas yog sau rau cov zaub thiab tsis nyeem
  • E to GPIO 19
  • DB0 rau P0 ntawm PCF
  • DB1 to PEB
  • DB2 to PEB
  • DB3 to PEB
  • DB4 to PEB
  • DB5 to PEB
  • DB6 to PEB
  • D7 to PEB
  • LED+ rau 5V
  • LED- rau hauv av

PCF8574 tus pin:

  • A0 rau hauv av
  • A1 rau hauv av
  • A2 rau hauv av
  • Av rau hauv av
  • VCC to 5V
  • SDA to CSY 27
  • SCL rau GPIO 22 nrog tus tiv thaiv ntawm 330 Ohm

Koj yuav tsis muaj LED+ thiab LED- nyob ntawm seb hom zaub twg koj tau txais. LED+ thiab LED- yog rau lub teeb pom kev zoo.

Txuas qhov zoo ntawm lub hwj chim rau 5V thiab hauv av rau hauv av.

Nco ntsoov koj siv Pull-up resistors!

Kauj ruam 4: Code ntawm Github

Koj tuaj yeem pom txhua qhov cai tsim nyog ntawm kuv Github.

Nplaub tshev project1:

Daim nplaub tshev no muaj tag nrho cov cai rau nraub qaum. Hauv cov ntawv Klasses yog txhua chav kawm los tswj hwm kho vajtse.

Cov ntawv khaws cia muaj 2 cov ntaub ntawv: Database.py thiab DataRepository.py. Database.py tswj kev sib txuas rau lub database thiab ua haujlwm cov lus nug. DataRepository.py muaj tag nrho cov lus nug xav tau rau lub xaib.

App.py yog cov ntaub ntawv tseem ceeb ntawm cov backend. Cov ntaub ntawv no pib tsis siv neeg thaum Pi khau raj.

Config.py muaj qee qhov teeb tsa los txuas rau lub database. Nco ntsoov tias koj ua cov ntawv no nrog koj tus kheej cov ntaub ntawv.

Koj tuaj yeem tso daim nplaub tshev no nyob txhua qhov chaw hauv koj phau ntawv teev npe tsev.

Nplaub tshev html:

Cov nplaub tshev no muaj tag nrho cov ntaub ntawv rau ntawm lub xaib, lub ntsej muag.

  • Lub nplaub tshev muaj cov ntaub ntawv rau kev teeb tsa ntawm lub xaib.
  • Fonts muaj cov fonts siv ntawm lub xaib.
  • Tsab ntawv muaj tag nrho cov ntaub ntawv Javascript los ua kom lub xaib muaj zog

Cov nplaub tshev no yuav tsum nyob hauv daim nplaub tshev/var/www/html

Koj tuaj yeem luam cov ntawv lossis ntawv tais ceev tseg nrog cov lus txib no:

sudo mv/txoj kev/mus/tam sim no/phau ntawv teev npe/txoj kev/mus/qhov chaw/cov npe

Txhawm rau mus rau lub xaib hom hauv koj tus browser IP-chaw nyob tshwm ntawm LCD zaub.

Kauj Ruam 5: Cov Qauv Txheej Txheem Zoo Li Cas

Cov Qauv Txheej Txheem Zoo Li Cas
Cov Qauv Txheej Txheem Zoo Li Cas

Hauv theem no peb tab tom yuav ntshuam cov ntaub ntawv.

  1. Txuas rau koj li Raspberry Pi nrog MySQL Workbench
  2. Nyem rau Server -> Cov Ntaub Ntawv Ntshuam
  3. Xaiv Ntshuam Tus Kheej Cov Ntaub Ntawv
  4. Hauv daim nplaub tshev Database-export los ntawm Github muaj cov ntaub ntawv sql hu ua dump_project1.sql
  5. Xauj rau cov ntawv no thiab nyem pib ntshuam

Qhov ntawd yog nws. Tam sim no Pi tuaj yeem nkag mus rau lub hauv paus yog tias nws muaj cov ntaub ntawv raug.

Kauj Ruam 6: Cov Ntaub Ntawv rau Tus Muag Khoom Daim Npav

Case rau Daim Npav Muag Khoom
Case rau Daim Npav Muag Khoom
Case rau Daim Npav Muag Khoom
Case rau Daim Npav Muag Khoom
Case rau Daim Npav Muag Khoom
Case rau Daim Npav Muag Khoom

Hauv qib no kuv yuav piav qhia qhov kuv tau siv rau rooj plaub thiab yuav ua li cas kuv txhim kho txhua yam.

Rau rooj plaub kuv siv 2 lub thawv ABS:

- 265 x 185 x 95 hli

- 171 x 121 x 80 hli

Cov qhov kuv tau ua hauv cov thawv

Lub qhov rau LCD saib, 3 qhov rau lub zog txuas hluav taws xob, ib qho rau cov xov hlau los ntawm lub tshuab tsav, lub tshuab DC thiab lub ntsuas hluav taws xob.

Hauv lub thawv me tshaj kuv tau ua lub qhov rau cov xov hlau los ntawm cov khoom siv thiab lub qhov rau daim npav hla dhau. Nyob rau sab saum toj kuv tau ua qhov loj tshaj yog li koj tuaj yeem tso daim npav ua si hauv lub cuab yeej.

Kuv tau nruab DC lub cev muaj zog nrog lub khawm thiab qee daim kab xev ob tog. Kuv tau ua ib lub rooj ntoo los tso daim npav nrog lub qhov rau lub log kom tua daim npav.

Kuv tau xaiv rau yas ABS vim tias nws yog lub teeb yuag yog li cov stepper lub cev muaj zog tuaj yeem tig nws yooj yim. Ntoo tuaj yeem hnyav heev thiab lub cav tsav tsheb tuaj yeem muaj teeb meem nrog qhov no. Txhawm rau txiav lub qhov kuv siv lub laum nrog cov laum tsim los rau cov hlau thiab Dremel. Txiav qhov loj dua tau ua haujlwm ntau dua thiab lub jig pom yuav zoo dua.

Kauj Ruam 7: Program Raws Li Kev Pabcuam

Nws yog qhov muaj txiaj ntsig zoo kom muaj cov lej pib tom qab Pi tau khau raj. Rau qhov ntawd peb yuav ua qhov kev pabcuam.

Tsim cov ntawv tshiab hu ua smartcard.service nrog cov lus txib hauv qab no:

sudo nano /etc/systemd/system/smartcard.service

Qhov no yuav tsum mus rau hauv cov ntawv:

[Chav]

Nqe lus piav qhia = Ntse daim npav rov qab Tom qab = network.target [Service] ExecStart =/usr/bin/python3 -u app.py WorkingDirectory =/home/pi/project1 StandardOutput = inherit StandardError = inherit Restart = always User = pi [Install] WantedBy = ntau-user.target WorkingDirectory yog txoj hauv kev rau daim nplaub tshev uas qhov program nyob

Tam sim no koj tau txais koj li Smart Card!

Pom zoo: