Cov txheej txheem:

Khawv koob iav nrog Xov Xwm, Huab Cua, Tswb, Timer thiab Todolist: 9 Kauj Ruam
Khawv koob iav nrog Xov Xwm, Huab Cua, Tswb, Timer thiab Todolist: 9 Kauj Ruam

Video: Khawv koob iav nrog Xov Xwm, Huab Cua, Tswb, Timer thiab Todolist: 9 Kauj Ruam

Video: Khawv koob iav nrog Xov Xwm, Huab Cua, Tswb, Timer thiab Todolist: 9 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim
Khawv koob iav nrog Xov Xwm, Huab Cua, Tswb, Timer thiab Todolist
Khawv koob iav nrog Xov Xwm, Huab Cua, Tswb, Timer thiab Todolist
Khawv koob iav nrog Xov Xwm, Huab Cua, Tswb, Timer thiab Todolist
Khawv koob iav nrog Xov Xwm, Huab Cua, Tswb, Timer thiab Todolist

Daim iav Khaub Ncaws yog daim iav tshwj xeeb ib txoj hauv kev nrog cov duab tom qab nws. Cov zaub, uas txuas nrog Raspberry Pi, qhia cov ntaub ntawv xws li huab cua, chav sov, sijhawm, hnub tim, todolist thiab ntau ntxiv. Koj kuj tseem tuaj yeem ntxiv lub microphone thiab teeb tsa tus pab ntse. Qhov muaj peev xwm yog qhov kawg.

Txoj haujlwm no tuaj yeem kim heev, ib qho ntawm cov khoom kim tshaj plaws uas koj xav tau yog qhov tseeb ntawm cov zaub. Tias yog vim li cas kuv rov ua dua cov zaub los ntawm lub khoos phis tawj qub. Txawm li cas los xij kuv pom zoo kom tau txais qhov loj, ci ci, siab sib piv kom ua qhov haujlwm no. Nws muaj nqis.

Daim iav kuv ua tau muaj cov yam ntxwv no:

  • Xov xwm los ntawm tus neeg siv-xaiv RSS pub
  • Huab cua
  • Sab hauv kub
  • Lub tswb ceeb toom
  • Lub timer system
  • Ib todolist
  • Ntau tus neeg siv: cov kab ntawv coj xim thiab cov xov xwm hloov pauv raws tus neeg siv tau xaiv.

Khoom siv

Txhawm rau tsim Daim iav Khaub Ncaws, koj yuav xav tau:

  • Ib daim iav tsom iav
  • Ntoo
  • Ib Raspberry Pi
  • Micro SD daim npav (8+GB)
  • Ib daim ntawv qhia zaub mov
  • Ob tus neeg hais lus 20W
  • MAX9744 20W lub tshuab ua kom lub zog hais lus
  • 1m 30-coj WS2801 ledstrip
  • DS18B20 1-xaim ntsuas kub
  • HC-SR501 Infrared sensor
  • Lub teb chaws encoder
  • Lub saib lossis lub laptop qub saib

    Yog tias koj siv lub khoos phis tawj qub qub, koj yuav tsum yuav lub khoos phis tawj tso saib lub laptop. Koj tuaj yeem tau txais cov no los ntawm AliExpress, Ebay lossis Amazon. Tsuas yog tshawb rau tus lej ntawm koj cov zaub

Koj tseem yuav xav tau cov khoom me me hauv qab no:

  • Ib diode
  • Ib qho 4.7k Ohm resistor
  • Ib qho 470 Ohm resistor
  • Cov xov txuas txuas cov cim rau Raspberry Pi

Thiab cov khoom siv fais fab no:

  • 5V 2A txhawm rau txuas lub zog coj
  • 12V 2A txhawm rau ua kom pom cov duab
  • 12V 2A txhawm rau ua kom lub suab nrov nrov
  • 5.1V 3A txhawm rau ua kom lub zog Raspberry Pi (siv lub zog RPi raug cai)

Kauj ruam 1: Txhim kho Raspbian

Cov zaub thiab txhua yam khoom siv tom qab daim iav tau siv los ntawm Raspberry Pi. Koj yuav tsum tau teeb tsa Raspbian, Pi txoj haujlwm ua haujlwm tsis raug, mus rau SD daim npav.

  1. Rub tawm Win32 Disk imager. Linux thiab MacOS cov neeg siv tuaj yeem siv qee yam zoo li Etcher.
  2. Rub tawm qhov tseeb Raspbian duab los ntawm Raspberry Pi lub vev xaib. Xaiv qhov kev xaiv 'Raspbian Buster nrog lub desktop'
  3. Qhib Win32 Disk Imager thiab sau cov duab rau SD daim npav.

Daim npav SD tam sim no yuav luag tiav. Peb tsuas yog xav kom ntseeg tau tias peb tuaj yeem txuas rau Raspberry Pi nyob deb:

  1. Mus rau SD card's 'boot' muab faib siv koj lub kaw lus cov ntaub ntawv tshawb nrhiav.
  2. Ntxiv cov ntaub ntawv hu ua 'ssh' yam tsis muaj kev txuas ntxiv.
  3. Ntxiv 'ip = 169.254.10.1' (tsis hais nqe lus) mus rau qhov kawg ntawm thawj kab ntawm 'cmdline.txt'.

Muaj kev nyab xeeb tshem daim npav SD los ntawm koj lub computer, muab tso rau hauv koj li Raspberry Pi thiab khau raj nws.

Kauj ruam 2: Kev teeb tsa WiFi

Txhawm rau tshuaj xyuas WiFi network, ua raws cov lus txib hauv qab no:

sudo iw dev wlan0 scan | grep SSID cov

Koj yuav pom cov npe ntawm txhua SSIDs koj Raspberry Pi tuaj yeem txuas rau.

Tsim lub network nkag nrog tus lej nkag los nkag los ntawm kev ua cov lus txib hauv qab no thiab nkag mus rau koj lub network tus password:

wpa_passphrase "YOUR_NETWORK_SSID_HERE"

Tam sim no muab cov ntawv tso tawm ntawm cov lus hais los saum no hauv cov ntawv no:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Tam sim no rov pib dua Raspberry Pi. Koj yuav txuas nrog internet.

Kauj Ruam 3: Kev teeb tsa software & teeb tsa

Txog qhov haujlwm no, koj yuav tsum rub cov pob khoom no rau koj Raspberry Pi:

pip3 nruab mysql-txuas-sej-flask-socketio flask-cors gevent gevent-websocket adafruit-circuitpython-ws2801 adafruit-circuitpython-max9744

sudo apt nruab apache2 mariadb-server

Ntxiv kab no rau hauv qab ntawm /boot/config.txt kom muaj suab los ntawm GPIO pins 12 (sab laug) thiab 13 (txoj cai):

dtoverlay = audremap

Siv raspi-teeb tsa los teeb tsa koj cov lus daws teeb meem thiab pab kom i2c, Ib-xaim thiab SPI. Kuj teeb tsa txoj kev khau raj rau 'Desktop Autologin'.

Hauv/etc/xdg/lxsession/LXDE-pi/autostart, ntxiv cov hauv qab no:

@xset s off@xset -dpms@xset s noblank@chromium -browser --kiosk 127.0.0.1/mirror.html # ntsaws chromium tom qab khau raj thiab qhib lub vev xaib hauv hom puv npo

Qhov no qhib qhov browser ntawm nplooj ntawv raug thaum LXDE (Raspbian lub desktop ib puag ncig) thauj khoom. Tsis tas li tshem tawm lossis tawm tswv yim kab @xscreensaver kom xiam cov screensaver.

Github chaw cia khoom

Clone kuv qhov chaw cia GitHub thiab muab cov ntsiab lus ntawm Frontend nplaub tshev hauv/var/www/html. Peb yuav xav tau Backend nplaub tshev tom qab.

Kauj ruam 4: Database

Cov Database
Cov Database

Nov yog cov phiaj xwm phiaj xwm, ua kom zoo rau 3NF. Nws khaws txhua lub tswb ceeb toom, cov xov xwm, cov neeg siv, cov ntaub ntawv ntsuas, suab thiab tus todolist.

  1. Siv MySQL Workbench txhawm rau nkag mus rau koj li pi's database server (mariadb)
  2. Tsim cov ntaub ntawv siv cov txheej txheem no thiab ntxig koj cov ntaub ntawv.
  3. Kho kom raug config.py hauv Backend nplaub tshev ntawm kuv GitHub chaw cia khoom: hloov lub npe database, koj lub npe siv, thiab tus password.
  4. Kho kom raug app.py thiab hloov OpenWeatherMap API URL rau koj tus kheej. (Tsim koj tus kheej ntawm no)

Kauj Ruam 5: Txhim Kho Daim iav

Txhim Kho Daim iav
Txhim Kho Daim iav
Txhim Kho Daim iav
Txhim Kho Daim iav
Txhim Kho Daim iav
Txhim Kho Daim iav

Kuv ua tus thav duab nyob ib ncig ntawm daim iav siv Miter txuas nrog hlau fab. Cov ntoo ntoo uas kuv siv yog 18 hli tuab thiab 10cm dav. Hauv cov duab koj tuaj yeem pom qhov ntsuas tseeb rau daim iav 45cm x 60cm. Hauv qab daim iav yog txhua yam khoom siv hluav taws xob, yog li xyuas kom koj cov phiaj yog dav txaus kom haum rau lawv.

Kuv siv cov hlau txuas los txuas cov neeg hais lus rau lub thav duab. Txoj kev ntawd lawv tsis so ntawm daim iav, txo kev vibration kev ntxhov siab ntawm iav.

Kauj Ruam 6: Cov Khoom Siv Hluav Taws Xob

Cov Electronics
Cov Electronics
Cov Electronics
Cov Electronics

Ua raws li cov lus piav qhia saum toj no los tsim lub Circuit Court. Kuv siv daim kab xev los kho cov khoom siv hluav taws xob mus rau daim iav.

Kauj Ruam 7: Kho Cov Khoom Siv Hluav Taws Xob hauv Tus Kheej

Fitting Cov Khoom Siv Hluav Taws Xob hauv Tus Kheej
Fitting Cov Khoom Siv Hluav Taws Xob hauv Tus Kheej
Fitting Cov Khoom Siv Hluav Taws Xob hauv Tus Kheej
Fitting Cov Khoom Siv Hluav Taws Xob hauv Tus Kheej

Tom qab txuas cov neeg hais lus rau cov hlau txuas rau saum, ntxiv cov khoom siv hluav taws xob tas mus rau daim iav. Kuv kuj tau muab daim txiag ntoo nyias ua nruab nrab ntawm daim iav thiab cov khoom siv hluav taws xob, yog li tsis txhob siv cov khoom siv hluav taws xob mus rau daim iav, Kuv tau kaw cov khoom siv hluav taws xob mus rau cov ntoo ntoo. Lub khoos phis tawj saib yog lub vaj huam sib luag dawb nyob hauv qab ntawm daim iav.

Raws li koj tuaj yeem pom hauv cov duab, Kuv tau ntsaws tag nrho lub zog hloov pauv sab hauv lub qhov (socket) ntau li ntawd tsuas muaj ib txoj hlua txuas tawm ntawm tus ncej. Qhov no yog vim li cas kuv xav tau cov dav dav txaus (10cm).

Kuv tau hlais 2cm-dav qhov nyob rau sab xis ntawm daim iav rau lub tshuab nkag teb chaws kom haum los ntawm. Qhov no tso cai rau koj yooj yim hloov ntim (tig) lossis tso lub sijhawm thiab lub tswb nrov (thawb).

Kuv tau hlais ob lub qhov 8 hli ntawm ob sab ntawm daim iav txhawm rau txhawm rau txuas cov kab hluav taws xob rau cov kab.

Kauj Ruam 8: Tiav Touches

Tiav Touches
Tiav Touches
Tiav Touches
Tiav Touches
Tiav Touches
Tiav Touches

Kuv ntxiv daim ntaub dub rau tom qab ntawm daim iav kom zais cov khoom siv hluav taws xob. Nws kuj ua rau tsaus nti sab hauv ntawm rooj plaub, uas ua rau nws nyuaj rau pom cov xov hlau hla daim iav. Kuv txuas nws nrog velcro, ua kom yooj yim nkag mus rau cov khoom siv hluav taws xob thaum xav tau.

Luam cov Backend nplaub tshev los ntawm kuv Github chaw cia khoom mus rau qhov chaw koj yuav nco tau.

Ntxiv ib chav systemd yog li ntawv nab nab khiav ntawm khau raj:

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

[Chav]

Nqe lus piav qhia = Cov kev pabcuam rau magicmirror python tsab ntawv Tom qab = network.target [Service] ExecStart =/usr/bin/python3 -u app.py WorkingDirectory =/home/pi/magicMirror/Backend StandardOutput = inherit StandardError = inherit Restart = ib txwm siv = pi [Nruab] WantedBy = multi-user.target

Hloov 'WorkingDirectory' mus rau Backend directory, thiab hloov Tus Neeg Siv rau koj tus kheej lub npe.

Kauj ruam 9: Sib cuam tshuam nrog Webapp

Sib tham nrog Webapp
Sib tham nrog Webapp
Sib tham nrog Webapp
Sib tham nrog Webapp
Sib tham nrog Webapp
Sib tham nrog Webapp
Sib tham nrog Webapp
Sib tham nrog Webapp

Caij ntoj ke mus rau tus IP chaw nyob (uas yog ntawm cov zaub). Koj yuav pom lub vev xaib mobile-thawj nrog cov yam ntxwv hauv qab no:

  • Ib qho kev sib tham sib ntsuas kub
  • Ib lub sij hawm. Thaum lub sijhawm ua haujlwm, koj tseem yuav pom suav rov qab ntawm daim iav nws tus kheej.
  • Lub tswb ceeb toom
  • Qhov chaw teeb tsa, qhov twg koj tuaj yeem hloov kho cov neeg siv, cov xov xwm thiab cov hais lus ntim.
  • Ib todolist. Cov khoom ua si yuav muab tso rau ntawm daim iav

Mirror.html yog nplooj ntawv uas tau tshwm rau ntawm Daim iav Khaub Ncaws. Kuv ntxiv qhov piv txwv hauv cov duab saum toj no.

Pom zoo: