Cov txheej txheem:

Raspberry Pi Tham Nrog Barcode Reader: 12 Cov Kauj Ruam
Raspberry Pi Tham Nrog Barcode Reader: 12 Cov Kauj Ruam

Video: Raspberry Pi Tham Nrog Barcode Reader: 12 Cov Kauj Ruam

Video: Raspberry Pi Tham Nrog Barcode Reader: 12 Cov Kauj Ruam
Video: Lub Zog Nruab Nrog (Hmong Dubbed) 2024, Hlis ntuj nqeg
Anonim
Raspberry Pi Tham Nrog Barcode Reader
Raspberry Pi Tham Nrog Barcode Reader

Daim duab 1 Barcode Scanner los ntawm DX.com

Txheej txheem cej luam

Hloov tshiab: Ib qho vis dis aus luv luv muaj nyob

Kuv niam tsis tuaj yeem nyeem cov ntawv lo ntawm cov khoom lag luam ntxiv lawm, yog li kuv tau mus nrhiav kev daws teeb meem. Tom qab pom qhov bar nyeem ntawv rau cov neeg dig muag khiav ntau pua daus las, Kuv xav pom dab tsi tuaj yeem ua tiav siv Raspberry Pi thiab USB Barcode nyeem ntawv.

Lwm qhov kev coj ua tseem ceeb yog qhov no yuav tsum ua haujlwm yam tsis muaj Is Taws Nem txuas (xws li tom khw lossis phooj ywg lub tsev). Yog li cov ntaub ntawv khaws tseg thiab cov ntawv-rau-hais lus yuav tsum muaj tus kheej.

Kuv sim lub koob yees duab raws li tus lej nyeem kab ntawv, tab sis teeb pom kev zoo thiab lub koob yees duab txoj haujlwm ua rau muaj teeb meem kev ntseeg tau rau ib tus neeg tsis tuaj yeem pom meej. Cov no tseem yuav tsum tau pom kom teeb tsa thiab siv lub app. Yog li kuv hloov mus rau USB Laser bar code nyeem ntawv, tshwj xeeb tshaj yog txij li tam sim no lawv muaj rau qis dua $ 30 thiab Raspbian Jessie txhawb nqa lawv tawm ntawm lub thawv.

Kuv kuj tau sim tawm tshiab Amazon Dash Wand tab sis nws tsis hais lus cov khoom luam theej thiab nws xav tau kev sib txuas hauv Is Taws Nem los ua haujlwm.

Lub tswv yim yog txhawm rau tshuaj xyuas ib yam khoom thiab muaj Raspberry nug cov ntaub ntawv sab hauv ntawm UPC cov lej thiab tom qab ntawd hais cov lus piav qhia cov khoom siv cov ntawv-rau-hais lus.

Txhawm rau ua kom chav nyob me me li sai tau, kuv xav siv Raspberry Pi Zero. Kuv kuj xav khiav lub tsev tawm roj teeb lub zog ib yam.

Txhawm rau ua kom tau raws li qhov yuav tsum tau ua no yuav tsum muaj kev sib pauv pauv. Txij li Xoom tsis muaj lub suab sab nraud kuv rov siv lub suab tsim los ntawm kuv qhov "Av Qeeg Pi" vim nws tau tus nqi qis (kwv yees li $ 6) thiab me me heev. Hloov pauv, hloov pauv "Ib Lub Suab Transistor rau Pi Zero" tej zaum yuav ua tau.

Txog Laser Bar Code scanner, kuv pom ib qho los ntawm DX.com. Nws tau siv tawm ntawm Raspberry USB thiab raug nqi txog $ 25. (saib Tshooj hauv qab)

Kauj ruam 1: Hloov tshiab

Nrog tuaj txog ntawm Raspberry Pi Zero W, Kuv yuav hloov mus rau nws. Txhua yam ntawm no zoo ib yam, tshwj tsis yog tias koj yuav tsum teeb tsa WiFi txuas rau Pi. Qhov no txhais tau tias koj yuav tsis xav tau lub USB hub rau Zero rau teeb tsa thiab siv.

Koj tuaj yeem teeb tsa WiFi siv:

thepihut.com/blogs/raspberry-pi-tutorials/…

Koj puas paub?

Yog tias koj nruab Raspbian Jessie ntawm daim npav SD siv lub Windows PC, koj tuaj yeem tsim ob daim ntawv ntawm daim npav txhawm rau teeb tsa WiFi thiab SSH nkag ua ntej koj khau raj ntawm Raspberry?

Txog qhov no, xav tias koj daim npav SD tam sim no tau teeb tsa ua K: ntawm koj lub PC:

1) Nruab qhov tseeb Raspbian Jessie duab mus rau SD. Txog qhov haujlwm no, Jessie Lite yuav tsum ua haujlwm.

www.raspberrypi.org/downloads/raspbian/

2) Nrog notepad, tsim cov ntawv hu ua "ssh" thiab siv Txuag Raws li "Txhua cov ntaub ntawv" rau K: / ssh

Cov ntawv tuaj yeem muaj dab tsi. Nws yog lub npe ntawv uas tseem ceeb. Yuav tsum tsis yog "ssh.txt" !!!

3) Nrog notepad, tsim cov ntawv hu ua "wpa_supplicant.conf" nrog rau hauv qab no:

ctrl_interface = DIR =/var/run/wpa_supplicant GROUP = netdevupdate_config = 1

network = {

ssid = "mySSID" psk = "mypassword" key_mgmt = WPA-PSK}

Siv Txuag Raws Li "Txhua cov ntaub ntawv" rau K: / wpa_supplicant.conf Ib zaug ntxiv, tsis txhob cia Notepad hloov nws mus rau "wpa_supplicant.conf.txt" !!

Thaum koj khau raj Raspberry thawj zaug, Jessie yuav nrhiav cov no thiab txuas rau koj li Wifi. Koj yuav tsum tau saib ntawm koj tus Router rau tus IP chaw nyob, txawm li cas los xij, txij li nws tau pib ua haujlwm.

Kauj Ruam 2: Daim Ntawv Teev Npe

  • Raspberry Pi Zero (lossis ib qho Raspberry Pi, yog qhov loj tsis yog qhov teeb meem)
  • USB Laser bar code scanner

    www.dx.com/p/ls-4209-laser-bar-code-scanner…

  • Rau Raspi Zero, ntxiv Adafruit I2S 3W Class D Amplifierhttps://www.adafruit.com/products/3006
  • Hais lus me. (Rau Pi 2, 3, siv sab nraud amp & hais lus.)
  • USB Micro rau USB OTG adapterhttps://www.adafruit.com/products/2910
  • 5V 1Amp USB roj teeb pob xws li ashttps://www.adafruit.com/products/1959
  • USB rau micro USB cable rau roj teeb pob.
  • USB & Ethernet hub (tsawg kawg rau kev teeb tsa thawj zaug, tsis xav tau rau Zero W lossis Raspi 2, 3)
  • Software los ntawm GITHUB:

Kauj Ruam 3: USB Laser Bar Code Reader

USB Laser Bar Code Reader
USB Laser Bar Code Reader

Laser bar code nyeem ntawv tau zam txim ntau dua hauv lawv lub peev xwm los tshuaj xyuas daim ntawv lo UPC ntau dua li lub koob yees duab. Lawv kuj ua haujlwm tau zoo txawm tias nyob hauv cov teeb pom kev tsis zoo lossis cov ntawv sau tsis zoo.

Koj yuav xav tau USB rau USB micro adapter txhawm rau txuas nws rau Zero.

Kev tuav tes thiab txhais ntawm lub tshuab luam ntawv ua rau nws yooj yim siv.

Nws tseem muab cov lus tawm tswv yim thaum nws ua tiav luam daim ntawv lo.

Yav Tom Ntej ToDo:

Hauv qhov tsim qauv zaum kawg, Kuv yuav txiav cov kab hluav taws xob kom luv nws thiab txuas ncaj qha rau USB pins ntawm Xoom kom txo qhov loj me thiab muaj feem yuav ua rau txuas tsis tau. Zero thiab roj teeb yuav txuas ncaj qha rau hauv qab ntawm lub tshuab luam ntawv kov hauv 3D luam ntawv.

Kauj Ruam 4: UPC Database

Qhov no yog qhov tsis zoo tshaj plaws suav nrog ib feem ntawm txoj haujlwm, raws li muaj ntau plhom tus lej UPC thiab tsawg tsawg qhov qhib cov ntaub ntawv muaj rau rub tawm. Hmoov tsis zoo, feem ntau UPC cov chaw khaws ntaub ntawv zoo dua thiab xav tau kev sib txuas hauv is taws nem.

Kuv muaj peev xwm muab ob peb lub hauv paus qhib cov ntaub ntawv ua ke (cov peev txheej hauv Cov Ntawv Ntxiv hauv qab no), tab sis txawm tias muaj ze li ntawm 700, 000 yam khoom hauv nws, coob leej uas ploj lawm.

Txog qhov kawg no, Kuv tau ua ob yam; ib qho yog tsom mus rau cov khoom lag luam tshwj xeeb thiab lwm qhov yog ntxiv lub web server rau Raspberry kom tso cai ntxiv UPC cov lej tshiab ntawm tus kheej, txawm li cas los xij, qhov no xav tau tsawg kawg hauv zej zog kev sib txuas.

Yav Tom Ntej ToDo:

Kuv yuav ua Zero W "hotspot" kom koj tuaj yeem txuas rau nws nyob txhua qhov chaw kom ntxiv cov lej tshiab UPC.

Kauj ruam 5: Text-to-Speech

Kuv siv cov ntawv los hais lus qhov program hu ua "Flite", vim nws muaj qhov kev pom zoo tshaj plaws ntawm lub suab zoo thiab hloov pauv nrawm ntawm Zero. Lwm tus tau hnov zoo me ntsis, tab sis qeeb dhau los hloov pauv.

Koj tseem tuaj yeem tshawb xyuas Adafruit cov lus qhia: https://learn.adafruit.com/speech-synthesis-on-the …

Nco ntsoov tias nws yuav siv sijhawm me ntsis ntawm "kev qhia pob ntseg" kom tau siv rau qhov kev hais lus cuam tshuam, tab sis nws tsis phem heev.

Kev txheeb xyuas cov khoom qub ib zaug ntxiv yuav rov ua suab.

Yav Tom Ntej ToDo

Tej zaum ntxiv lub mloog pob ntseg kom thiaj yooj yim rau cov laus mloog lub suab nrov nrov.

Kauj Ruam 6: Roj Teeb

Lub kaw lus tuaj yeem ua haujlwm los ntawm 5V USB roj teeb, xws li siv los rov them xov tooj ntawm tes.

Qhov ntes yog tias thaum koj ntsaws lub roj teeb lossis lub roj teeb tuag, Pi yuav tsoo nrog lub sijhawm uas nws yuav ua rau SD tsav puas.

Txhawm rau daws qhov no, xav tau lub pob uas ua haujlwm kaw qhov hais kom ua. Kuv yuav zaum siv ib qho zoo li no:

www.element14.com/community/docs/DOC-78055…

(Yog … lwm "Yav Tom Ntej ToDo!")

Kauj Ruam 7: Ntu Kuv - Ntxiv Suab rau Pi Zero

Ntu Kuv - Ntxiv Suab rau Pi Zero
Ntu Kuv - Ntxiv Suab rau Pi Zero
Ntu Kuv - Ntxiv Suab rau Pi Zero
Ntu Kuv - Ntxiv Suab rau Pi Zero
Ntu Kuv - Ntxiv Suab rau Pi Zero
Ntu Kuv - Ntxiv Suab rau Pi Zero

(Hla qhov no yog tias tsis siv Xoom!)

Ntawm Pi Zero, koj yuav tsum tau ntxiv cov suab sab nraud, vim nws tsis tau tsim nrog. Kuv siv tus nqi qis "Adafruit I2S 3W Amplifier breakout MAX98357A"

Qhov no xav tau teeb tsa siv Adafruit qhov qhia tau zoo ntawm:

Raws li qhia hauv ntu txuas ntawm kev qhia, txuas:

• Amp Vin rau Raspi Zero Pi 5V • Amp GND rau Raspi Zero Pi GND • Amp DIN rau Raspi Zero Pi #21 • Amp BCLK rau Raspi Zero Pi #18 • Amp LRCLK rau Raspi Zero Pi #19

Txuas tus neeg hais lus me me rau lub suab coj ntawm lub rooj tsavxwm.

Pi Zero Adafruit Audio Software SetupAlso qhia hauv Adafruit software teeb tsa qhia, ua raws CURL hais kom ua hauv qab no:

$ curl -sS https://raw.githubusercontent.com/adafruit/Raspbe…> | tsoo

Tom qab rov pib dua, sim lub suab siv tus hais lus-ntsuas:

$ speaker -test -c2 --test = wav -w /usr/share/sounds/alsa/Front_Center.wav

Yog tias koj muaj teeb meem, rov mus dhau Adafruit cov lus qhia pib rov qab los ntawm kev saib xyuas. Koj yuav xav tau mus rau ntu "Kev teeb tsa kom ntxaws" cov kauj ruam hauv kev qhia kom paub tseeb txhua cov ntaub ntawv hloov tshiab.

Qhov Tseem Ceeb Yuav Tsum Ua Rau Xoom & Max98357 Suab: Los ntawm lub neej ntawd, ALSA lub suab tsuas ua haujlwm hauv Stereo thaum Flite ntawv-rau-hais lus yog mono. Tsis tas li, lub suab muaj "pops" hauv nws txhua lub sijhawm nws pib ua si.

(Saib:

Koj yuav tsum ua cov hauv qab no:

1) Ntxiv kab rau /boot/config.txt

$ sudo nano /boot/config.txt

dtoverlay = i2s-mmap

2) Hloov /etc/asound.conf

$ sudo nano /etc/asound.conf

pcm.hifiberry {hom hw card 0} pcm.! default {hom plug slave.pcm "dmixer"} pcm.dmixer {hom dmix ipc_key 1024 qhev {pcm "hifiberry" raws 2}} ctl.dmixer {hom hw card 0}

3) Reboot koj Pi.

Sim Tus Hais Lus-sim dua. Nws yuav tsum zoo dua tam sim no. Thaum koj ua tiav cov teeb tsa kev qhia suav nrog kev kuaj lub suab, tom qab ntawd lub suab yuav tsum npaj txhij.

Nco ntsoov tias koj yuav xav ntxiv lub mloog pob ntseg rau lub suab, yog tias koj coj qhov no mus rau tom khw muag khoom lossis ib puag ncig nrov nrov.

Kauj Ruam 8: Ntu II - Kev Txhim Kho Software

Qhov no xav tias koj twb muaj Raspbian Jessie teeb tsa thiab tuaj yeem nkag mus rau Linux kab lus hais kom ua. Koj tsis xav tau GUI version ntawm Raspbian, tab sis zoo siv.

Koj TSIS TXHOB xav tau lub USB scanner txuas rau tam sim no, yog tias koj xav tau USB chaw nres nkoj rau Ethernet lossis keyboard/mouse.

Xyuas kom tseeb tias koj OS tau hloov kho tshiab:

$ sudo apt-tau hloov tshiab $ sudo apt-tau upgrade

Los ntawm kab hais kom ua, mus rau pi tsev phau ntawv teev npe thiab rub tawm GITHUB chaw cia khoom:

$ cd/home/pi $ sudo apt install git $ git clone https://github.com/rgrokett/TalkingBarcodeReader….> https://github.com/rgrokett/TalkingBarcodeReader….> $ cd TalkingBarcodeReader $./install. sh ua

Qhov no yuav siv qee lub sijhawm, tshwj xeeb yog qhov no yog thawj zaug thiab lub vev xaib thiab PHP xav tau los teeb tsa lossis hloov kho tshiab. Yog tias tsim nyog, koj tuaj yeem ua qhov no ntau dua ib zaug. Qhov lwm yam, qhov no teeb tsa cov ntawv barcode thiab UPC database rau:/var/www/html/upc

Tom ntej no, hloov /etc/rc.local thiab txuas kab hauv qab no ua ntej "tawm 0"

$ sudo nano /etc/rc.local

fi sudo /var/www/html/upc/bin/run.sh tawm 0

Thaum kev teeb tsa tiav, kaw koj tus Pi thiab ntsaws rau hauv USB Barcode nyeem ntawv thiab rov pib dua.

$ sudo kaw tam sim no

Hwj chim nws rov qab thiab koj yuav tsum hnov lus pib pib luv luv.

Yog tias yog, sim tshuaj xyuas kab ntawv bar code los ntawm cov khoom lag luam. Yog tias txhua yam mus tau zoo, koj yuav tsum hnov nws hais cov khoom (lossis hais "Tsis Pom"). Txwv tsis pub, kos rau ntawm phau ntawv qhia kev daws teeb meem tom ntej.

Kauj ruam 9: Teeb meem

Teeb meem
Teeb meem

Yog tias koj tsis hnov suab, koj yuav tsum tau sim cov lus txib hauv qab no:

1) Txheeb xyuas cov ntawv nyeem-rau-hais lus ua haujlwm:

$ sudo flite -voice awb -t "kuaj"

Yog tias koj tau txais qhov yuam kev, nco ntsoov tias tau teeb tsa flite:

$ sudo apt nruab flite

Yog tias koj tau txais qhov yuam kev hauv qab no, nco ntsoov koj hloov kho /boot/config.txt thiab /etc/asound.conf qhia hauv ntu Suab teeb tsa ntu saum toj no ntawm Raspi Zero's: audio_open_alsa: ua tsis tau raws tus naj npawb ntawm txoj hauv kev rau 1. Kev siv tsis raug.

Yog tias koj tsis muaj qhov yuam kev thiab tsis muaj suab, nco ntsoov tias koj lub Raspberry audio ua haujlwm.

sudo aplay /usr/share/sounds/alsa/Front_Center.wav

1) Koj yuav xav yuam lub suab tawm lub suab tawm: (saib daim duab 1 saum toj no)

$ sudo raspi -config -> 7 Advanced Options -> A4 Audio

2) Thaum koj muaj lub suab thiab ntawv-rau-hais lus txheeb xyuas tau zoo, txheeb xyuas tus lej nyeem barcode:

cd/var/www/html/upc/binsudo python./test.py

Koj yuav tsum pom tus lej lej lej barcode tso tawm thaum koj luam theej duab barcode. (Qhov kev xeem tsis suav nrog cov suab tso tawm lossis cov ntaub ntawv sib txuas.)

3) Yog tias txhua yam no zoo, tom qab ntawv khij "nohup.out" rau cov lus yuam kev:

cd/var/www/html/upc/binsudo miv nohup.out

Tej zaum yuav muaj teeb meem tsis muaj pob lossis tso cai tsis zoo (lossis BUGs hauv txoj cai!). Nco ntsoov tias koj OS tau hloov kho tshiab thiab rov nruab install.sh dua.

Vam tias, koj tab tom ua haujlwm tam sim no!

Kauj ruam 10: Ntu III - Web Server

Ntu III - Web Server
Ntu III - Web Server

Txij li muaj ntau lab ntawm UPC cov lej thiab feem ntau tshaj tawm rau pej xeem (piv txwv li pub dawb) muaj cov chaw khaws ntaub ntawv tsuas yog ib pawg me me ntawm cov lej, txoj haujlwm no tsom mus rau UPC cov lej rau khoom noj khoom haus. Nws suav nrog ntau pua txhiab yam khoom, tab sis ntau, ntau yuav tsis pom.

Yog tias koj xav tau ntxiv lossis hloov kho UPC Database, muaj ob txoj haujlwm muaj; ib kab lus txib ib thiab lub web browser ib. (hloov cov lej nrog koj tus lej khoom UPC)

$ cd/var/www/html/upc/bin

$ sudo./addDB.sh 01234567890 "Kuv cov khoom tshiab"

Qhov no yuav ntxiv cov ntaub ntawv rau lub database. Txwv tsis pub, nws tau pom zoo kom siv lub web browser DB muaj nuj nqi.

Rau Web Server GUI, koj xav tau tus IP chaw nyob ntawm koj cov txiv pos.

Txhawm rau nrhiav tus IP chaw nyob, koj tuaj yeem siv:

$ hostname -I 192.168.1.108

Los ntawm PC browser, mus rau: https://192.168.1.108/upc/Koj yuav tsum pom lub vijtsam zoo ib yam li daim duab 2 saum toj no.

Yog tias yog, koj tuaj yeem ntxiv/hloov tshiab thiab rho tawm cov ntaub ntawv. Mus rau nplooj ntawv kawg uas siv ('> |') "kaw cov ntaub ntawv kawg" kom pom koj cov ntaub ntawv tshiab tshaj plaws raws li lawv tau txuas ntxiv mus rau qhov kawg ntawm cov ntaub ntawv khaws tseg.

NCO NTSOOV tias qhov kev pabcuam web no tsis muaj kev nyab xeeb, (tsis muaj pov thawj tseeb, tsis muaj SSL), yog li tsis txhob nthuav tawm rau pej xeem Is Taws Nem. (Tab sis txij li nws tsis tau teeb tsa ua WiFi Access Point, nws muaj kev nyab xeeb nqa mus rau tom khw.)

Txawm hais tias, txij li tsis muaj cov ntaub ntawv ntiag tug ntawm nws, qhov phem dua uas tuaj yeem tshwm sim yog ib tus neeg tswj hwm UPC cov ntaub ntawv.

Koj tseem tuaj yeem txwv kev nkag mus rau tus IP tshwj xeeb yog li tsis muaj lwm tus tuaj yeem nkag tau. Tsuas yog hloov tus IP (s) ntawm no rau qhov koj xav tso cai. Tag nrho lwm tus yuav raug thaiv los ntawm kev nkag mus:

$ sudo vi /etc/lighttpd/lighttpd.conf

$ HTTP ["remoteip"] = ~ "127.0.0.1 | 192.168.1.108" {url.access-reject = ("")} $ sudo /etc/init.d/lighttpd rov pib dua

Tsis tas li, Hloov pauv tus lej PI tsis raug! Txhua leej txhua tus paub lub neej ntawd yog pi/raspberry

$ passwd

Kauj ruam 11: Troubleshooting Web Server

Teeb meem hauv Web Server
Teeb meem hauv Web Server
Teeb meem hauv Web Server
Teeb meem hauv Web Server

Siv koj tus browser mus rau koj li Raspberry's IP chaw nyob, zoo li no:

192.168.1.108/

Koj yuav tsum pom lub vijtsam pib los ntawm /var/www/html/index.html (Daim duab 1 saum toj no)

Kuj nco ntsoov tias lub vev xaib ua haujlwm tau ua haujlwm:

$ ps -ef | grep lighttpd

Txhawm rau txheeb xyuas PHP zoo, tsim cov ntawv xeem php:

$ sudo nano /var/www/html/phpinfo.php

Tom qab ntawd mus rau

Koj yuav tsum pom lub vijtsam zoo li daim duab 2 saum toj no

Yog tias koj tau txais qhov yuam kev lossis cov ntxaij vab tshaus khoob, tshawb xyuas qhov ua yuam kev hauv

$ sudo miv /var/log/lighttpd/error.log

Ib zaug ntxiv, rov ua haujlwm install.sh tuaj yeem kho qhov tsis txaus ntseeg.

Kauj ruam 12: Cov ntawv txuas ntxiv

Ua tsaug ntau mus rau cov hauv qab no txhawm rau ua kom muaj UPC cov ntaub ntawv loj.

Qhib Khoom Noj UPC DB

www.grocery.com/open-grocery-database-proje…

Qhib Cov Ntaub Ntawv DB

www.grocery.com/open-grocery-database-proje…

www.upc-search.org/perl/upc-search.pl?q=84…

Ua tsaug rau EasyUI rau lub vev xaib yooj yim CRUD GUI

www.jeasyui.com/index.php

Pom zoo: