Cov txheej txheem:

Yuav Ua Li Cas Lub Ntsej Muag Ntsej Muag Nrog Raspberry Pi: 4 Kauj Ruam
Yuav Ua Li Cas Lub Ntsej Muag Ntsej Muag Nrog Raspberry Pi: 4 Kauj Ruam

Video: Yuav Ua Li Cas Lub Ntsej Muag Ntsej Muag Nrog Raspberry Pi: 4 Kauj Ruam

Video: Yuav Ua Li Cas Lub Ntsej Muag Ntsej Muag Nrog Raspberry Pi: 4 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
Yuav Ua Li Cas Lub Ntsej Muag Ntsej Muag Nrog Raspberry Pi
Yuav Ua Li Cas Lub Ntsej Muag Ntsej Muag Nrog Raspberry Pi

Hauv qhov kev qhia no, Kuv yuav piav qhia yuav ua li cas koj tuaj yeem ua lub hnab ntim ntse nrog Raspberry Pi.

Thaum koj ua tiav, koj yuav tuaj yeem taug qab koj lub thawv rau khaub ncaws thoob ntiaj teb thiab ntsuas nws yam tsis tas yuav tsum tau ntsuas.

Cia peb pib!

Kauj Ruam 1: Cheeb Tsam Koj Xav Tau

  • Raspberry Pi (ofcourse xd)
  • Jumper cables
  • Ib lub thawv rau khaub ncaws
  • Powerbank los txhawb koj lub Pi
  • Adafruit Qhov kawg GPS tawg + Antenna
  • HX711 load cell amplifier
  • Load sensor sib txuas
  • Plaub plaub 50kg load hlwb
  • Ob (ntoo) cov laug cam uas tsis khoov yooj yim heev (piv txwv li plywood). Nco ntsoov tias cov laug cam muaj qhov ntev ib yam thiab haum rau hauv koj lub thawv rau khaub ncaws.
  • LCD-zaub (xaiv tau, Kuv yuav siv nws los tso saib IP ntawm kuv Raspberry Pi kom tus neeg siv tuaj yeem paub mus rau lub vev xaib twg nws yuav tsum mus saib cov ntaub ntawv ntawm lub thawv)

Kauj Ruam 2: Sib Sau Koj Lub Phiaj Xwm

Sib Sau Koj Lub Phiaj Xwm
Sib Sau Koj Lub Phiaj Xwm
Sib Sau Koj Lub Phiaj Xwm
Sib Sau Koj Lub Phiaj Xwm
Sib Sau Koj Lub Phiaj Xwm
Sib Sau Koj Lub Phiaj Xwm

Ntawm daim duab koj tuaj yeem pom yuav ua li cas koj yuav tsum txuas txhua qhov sib txawv. Yog tias koj muaj teeb meem, ua raws cov theem hauv qab no:

Txhawm rau txuas koj li GPS:

  • VIN -> Raspberry Pi tus pin 1 (3.3V)
  • GND -> Raspberry Pi tus pin 6 (GND)
  • TX -> Raspberry Pi pin 10 (RXD)
  • RX -> Raspberry Pi pin 8 (TXD)

Txhawm rau txuas koj lub LCD-zaub: (tsis tau kos nws ntawm Fritzing cov phiaj xwm vim tias nws yuav tau ntxhi..)

  • VSS -> Raspberry Pi tus pin 6 (GND)
  • VDD -> Raspberry Pi pin 2 (5V)
  • V0 -> potentiometer (qhov no saib xyuas qhov sib txawv kho)
  • RS -> Raspberry Pi tus pin 18 (GPIO24)
  • RW -> Raspberry Pi pin 6 (GND)
  • E -> Raspberry Pi tus pin 32 (GPIO25)
  • D0 -> Raspberry Pi tus pin 42 (GPIO12)
  • D1 -> Raspberry Pi tus pin 46 (GPIO16)
  • D2 -> Raspberry Pi tus pin 48 (GPIO20)
  • D3 -> Raspberry Pi tus pin 50 (GPIO21)
  • D4 -> Raspberry Pi tus pin 11 (GPIO17)
  • D5 -> Raspberry Pi tus pin 13 (GPIO27)
  • D6 -> Raspberry Pi tus pin 15 (GPIO22)
  • D7 -> Raspberry Pi tus pin 33 (GPIO13)
  • A -> Raspberry Pi tus pin 2 (5V)
  • K -> Raspberry Pi tus pin 6 (GND)

Txhawm rau txuas koj lub xov tooj ntawm tes:

  • Hauv nruab nrab ntawm pawg thawj coj sib txuas, koj tuaj yeem pom tias muaj plaub kab nrog txhua peb qhov kev sib txuas (-, + thiab C). Ib lub xovtooj ntawm tes muaj peb lub xovtooj (wite, liab thiab dub). Txuas txhua lub ntsuas qhov ntsuas mus rau kab ntawv raws li hauv qab no:

    • - -> Dub
    • + -> Dawb
    • C -> Liab
  • Thaum koj tau ua tiav qhov ntawd, txuas lub rooj sib txuas ua ke rau HX711 thauj khoom ntawm lub xov tooj ntawm tes raws li hauv qab no:

    • Liab -> E+
    • Dub -> E-
    • Ntsuab -> A-
    • Dawb -> A.
  • Thaum kawg, txuas HX711 rau koj li Raspberry Pi:

    • VCC -> Raspberry Pi tus pin 17 (3.3V)
    • GND -> Raspberry Pi pin 9 (GND)
    • DT -> Raspberry Pi tus pin 29 (GPIO5)
    • SCK -> Raspberry Pi tus pin 31 (GPIO6)

(B- thiab B+ ntawm HX711 thiab Daj ntawm lub rooj sib txuas ua ke nyob twj ywm)

Txhawm rau xa koj cov cell load rau koj cov laug cam:

  • Ua ntej tshaj, xyuas kom tseeb tias lub hlwb thauj khoom raug muab tso rau ntawm lub rooj tsavxwm.
  • Tom qab ntawd, rau txhua lub xovtooj ntawm tes, ua kom lub qhov me me, lub voos plaub kom lub "hau" ntawm lub xovtooj ntawm tes tsis kov hauv av. Yog tias nws ua, koj yuav tau txais qhov txiaj ntsig tsis zoo.
  • Muab cov xov tooj ntawm tes tso rau ntawm lawv qhov chaw raug thiab muab txuas rau lub rooj tsavxwm nrog cov ntsia hlau.
  • Tom ntej no, txuas lub rooj sib txuas ua ke rau sab saum toj ntawm lub rooj tsav khoom kom cov pins yog "sab nraud" saum npoo ntawm lub rooj tsavxwm.
  • Ruaj ntseg cov xov hlau los ntawm lub xov tooj ntawm tes nrog qee daim kab xev rau lub rooj tsavxwm.
  • Tom qab ntawd, ua me me cubes nrog qee cov ntoo thiab txuas lawv mus rau qhov nruab nrab ntawm txhua lub xov tooj ntawm tes nrog qee cov kua nplaum. Qhov hnyav yuav raug ntsuas los ntawm kev sib tsoo ntawm qhov nruab nrab bar.
  • Thaum kawg, txuas lub rooj tsavxwm thib ob mus rau lub voos me me nrog qee cov kua nplaum.

Kauj Ruam 3: Muab cov Cheebtsam tso rau hauv koj lub thawv rau khaub ncaws

Muab cov Cheebtsam tso rau hauv koj lub thawv rau khaub ncaws
Muab cov Cheebtsam tso rau hauv koj lub thawv rau khaub ncaws
Muab cov Cheebtsam tso rau hauv koj lub thawv rau khaub ncaws
Muab cov Cheebtsam tso rau hauv koj lub thawv rau khaub ncaws
Muab cov Cheebtsam tso rau hauv koj lub thawv rau khaub ncaws
Muab cov Cheebtsam tso rau hauv koj lub thawv rau khaub ncaws
Muab cov Cheebtsam tso rau hauv koj lub thawv rau khaub ncaws
Muab cov Cheebtsam tso rau hauv koj lub thawv rau khaub ncaws

Yog li thaum koj tau txuas txhua yam, nws yog lub sijhawm los muab txhua yam hauv koj lub thawv rau khaub ncaws.

Kev ntsuas qhov hnyav: Ib yam uas yuav tsum tau nyob hauv tib qho chaw tsis muaj teeb meem dab tsi yog qhov ntsuas qhov hnyav, yog li nco ntsoov tias koj txuas lawv zoo heev rau hauv qab ntawm lub thawv rau khaub ncaws nrog qee cov kua nplaum zoo lossis cov ntsia hlau.

GPS-module: Txhawm rau kom tau txais GPS-teeb liab zoo dua, Kuv tau ua lub qhov me me hauv kuv lub thawv rau khaub ncaws kom sab saum toj ntawm lub kav hlau txais xov tuaj yeem txuas rau sab nraum lub thawv rau khaub ncaws.

LCD-screen: Txhawm rau tso lub LCD-tso rau hauv koj lub thawv rau khaub ncaws, yog tias koj xav tau, koj ua lub qhov plaub fab uas muaj qhov loj ib yam li LCD-screen. Tom qab ntawd txuas lub LCD-screen nrog qee cov kua nplaum muaj zog.

Lwm qhov: Koj tuaj yeem tso lwm qhov, xws li Raspberry Pi thiab lub txhab nyiaj, rau hauv qab lossis ob sab ntawm lub thawv rau khaub ncaws nrog qee cov kua nplaum. Koj tuaj yeem ua nws zoo li koj xav tau.

Yog li hauv qhov xaus, tsuas yog ua kom ntseeg tau tias txhua yam khoom sib txuas tau zoo rau lub thawv rau khaub ncaws kom tsis muaj ib yam dab tsi tuaj yeem tawm ntawm qhov chaw.

Kauj Ruam 4: Teeb Koj Raspberry Pi

Txhawm rau pib yam tawm, peb yuav tsum ua qee qhov teeb tsa ua ntej, yog li tsuas yog ntaus cov lus txib hauv qab no:

Ua ntej nruab qee pob khoom:

sudo apt hloov tshiab apt nruab -y python3-venv python3-pip python3-mysqldb mariadb-server uwsgi nginx uwsgi-plugin-python3

  • Tom qab ntawd tsim lub virtual

    ib puag ncig

    :

python3 -m pip install-upgrade pip setuptools log virtualenvmkdir project1 && cd project1python3 -m venv --system-site-packages envsource env/bin/activatepython -m pip install mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask MySQL mysql-connector-python passlib

  • Tom ntej no, clone txoj haujlwm no rau hauv xws li PyCharm (txoj haujlwm muaj 4 daim nplaub tshev)
  • Nco ntsoov tias txoj haujlwm txhais lus yog nab nab ntawm koj li Raspberry Pi
  • Txhawm rau teeb tsa lub database:

cd ua project1

sudo mariadb <sql/db_init.sql

  • Ua txuas nrog koj cov ntaub ntawv hauv PyCharm
  • Thaum kawg, nyem rau ntawm cov ntaub ntawv 'lugapp.sql' hauv daim nplaub tshev 'sql' thiab xaiv 'khiav'. Qhov no yuav tso cov ntxhuav rau hauv cov ntaub ntawv ntawm koj Pi.

Tom ntej no, tsuas yog qhov koj yuav tsum tau hloov kho, yog nyob hauv cov ntaub ntawv teeb tsa hauv daim nplaub tshev "CONF". Nyeem txhua cov ntawv hauv daim nplaub tshev no thiab hloov pauv qhov tsim nyog. (piv txwv li txoj hauv kev ua haujlwm, tus neeg siv …).

Cov kauj ruam kawg:

Luam cov ntaub ntawv "project1-flask.service" thiab "project1-lcd.service" rau/etc/systemd/system los ntawm kev siv cov lus txib hauv qab no:

sudo cp conf/project1-*. service/etc/systemd/system/

Tom qab ntawd, rov ua dua:

sudo systemctl daemon-reload

Thaum kawg, pib ob qhov kev pabcuam:

sudo systemctl qhib qhov project1-*

sudo systemctl pib qhov project1-*

Pom zoo: