Cov txheej txheem:

Tsis Siv Neeg Dog Dispenser: 10 Kauj Ruam
Tsis Siv Neeg Dog Dispenser: 10 Kauj Ruam

Video: Tsis Siv Neeg Dog Dispenser: 10 Kauj Ruam

Video: Tsis Siv Neeg Dog Dispenser: 10 Kauj Ruam
Video: Tsis Muaj Ntxiv Lawm [(kuv hmoov phem los koj siab phem part 2)]-LOKY f.t RC Hmong. 2024, Kaum ib hlis
Anonim
Tsis Siv Neeg Aub Dispenser
Tsis Siv Neeg Aub Dispenser
Tsis Siv Neeg Aub Dispenser
Tsis Siv Neeg Aub Dispenser
Tsis Siv Neeg Aub Dispenser
Tsis Siv Neeg Aub Dispenser

Nrog kuv qhov project kuv paub tseeb tias thaum koj tso koj tus dev nyob ib leeg hauv tsev, nws / nws yeej tsis muaj zaub mov noj.

Lub tshuab pub mis tsis siv neeg yuav "hacked" los ntawm lub tshuab xa cov pob kws. Lub tshuab xa khoom yog lub chaw tso khoom rau dev noj, lub log nyob hauv qab yuav txuas nrog lub cav servo uas cia li poob zaub mov thaum lub txaj txaj yuav luag tas thiab thaum tus dev nyob ze txaus. Hauv qab ntawm lub dispenser yuav muaj PVC raj txuas uas yuav tso cov khoom noj dev zoo rau hauv txaj. Vim li no txoj haujlwm no yuav muaj 3 lub ntsuas hluav taws xob, 2 qhov uas tsis suav nrog hauv chav kawm thiab 1 uas yog tus ua haujlwm.

Thawj lub sensor yog RFID nyeem ntawv. Qhov ntsuas no ntsuas thaum tus dev los ze rau lub txaj. RFID yuav suav nrog hauv tus dev lub dab tshos. Yog tias lub ntsuas ntsuas pom tias tus dev nyob ze txaus, nws yuav xa lub teeb liab mus rau lub cim thib ob. Qhov ntsuas thib ob yog lub ntsuas qhov hnyav (tsis suav nrog hauv chav kawm) uas ntsuas cov zaub mov hauv lub txaj, yog lub ntsuas ntsuas pom tias qhov hnyav qis dhau, nws yuav xa lub teeb liab mus rau lub tshuab servo uas yuav tso zaub mov rau hauv txaj (nrog kev lees paub ntawm RFID thiab qhov ntsuas qhov hnyav). Hauv ntej, tus dev tsuas tau txais zaub mov ntxiv thaum nws nyob ze txaus rau lub txaj thiab thaum lub txaj txaj yuav luag tas. Tau kawg tseem muaj qhov txwv txwv uas koj tuaj yeem teeb tsa koj tus kheej ntawm lub web server; kom tus aub tsis noj zaub mov ntau dhau ib hnub. Qhov ntsuas thib peb yog lub teeb pom kev zoo uas pom lub teeb ci LED thaum nws tsaus ntuj ib ncig ntawm lub txaj. Yog li tus actuator yuav yog lub cav servo txuas nrog lub log hauv lub tshuab xa khoom.

Txoj haujlwm no yog txhais rau cov dev, koj tseem tuaj yeem siv nws rau lwm yam tsiaj me.

Khoom siv

Raspberry Pi 3

Thauj khoom ntawm tes (1KG)

HX711 load cell amplifier

Lub tais zaub mov

Cereal dispenser

Ntoo (+ ntsia hlau thiab ntsia hlau)

Lub teeb sensor

Coj

RFID nyeem ntawv rc522

Jumper xov hlau

16*2 LCD (zaub)

Servo tsav

5V zog adapter

Kev tiv thaiv 470 Ohm

PVC cev

Breadbord

Potentiometer

Pom

Sanding ntawv

Silicon phom

Kauj ruam 1: Pi Teeb

Pib teeb
Pib teeb

Teeb

Txhawm rau pib peb yuav tsum xub teeb tsa koj Pi.

Koj yuav xav tau ob yam:

- Win32 Disk Imager los ntawm

- Raspbian OS duab los ntawm

Rub tawm ZIP cov ntaub ntawv thiab rho tawm nws mus rau qhov twg koj xav tau.

Kev teeb tsa

1. Xaiv koj cov duab los ntawm daim nplaub tshev icon

2. Xaiv koj daim npav SD ntawm qhov nco tseg

3. Nyem rau sau

Tam sim no peb yuav tsum tau ua qee qhov tinkering ntxiv nrog qee qhov chaw yog li peb yuav tuaj yeem nkag mus rau Pi.

1. Mus rau daim npav SD daim ntawv teev npe khau raj

2. Qhib cov ntawv "cmdline.txt"

3. Ntxiv ip = 169.254.10.1 Thaum kawg ntawm kab ntawv ntev ntawm cov ntawv sib cais nrog ib qho chaw (ntawm kab ib yam).

4. Txuag cov ntawv.

5. Tsim cov ntaub ntawv npe ssh uas tsis muaj kev txuas ntxiv hauv tib phau ntawv

Tam sim no koj tuaj yeem tshem daim npav SD thiab muab tso rau hauv koj Pi.

Txuas

Tam sim no peb yuav tsum teeb tsa software.

Ua ntej txuas rau hauv LAN cable, ib kawg ntawm koj lub desktop/laptop thiab lwm qhov hauv koj Pi.

Tam sim no khau raj Raspberry Pi.

1. Nruab Putty los ntawm

2. Nkag mus rau 169.254.10.1 hauv IP kem.

3. Nco ntsoov xaiv SSH thiab chaw nres nkoj 22 tau sau rau.

4. Nyem qhib

5. Sau tus username: pi

6. Sau tus password: raspberry

Raspi-teeb tsa

Qhib Raspi-teeb tsa kev siv hluav taws xob los ntawm kev siv:

sudo raspi-teeb tsa

Pab kom cov kev xaiv hauv qab no hauv pawg cuam tshuam

- 1-Hlau

- TSI SPI

Lov tes taw cov kev xaiv hauv qab no hauv qeb xaiv khau raj

- Splash npo

Thaum kawg teeb tsa Desktop/CLI teeb tsa hauv qeb xaiv khau raj rau Desktop Autologin.

WiFi

Rau tus dev pub mis peb yuav tsum muaj kev sib txuas wifi yog li ua kom koj muaj koj li ntawv pov thawj wifi kaw.

1. Mus rau hauv paus hom

sudo -i ua

2. Muab kab ntawv no tso tab sis nco ntsoov tias SSID thiab Password tau ob qho tib si sau rau hauv

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

3. Nkag mus rau WPA Client.

Wpa_cli

4. Xaiv lub interface

Kev sib txuas wlan0

5. Rov ua dua qhov teeb tsa

Rov kho dua

Nco ntsoov tias koj tau txuas nrog raug los ntawm kev ntaus ip a thiab pom yog tias koj muaj IP ntawm WLAN0 cuam tshuam.

Pob

Tam sim no peb tau txuas nrog internet peb yuav tau teeb tsa qee pob khoom.

Ua ntej peb yuav xav tau hloov kho cov npe pob rau qhov tshiab kawg.

sudo apt hloov tshiab

Nab hab sej

Peb yuav yuam Raspbian siv Python 3

hloov kho-lwm txoj hauv kev-nruab/usr/bin/sej python /usr/bin/python2.7 1

hloov kho-lwm txoj kev-nruab/usr/bin/nab nab sej/usr/bin/python3 2

MariaDB

Muab tshuaj txhuam cov kab hauv qab no los teeb tsa lub database.

sudo apt nruab mariadb-server

Tom qab ntawd peb yuav tsum muaj kev ruaj ntseg rau peb kev teeb tsa.

mysql_secure_installation

Nws yuav nug peb rau lo lus zais hauv paus tam sim no vim tias peb tsis muaj ib tus nias nkaus xwb.

Tom ntej no nws nug yog tias peb xav tau lub hauv paus lo lus zais hom hauv y txij li peb xav tau ib tus.

Rau cov lus nug tom ntej no tsuas yog nkag rau Y.

Tom ntej no peb yuav tsim tus neeg siv uas peb yuav siv tau rau daim iav.

Nkag mus rau lub plhaub mysql los ntawm kev ua:

- Txhawb peb tus kheej rau hauv paus

Sudo -ib

- Nkag mus rau lub plhaub mysql

Mysql

- Hloov nrog koj tus kheej lub npe siv thiab zoo ib yam nrog

muab txhua txoj cai rau *. * rau ''@'%' txheeb xyuas los ntawm '';

- muab txhua txoj cai rau *. * rau ''@'%' txheeb xyuas los ntawm '';

Tom ntej no peb yuav ntxiv peb cov ntaub ntawv.

Apache Webserver

Txhawm rau nruab Webserver khiav kab hauv qab no.

sudo apt nruab apache2 -y

Nab hab sej pob

Peb tab tom yuav teeb tsa cov pob khoom no

- Lub hwj

- Flask-Cors

Flask-MySQL

- Flask-SocketIO

- PyMySQL

- Gevent

Gevent-websocket

- Httplib 2

Python-socketio

- Thov

- Wsaccel

- Ua

Los ntawm kev ua

pip nruab Flask Flask-Cors Flask-MySQL Flask-SocketIO PyMySQL gevent gevent-websocket httplib2 python-socketio thov wsaccel ujson mfrc522 hx711 Adafruit-CharLCD

Kauj Ruam 2: Coj thiab Lub Teeb Sensor

Led thiab Lub Teeb Sensor
Led thiab Lub Teeb Sensor
Led thiab Lub Teeb Sensor
Led thiab Lub Teeb Sensor

Hooking txog tus coj

  1. S -> GPIO15 (rxd0)
  2. + -> 5V
  3. G -> Resistor 470 ohm thiab GND

Hooking li lub teeb sensor

  1. Tawm -> GPIO17
  2. VCC -> 3.3V
  3. GND -> GND

Tam sim no peb tuaj yeem sim yog tias peb coj thiab lub teeb pom kev ua haujlwm nrog tsab ntawv me me no

ntshuam RPi. GPIO li GPIO GPIO.setmode (GPIO. BCM)

GPIO.setup (15, GPIO. OUT)

GPIO.setup (17, GPIO. IN)

sim: thaum Tseeb:

yog GPIO.input (17) == 0:

GPIO.output (15, GPIO. HIGH)

yog GPIO.input (17) == 1:

GPIO.output (15, GPIO. LOW)

tshwj tsis yog KeyboardInterrupt: GPIO.cleanup ()

Kauj Ruam 3: Servo Motor

Servo Tsav
Servo Tsav

Hooking li servo motor

  1. Tawm -> GPIO18
  2. VCC -> 5V
  3. GND -> GND

Tam sim no peb tuaj yeem sim yog tias peb coj thiab lub teeb pom kev ua haujlwm nrog tsab ntawv me me no

ntshuam RPi. GPIO ua GPIOimport lub sijhawm

GPIO.setmode (GPIO. BCM)

GPIO.setup (18, GPIO. OUT)

p = GPIO. PWM (18, 50)

p. pib (12.5)

sim:

thaum Muaj Tseeb:

p. ChangeDutyCycle (12.5)

sijhawm.sleep (1)

p. ChangeDutyCycle (2.5)

sijhawm.sleep (1)

tshwj tsis yog KeyboardInterrupt:

p.stop ()

GPIO.cleanup ()

Kauj Ruam 4: RFID Reader RC522

RFID nyeem ntawv RC522
RFID nyeem ntawv RC522

Hooking txog RFID

  1. RST -> GPIO6
  2. MISO -> GPIO9 (MISO)
  3. MOSI -> GPIO10 (MOSI)
  4. SCK -> GPIO11 (SPISCLK)
  5. SDA -> GPIO8 (SPICS0)
  6. 3.3V -> 3.3V
  7. GND -> GND

Tam sim no peb tuaj yeem sim yog tias peb tus nyeem ntawv RFID ua haujlwm nrog tsab ntawv me me no

ntshuam RPi. GPIO ua GPIO

los ntawm mfrc522 ntshuam SimpleMFRC522

nyeem ntawv = SimpleMFRC522 ()

text = input ('Cov ntaub ntawv tshiab:')

print ("Tam sim no tso koj daim ntawv sau")

nyeem ntawv.write (ntawv nyeem)

print ("Sau")

Kauj Ruam 5: Load Cell HX711

Load Cell HX711
Load Cell HX711

Hooking txog Load cell rau HX711 tus tsav tsheb

  1. Liab -> E+
  2. Dub -> E-
  3. Ntsuab -> A+
  4. Dawb -> A-

Hooking li Load cell

  1. DT-> GPIO27
  2. SCK -> GPIO22
  3. RED -> 3.3V
  4. GND -> GND

Tam sim no peb tuaj yeem sim yog tias peb lub cell load ua haujlwm nrog tsab ntawv me me no

ntshuam RPi. GPIO li GPIOimport lub sij hawm ntshuam sys los ntawm klasses. HX711 ntshuam HX711

def cleanAndExit (): print ("Cleaning …") GPIO.cleanup () print ("Bye!") sys.exit ()

hx = HX711 (22, 27)

hx.set_reading_format ("LSB", "MSB")

hx.set_reference_unit (2167)

hx.reset ()

hx.tare ()

thaum Muaj Tseeb:

sim:

val = max (0, int (hx.get_weight (5)))) cov

print (nqi)

hx.power_down ()

hx.power_up ()

sijhawm.s pw (0.5)

tshwj tsis yog (KeyboardInterrupt, SystemExit): cleanAndExit ()

Kauj Ruam 6: LCD (16*2)

LCD (16*2)
LCD (16*2)

Txuas lub LCD

  1. RS -> GPIO21
  2. RW -> GND
  3. E-> GPIO20
  4. D0 -> GPIO16
  5. D1 -> GPIO12
  6. D2 -> GPIO6
  7. D3 -> GPIO24
  8. D4 -> GPIO23
  9. D5 -> GPIO26
  10. D6 -> GPIO19
  11. D7 -> GPIO13
  12. VSS -> GND
  13. VDD -> 5V
  14. A -> 5V
  15. K -> GND
  16. V0 -> nruab nrab potentio tus pin

Tam sim no peb tuaj yeem sim yog tias peb lub vijtsam LCD ua haujlwm nrog tsab ntawv me me no

ntshuam Adafruit_CharLCD li LCDlcd_rs = 21

lcd_cov = 20

lcd_d4 = 23

lwd_d5 = 26

lcd_d6 = 19

lcd_d7 = 13

lcd_cov = 16

lcd_rows = 2

lcd = LCD. Adafruit_CharLCD (lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows)

lcd.message ('169.254.10.1')

Kauj Ruam 7: Puv Circuit Court

Puv Circuit
Puv Circuit

ntawm no koj tuaj yeem tshawb xyuas ntxiv yog tias tag nrho cov Circuit raug

Kauj Ruam 8: Pib Qhov Case

Pib Qhov Case
Pib Qhov Case
Pib Qhov Case
Pib Qhov Case
Pib Qhov Case
Pib Qhov Case
Pib Qhov Case
Pib Qhov Case

Kuv siv lub tshuab ua pob kws ua pob kws los ua khoom rau dev noj

Kuv txuas lub log hauv lub tshuab xa mus rau kuv lub cav servo

Tam sim no kuv tuaj yeem tswj lub log nrog kuv lub cav servo thiab tso zaub mov tawm ntawm lub pas dej

Qhov kawg ntawm lub pas dej muaj cov raj PVC txuas nrog uas tso cov zaub mov zoo rau hauv txaj

Kuv siv ntoo li casing

Kauj Ruam 9: Muab Nws Ua Ke

Muab tso ua ke
Muab tso ua ke
Muab tso ua ke
Muab tso ua ke
Muab tso ua ke
Muab tso ua ke

Kauj ruam 10: Lub Vev Xaib

Lub Vev Xaib
Lub Vev Xaib
Lub Vev Xaib
Lub Vev Xaib
Lub Vev Xaib
Lub Vev Xaib
Lub Vev Xaib
Lub Vev Xaib

Tam sim no peb lub tshuab ua haujlwm peb xav tau lub vev xaib mus rau pi. Tam sim no txhua yam tau nce thiab khiav qee qhov kev qhia ntawm qhov chaw ua haujlwm li cas.

Koj tuaj yeem txuas koj li pi mus rau wifi los ntawm kev ntsaws rau hauv ib qho hdmi cable thiab qhib txoj hauv kev no

Thawj nplooj ntawv yog home page, ntawm no koj tuaj yeem pom:

  • Cov lus qhia tiag txog lub teeb
  • Cov lus qhia txog lub sijhawm tiag tiag txog cov zaub mov uas tshuav hauv lub tais
  • Koj tuaj yeem tso zaub mov tseg
  • Cov ntaub ntawv hais txog tus dev

Nplooj ntawv thib ob yog nplooj ntawv kho, ntawm no koj tuaj yeem hloov kho:

  • lub npe ntawm koj tus tsiaj
  • hnub nyoog ntawm koj tus tsiaj
  • qhov hnyav ntawm koj tus tsiaj
  • daim duab ntawm koj tus tsiaj

Nplooj ntawv thib peb yog nplooj keeb kwm, ntawm no koj tuaj yeem pom:

  • thaum lub teeb tau mus ntxiv
  • thaum tus dev tau noj
  • thaum cov zaub mov poob lawm

Nplooj ntawv plaub yog nplooj ntawv teeb tsa, ntawm no koj tuaj yeem hloov kho:

  • thaum cov zaub mov xav tau poob
  • cov zaub mov kom poob
  • khoom noj khoom haus/hnub
  • lub teeb

Pom zoo: