Cov txheej txheem:

Hloov-nws, Tsis Siv Neeg Outlet Nrog Lub Sijhawm Tam Sim No Kev Ntsuas: 6 Cov Kauj Ruam
Hloov-nws, Tsis Siv Neeg Outlet Nrog Lub Sijhawm Tam Sim No Kev Ntsuas: 6 Cov Kauj Ruam

Video: Hloov-nws, Tsis Siv Neeg Outlet Nrog Lub Sijhawm Tam Sim No Kev Ntsuas: 6 Cov Kauj Ruam

Video: Hloov-nws, Tsis Siv Neeg Outlet Nrog Lub Sijhawm Tam Sim No Kev Ntsuas: 6 Cov Kauj Ruam
Video: Как работает SEO | Простая структура дорожной карты SEO 2024, Hlis ntuj nqeg
Anonim
Hloov-nws, Tsis Siv Neeg Outlet Nrog Lub Sijhawm Tam Sim No Kev Ntsuas
Hloov-nws, Tsis Siv Neeg Outlet Nrog Lub Sijhawm Tam Sim No Kev Ntsuas
Hloov-nws, Tsis Siv Neeg Outlet Nrog Lub Sijhawm Tam Sim No Kev Ntsuas
Hloov-nws, Tsis Siv Neeg Outlet Nrog Lub Sijhawm Tam Sim No Kev Ntsuas
Hloov-nws, Tsis Siv Neeg Outlet Nrog Lub Sijhawm Tam Sim No Kev Ntsuas
Hloov-nws, Tsis Siv Neeg Outlet Nrog Lub Sijhawm Tam Sim No Kev Ntsuas
Hloov-nws, Tsis Siv Neeg Outlet Nrog Lub Sijhawm Tam Sim No Kev Ntsuas
Hloov-nws, Tsis Siv Neeg Outlet Nrog Lub Sijhawm Tam Sim No Kev Ntsuas

Kuv yeej nyiam automatisation, lub peev xwm los tswj thaum qee yam yuav tsum tshwm sim. Nov yog qhov ua rau kuv los nrog lub tswv yim no: tus kheej ua, qhov hluav taws xob tsis siv neeg. Nws tuaj yeem siv los npaj thaum teeb yuav tsum tau qhib, thaum lub xov tooj xav tau them lossis thaum lub vijtsam xav tau lub zog. Ntxiv rau txhua qhov no, koj muaj peev xwm pom tias tam sim no ntws los ntawm qhov hluav taws xob ntau npaum li cas.

Cov cheebtsam xav tau rau txoj haujlwm no yog:

Khoom siv

Ua ntej peb yuav pib cov no yog yam uas koj yuav tsum tau tsim los ua Hloov-IT lub thawv zoo li kuv. Cov khoom siv no yuav raug nqi ib puag ncig 50 txog 100 euros nyob ntawm koj cheeb tsam thiab tus nqi tam sim no.

Kho vajtse

Electronics

  • Raspberry pib 4
  • 16gb (lossis ntau dua) Micro SD-Card
  • Arduino Ib
  • 5V-3.3V Qib hloov pauv
  • 5V relay module
  • ACS712 20A - tus qauv tam sim no
  • 1838 IR-Txais 37.9 kHz module
  • IR chaw taws teeb (Kuv siv Elegoo ib qho)
  • nquag cathode RGB
  • 3 * 330Ω resistors
  • laub khawm
  • RFID-RC522
  • LCD 1602A-1
  • Niko phab ntsa qhov (socket)
  • 10K Ω potmeter
  • 230 rau 5V - 7A fais fab tuag

Cov kab

  • USB-B rau USB-A cable
  • USB-C fais fab cable
  • Ethernet cable

Ntau yam

  • Txiv neej-Poj Niam Jumperwires
  • Txiv neej-Txiv neej Jumperwires
  • Cov kab laug sab
  • Shrinking lub cev

Cov ntaub ntawv Specefic qhov chaw (YOOJ YIM)

  • 50 * ceev thiab siab tawv
  • cov ntaub ntawv hlau 40x40x5 cm nrog lub hau
  • daim kab xev ob tog
  • 6 * 1cm siab spacers
  • coj-tuav
  • Velcro daim kab xev
  • cov kab lus qhia

Software

  • balenaEtcher:
  • PuTTy
  • rasbian
  • Visual Studio Code
  • Arduino IDE Cov

Kauj ruam 1: Teeb Rasbian

Teeb Rasbian
Teeb Rasbian
Teeb Rasbian
Teeb Rasbian

Ua ntej tshaj plaws peb yuav nyem Rasbian mus rau SD-Card. Peb yuav ua qhov ntawd siv balenaEtcher.

  1. Qhib balenaEtcher
  2. Xaiv Rasbian Duab
  3. Xaiv koj daim npav SD
  4. Nias Flash tos ob peb feeb kom txog thaum nws flashed

Ntxiv APIPA hauv phau ntawv teev npe khau raj: Peb yuav siv APIPA chaw nyob rau lub program thiab teeb tsa kev teeb tsa ntawm RPI. Ua li no:

  1. Nkag mus rau phau ntawv teev npe ntawm SD-Card
  2. Qhib "cmdline.txt"
  3. Ntxiv "169.254.10.1" tom kawg ntawm daim ntawv thiab khaws nws
  4. Ntxiv cov ntaub ntawv hu ua "ssh" rau cov npe khau raj (Tsis txhob muab qhov no NTAWV NTXIV)
  5. Tom qab koj ua tiav qhov no koj tuaj yeem tshem daim npav SD ntawm koj lub PC.

Nkag mus rau RPI siv PuTTy

Tam sim no peb tuaj yeem ntsaws daim npav SD rau hauv peb lub RPI, txuas RPI rau koj lub PC siv lub ethernet cable.

Txhawm rau txuas rau RPI peb yuav siv PuTTy nrog peb APIPA-chaw nyob.

  1. Qhib PuTTy
  2. Sau rau hauv peb qhov APIPA-chaw nyob raws li lub npe host (169.254.10.1)
  3. Nco ntsoov tias qhov chaw nres nkoj yog 22 thiab SSH raug xaiv
  4. Tam sim no koj tuaj yeem qhib qhov kev sib txuas
  5. Lub npe siv lub neej ntawd yog: pi
  6. Nrog tus password tsis raug: raspberry

raspi-config nqis

Qhib raspi-teeb tsa siv:

sudo raspi-teeb tsa

  • Hloov tus neeg siv tus password
  • Hauv cov kev xaiv hauv zos xaiv koj lub sijhawm sijhawm
  • Teeb WiFi siv kev xaiv network tom qab ntawd xaiv Wi-Fi qhov twg koj yuav tsum sau koj li SSID thiab Password.

Nruab Python 3

Hauv qhov haujlwm no peb tab tom siv Python, yog li peb yuav teeb tsa lub hauv paus rau Python3 insteat ntawm Python2, siv cov lus txib hauv qab no

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

Nab hab sej pob

Peb yuav xav tau ob peb pob khoom kom tau txhua yam ua haujlwm tau zoo, feem ntau yog Flask pob thiab ib qho los txuas nrog peb Cov DataBase. Peb tuaj yeem teeb tsa cov pob khoom siv cov lus txib hauv qab no:

pip nruab Flask

pip nruab Flask_cors pip nruab Flask_socketio pip nruab Python-mysql-connecton

Database

Tom ntej no peb yuav txhim kho peb li kev tswj hwm database (MariaDB) peb yuav ua li ntawd siv:

sudo apt nruab mariadb-server

Ntaus “Y” thiab Nkag mus ntxiv. Tom qab ob peb feeb, txheej txheem teeb tsa ua tiav thiab MariaDB yuav luag npaj txhij siv.

Txhawm rau teeb tsa lub database tus password siv lo lus txib:

sudo mysql_secure_installation

Tom qab ntawd nyem Enter, txij li tam sim no tus password tsis muaj dab tsi. Tom qab ntawv nyem "Y" txhawm rau teeb tus password, tam sim no koj tuaj yeem sau txhua tus password uas koj xav tau, nco ntsoov nco nws vim tias peb xav tau nws txhawm rau txhawm rau txhim kho kev sib txuas ntawm sab nraub qaum thiab pem hauv ntej.

Tam sim no, nyem "Y" 3 zaug rau: tshem tawm cov neeg siv tsis qhia npe, txwv tsis pub nkag mus hauv paus deb thiab tshem tawm cov ntawv xeem. Thaum kawg, nyem "Y" dua kom rov muaj txoj cai tshwj xeeb.

Tam sim no MariaDB thiab txhua qhov xav tau pob tau ua tiav tiav.

Kauj ruam 2: Lob tus Code thiab teeb tsa nws

Lob tus Code thiab teeb tsa nws
Lob tus Code thiab teeb tsa nws
Lob tus Code thiab teeb tsa nws
Lob tus Code thiab teeb tsa nws

Tam sim no peb muaj tag nrho cov pob khoom teeb tsa peb tuaj yeem rub tus lej.

Cov cai muaj nyob ntawm Github yog li koj tuaj yeem clone nws siv:

git clone

Qhov no yog lub ntsej muag

git clone

Qhov no yog cov backend

Txhim kho Database nws tus kheej

Txhawm rau teeb tsa lub chaw khaws ntaub ntawv, mus rau.sql cov ntaub ntawv uas nyob hauv daim nplaub tshev backend siv cov lus txib hauv qab no (nco ntsoov teeb nws rau koj tus kheej txoj hauv kev.

mysql ua

tsim database hloov pauv tawm mysql -u hauv paus -p hloov pauv <Koj_Path_to_Backend_Repo/switchit.sql

Txhim kho Apache

Tam sim no peb muaj tag nrho cov cai thiab cov ntaub ntawv teeb tsa peb tuaj yeem nruab Apache, thiab khiav peb cov backend ntawm nws. Peb yuav ua li ntawd siv:

apt -tau nruab apache2 -y

Tom qab ntawd hloov cov ntaub ntawv hauv/var/ww/html nrog cov uas nyob hauv daim nplaub tshev los ntawm cov ntawv tais ceev tseg.

Yog tias txhua yam ua tau zoo koj yuav tsum tuaj yeem txuas rau koj lub vev xaib siv APIPA chaw nyob: 169.254.10.1 hauv koj tus browser.

Kauj Ruam 3: Kev Sib Txuas Arduino

Arduino Kev Sib Txuas Lus
Arduino Kev Sib Txuas Lus

Txhawm rau nyeem peb lub ntsuas tam sim no thiab peb lub cim RFID peb tab tom siv arduino, kom ua li ntawd siv cov lej arduino uas tau hais hauv qab no. Tshaj tawm nws siv USB-A rau USB-B cable thiab arduino IDE software. Thaum rub tawm, ntu arduino ua tiav.

Tam sim no peb yuav tsum pom cov npe khoom siv ntawm PI. Txhawm rau ua kom ntseeg tau tias hauv /boot/config.txt "enable_uart = 1" tau teeb tsa raug. Tsis tas li nco ntsoov tias "console = serial0, 115200" raug tshem tawm ntawm cmdline.txt.

Tom qab ntawd txheeb xyuas cov chaw nres nkoj siv

ls -l /dev

Tom qab ntawd ib qho ntawm cov npe yuav tsum yog Arduino. Sau lub npe no ntawm arduinocom ua haujlwm hauv app.py

ser = serial. Serial ('/dev/ttyS0', 9600)

Tsuas yog ua li ntawd yog tias kev sib txuas lus txuas tsis ua haujlwm.

Kauj Ruam 4: Txuas Txuas Hloov-nws

Kev Txuas Hluav Taws Xob-nws
Kev Txuas Hluav Taws Xob-nws
Kev Txuas Hluav Taws Xob-nws
Kev Txuas Hluav Taws Xob-nws

Kev tiv thaiv txhua yam yog qhov yooj yim heev txawm hais tias koj yuav tsum ua raws li cov hauv qab no:

  • Ceev faj nrog lub qhov hluav taws xob ntawm phab ntsa, 230 volts tuaj yeem ua rau tuag taus.
  • Nco ntsoov siv qib hloov pauv rau kev sib txuas lus ntawm RPI thiab Arduino.
  • Ua ntej yuav siv lub RGB, xyuas kom koj siv tus pin liab thiab ntsuab. Kuaj qhov no ua ntej!
  • Kuaj yog tias tsis muaj dab tsi luv-circuited ua ntej powering lub Circuit Court.

Kauj ruam 5: Khiav Txoj Cai

Tam sim no txhua yam tau txuas nrog kom raug peb tuaj yeem ua haujlwm peb qhov program.

Txhawm rau kom nws ua haujlwm tau pib thaum pib tsim cov ntaub ntawv siv:

sudo nano myscript.service

Tom qab ntawv muab tshuaj txhuam (nco ntsoov siv koj tus kheej app.py cov npe:

[Chav] Nqe lus piav qhia = Hloov pauv Tom qab = network.target [Service] ExecStart =/usr/bin/python3 -u app.py WorkingDirectory = // hloov mus rau app.py directory // StandardOutput = inherit StandardError = inherit Restart = ib txwm siv = pi [Nruab] WantedBy = multi-user.target

Tom qab ntawd nias "ctrl + X" thiab luam nws rau/etc/systemd/system.

Tom qab ntawv cov lus txib ua kom nws ua haujlwm tau zoo:

sudo systemctl pab kom myscript.service

Koj tuaj yeem nrhiav cov ntaub ntawv ntau ntxiv txog qhov no ntawm RaspBerry Pi site.

Reboot thiab ua tiav

Tam sim no reboot koj PI siv:

sudo reboot -h tam sim no

Nov yog qhov koj ua Switch-it!

Ua tsaug rau kev ua raws, vam tias qhov no yuav pab tau. Yog tias koj muaj lus qhia lossis tswv yim, tsis txhob ua siab deb tawm lus.

Kauj Ruam 6: (XAV TAU) Lub Tsev Nyob

(TSIS MUAJ) Housing
(TSIS MUAJ) Housing
(TSIS MUAJ) Housing
(TSIS MUAJ) Housing
(TSIS MUAJ) Housing
(TSIS MUAJ) Housing
(TSIS MUAJ) Housing
(TSIS MUAJ) Housing

Koj tuaj yeem tsim lub tsev nyob rau koj tus kheej nyiam. Kuv siv cov ntaub ntawv hlau uas yog 40x40x5 cm nrog lub hau. Txij li thaum kuv siv cov hlau kuv yuav tsum tau laum qhov thiab siv cov kis kom tau txhua yam tawm ntawm cov phaj hauv av. Kuv tau xaiv los siv lub hauv paus uas 5V, 3.3V thiab gnd muaj. Txhua qhov kev sib txuas hluav taws xob tau txuas nrog ib daim ntawm Shrinking Tube nyob rau saum nws. Txhawm rau ua txoj kev tswj hwm cable kuv siv cov ntaub qhwv nrog cov hlua khawm.

Pom zoo: