Cov txheej txheem:

Ntse Tsev los ntawm Raspberry Pi: 5 Kauj Ruam (nrog Duab)
Ntse Tsev los ntawm Raspberry Pi: 5 Kauj Ruam (nrog Duab)

Video: Ntse Tsev los ntawm Raspberry Pi: 5 Kauj Ruam (nrog Duab)

Video: Ntse Tsev los ntawm Raspberry Pi: 5 Kauj Ruam (nrog Duab)
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
Ntse Tsev los ntawm Raspberry Pi
Ntse Tsev los ntawm Raspberry Pi

Twb muaj ntau cov khoom lag luam tawm muaj uas ua rau koj lub ntsej muag ntse dua, tab sis feem ntau ntawm lawv yog cov tswv lag luam. Tab sis vim li cas koj thiaj xav tau kev sib txuas hauv internet txhawm rau hloov lub teeb nrog koj lub smartphone? Qhov ntawd yog ib qho laj thawj rau kuv los tsim kuv tus kheej Smart Home solution.

Kuv programmed daim ntawv thov server uas khiav ntawm Raspberry Pi. Nov yog java raws qhov qhib qhov haujlwm uas tso cai rau koj teeb tsa koj lub tiaj thiab txuas rau ntau tus neeg siv khoom thiab 'chav tswj tau'. Kuv qhia qhov kev daws teeb meem uas ua haujlwm rc lub zog hloov pauv, ua suab paj nruag thiab vis dis aus ntawm Raspberry Pi, qhia qhov xwm txheej ntawm daim iav ntse thiab tuaj yeem tswj tau los ntawm Android app thiab ob lub pob zeb apps. Lub hauv paus tau tuav ntawm github

Kauj Ruam 1: Yam Koj Xav Tau

Yam Koj Xav Tau
Yam Koj Xav Tau

Txhawm rau teeb tsa Lub Tsev Ntse, koj xav tau cov khoom xyaw hauv qab no

  • Raspberry Pi tsawg kawg qauv 2 B.
  • 433 MHz tus xa, qee yam zoo li no
  • 3 jumper cables txuas Raspberry Pi thiab tus xa khoom
  • Qee lub xov tooj cua tswj nyob ntawm 433 MHz
  • Android smartphone los khiav cov neeg siv khoom app

Ib qho ntxiv, koj tuaj yeem txuas ntxiv Lub Tsev Ntse nrog ntau cov neeg siv khoom xaiv thiab cov chav zoo li no

  • Pebble smartwatch
  • Ntse Daim iav, saib txoj haujlwm no
  • 433 MHz tswj LED sawb, saib qhov no

Kauj Ruam 2: Npaj Raspberry Pi rau 433 MHz

Npaj Raspberry Pi rau 433 MHz
Npaj Raspberry Pi rau 433 MHz
Npaj Raspberry Pi rau 433 MHz
Npaj Raspberry Pi rau 433 MHz

Hauv cov theem hauv qab no koj xav tau nkag mus rau kab hais kom ua ntawm Raspberry Pi. Txhawm rau kom nkag mus tau koj tuaj yeem nyeem phau ntawv qhia no

Txuas tus 433 MHz tus xa nrog Raspberry Pi raws li qhia hauv daim duab saum toj no

  • GND (tus xa) 6 GND (raspi)
  • VCC (tus xa) 2 +5V (raspi)
  • DATA (tus xa) 11 GPIO 17 (raspi)

Thov kuj txuas 17cm tus kav hlau txais xov rau ANT (tus xa) tus pin. Qhov ntawd nce lub teeb liab tseem ceeb.

Txij li thaum peb xav tau qee lub tsev qiv ntawv los ntawm lwm qhov chaw cia khoom git, peb yuav tsum teeb tsa git

sudo apt-tau nruab git-core -y

Txhawm rau teeb tsa Raspberry Pi rau 433 MHz kev sib txuas lus peb xav tau xov txuas Pi lub tsev qiv ntawv kom ua tau zoo dua ntawm GPIOs.

git clone git: //git.drogon.net/wiringPi

cd wiringPi./build

Tom qab ntawd peb xav tau lub tsev qiv ntawv uas ua haujlwm feem ntau rc cov txheej txheem muab khoom siv hluav taws xob.

git clone git: //github.com/dabastynator/rcswitch-pi.git

cd rcswitch-pi ua cp xa/usr/bin/

Qhov 'xa' ua tiav tso cai rau koj xa cov lej txhawm rau hloov pauv feem ntau ntawm cov khoom siv fais fab.

Hauv kuv lub Tsev Ntse teeb kuv kuj muaj rc LED sawb piav qhia los ntawm cov lus qhia no: https://www.instructables.com/id/RC-controlled-LED… Txhawm rau teeb cov xim rau cov hlua LED no koj xav tau lwm qhov xa ua haujlwm uas tso cai rau koj kom xa ib qho Integer tus nqi (Uas cim xim).

Yog li ntawd, suav sau sendInt.cpp hauv rcswitch-pi repo thiab txav nws mus rau/usr/bin/sendInt.

sudo g ++ sendInt.cpp -o/usr/bin/sendInt /home/pi/rcswitch-pi/RCSwitch.o -I/tsev/pi/rcswitch -pi -lwiringPi

Tam sim no koj yuav tsum tam sim no tuaj yeem xa rc cov lus txib nrog ob qhov ua haujlwm/usr/bin/xa thiab/usr/bin/sendInt

Kauj Ruam 3: Teeb Smart Home Server

Ua ntej tshaj plaws koj yuav tsum tau teeb tsa ntau pob. Daim Ntawv Thov Tsev Ntse yog java raws thiab ua haujlwm zoo nrog openjdk-11. Kuv tsis paub meej txog lwm qhov java runtime ib puag ncig. Tus mplayer yog qhov tsawg tshaj plaws hais kom ua kab-suab paj nruag neeg uas ua ntawv. Omxplayer siv Raspberry Pi cov duab rau kev yees duab, yog li qhov no yuav tsum siv rau cov yeeb yaj kiab. Qhov program ntsaum xav tau los tsim daim ntawv thov java.

sudo apt-tau nruab mplayer omxplayer openjdk-11-jdk ntsaum -y

Teeb cov npe rau cov thawv ntawv thiab rau cov cav.

sudo mkdir /xaiv /neo

sudo chown pi: pi/opt/neo mkdir/home/pi/Logs

Kho kho kab ntawv pib kom pib daim ntawv thov txiav ntawm khau raj. Yog li ntawd theej cov ntawv txuas hauv tsev-ntse mus rau hauv phau ntawv teev npe /etc/init.d/ Kuv kuj tau tsim ib tsab ntawv hauv/usr/bin/uas cov lus txib rau kab ntawv txuas, yog li kuv tsuas yog nkag mus hauv tsev-ntse mus rau lub console kom ua cov lus txib.

sudo cp ntse-tsev /etc/init.d/smart-home

sudo chmod +x /etc/init.d/smart-home sudo sh -c "ncha '#!/bin/bash'>/usr/bin/smart -home" sudo sh -c "echo '/etc/init. d/smart-home / $ 1 '>>/usr/bin/smart-home "sudo chmod +x/usr/bin/ntse-tsev sudo hloov tshiab-rc.d ntse-tsev tsis tu ncua

Tam sim no nws yog lub sijhawm los txheeb xyuas qhov chaw cia khoom thiab tsim daim ntawv thov. Yog tias koj tsis xav sau nws tus kheej, koj tuaj yeem rub tawm qhov txuas smarthome.jar thiab txav mus rau/opt/neo/

git clone [email protected]: dabastynator/SmartHome.git

ntsaum -f SmartHome/de.neo.smarthome.build/build.ant build_remote cp SmartHome/de.neo.smarthome.build/build/jar/*/opt/neo/

Sim pib lub tsev ntse thiab tshawb xyuas cov ntaub ntawv teev cia. Txhawm rau nkag mus rau GPIOs, daim ntawv thov yuav tsum tau pib los ntawm sudo.

sudo ntse-tsev pib

miv Logs/smarthome.log

Koj yuav tsum pom cov lus yuam kev Configuration file tsis muaj nyob uas taw tes peb mus rau kauj ruam tom ntej. Cov chaw cia khoom muaj cov ntawv nyeem uas piav qhia cov ntaub ntawv teeb tsa. Koj tuaj yeem pom qhov ua tau zoo ntawm github:

Luam qhov xml no rau /home/pi/controlcenter.xml, tom qab ntawd teeb tsa qhov chaw rau koj lub server media thiab hloov cov ntsiab lus raws li koj xav tau. Thaum koj tau ua tiav kev teeb tsa thiab rov pib dua lub tsev ntse (sudo smart-home restart) koj yuav tsum pom cov ntsiab lus hauv qab no hauv smarthome.log

24.05-08: 26 REMOTE INFORMATION los ntawm de.neo.smarthome.cronjob. CronJob@15aeb7ab: Teem sijhawm ua haujlwm cron

24.05-08: 26 REMOTE INFORMATION los ntawm [trigger.light]: Tos 79391760 ms rau kev ua tiav 24.05-08: 26 RMI INFORMATION los ntawm Ntxiv web-handler (5061/ledstrip) 24.05-08: 26 RMI INFORMATION los ntawm Ntxiv web-handler (5061 /nqis tes ua) 24.05-08: 26 RMI INFORMATION los ntawm Ntxiv web-handler (5061/mediaserver) 24.05-08: 26 RMI INFORMATION los ntawm Ntxiv web-handler (5061/hloov) 24.05-08: 26 RMI INFORMATION los ntawm Ntxiv web-handler (5061/controlcenter) 24.05-08: 26 RMI INFORMATION los ntawm Pib webserver nrog 5 tus tuav (localhost: 5061) 24.05-08: 26 REMOTE INFORMATION by Controlcenter: Ntxiv 1. tswj chav: MyUnit (xyz)…

Tam sim no lub web-server tau ua haujlwm:-)

Kauj Ruam 4: Teeb Cov Neeg Siv Khoom

Teeb Cov Neeg Siv Khoom
Teeb Cov Neeg Siv Khoom
Teeb Cov Neeg Siv Khoom
Teeb Cov Neeg Siv Khoom
Teeb Cov Neeg Siv Khoom
Teeb Cov Neeg Siv Khoom

Smartphone Android tus neeg siv khoom

Cov chaw cia khoom git rau daim ntawv thov ntse hauv tsev tseem muaj cov hauv paus rau cov neeg siv khoom hauv, yog li koj tuaj yeem suav nws tus kheej. Tab sis kuv txuas lub APK rau cov kauj ruam no, uas ua rau nws yooj yim dua. Thawj zaug koj pib lub app, nws nug koj rau tus neeg rau zaub mov, zoo li hauv thawj daim duab saum toj no. Nkag mus rau qhov url ntawm server thiab token kev nyab xeeb.

Qhov ntawd yuav tsum yog nws. Tam sim no koj tau nkag mus rau tus neeg rau zaub mov thiab tswj hwm koj lub tiaj tus, ua si nkauj thiab saib cov vis dis aus nyob deb ntawm koj li Raspberry Pi. Nco ntsoov tias koj tuaj yeem ntxiv cov cuab yeej rau koj lub vijtsam hauv tsev, uas ua rau kev hloov pauv thiab suab paj nruag-tswj tau yooj yim dua.

Smartwatch Pebble tus neeg siv khoom

Qhov chaw rau ob tus neeg siv peb lub pob zeb yog tuav ntawm github. Ib qho app qhia txog cov nkauj ua si tam sim no:

Qhov app thib ob ua rau peb nqis tes ua: https://github.com/dabastynator/PebbleControl Qhov ua rau muaj npe yog: mobile.come_home mobile.leaving thiab mobile.go_to_bed. Yog tias koj txhais cov xwm txheej-txoj cai rau qhov ua rau hauv koj teeb tsa-xml koj ua rau lawv los ntawm koj lub moos.

Nws yog txhua qhov qhib-qhov, tab sis koj tsis tas yuav suav nws koj tus kheej, Kuv kuj txuas nrog pebble apps. Rub tawm PBW nrog koj lub xov tooj ntawm tes, koj lub xov tooj yuav tsum teeb tsa lawv ntawm koj lub moos. Pebble apps xav tau kev teeb tsa los tham nrog tus neeg rau zaub mov. Kuv tau txuas nrog lub vijtsam li cas kuv cov chaw zoo li.

Smartwatch Garmin tus neeg siv khoom

Kuj tseem muaj cov neeg siv khoom siv rau Garmin Smartwatches. Lub app muaj nyob hauv garmin txuas app-khw thiab tuaj yeem teeb tsa ntawm no:

apps.garmin.com/en-US/apps/c745527d-f2af-4…

Smart Mirror tus neeg siv khoom

Kuv twb tau tsim cov lus qhia uas piav qhia yuav ua li cas thiaj tsim Smart Mirror, saib qhov no https://www.instructables.com/id/Smart-Mirror-by-R…. Qhov chaws tseem muaj nyob rau ntawm github: https:// github.com/dabastynator/SmartMirror. The software ntawm Ntse Daim iav nyeem qhov teeb tsa los ntawm cov ntaub ntawv smart_config.js uas tsis yog ib feem ntawm git chaw cia khoom. Cov ntsiab lus ntawm cov ntawv teeb tsa yuav tsum zoo li cov npe no:

var mOpenWeatherKey = 'koj-qhib-wheather-qhov tseem ceeb';

var mSecurity = 'koj-kev ruaj ntseg-token';

Koj kuj tseem yuav tsum tau kho thawj ob kab ntawm cov ntawv smart_mirror.js txhawm rau txheeb xyuas Smart Home server IP chaw nyob thiab qhov chaw kom tau txais huab cua zoo.

Ntau tus neeg siv khoom

Daim ntawv thov server yog lub vev xaib yooj yim. Qhov no ua rau koj ua rau muaj kev nqis tes ua los ntawm ib tus neeg siv khoom koj xav tau los ntawm kev hu xov tooj yooj yim. Hauv cov vis dis aus-kuv qhia Android tus neeg ua haujlwm ua ke nrog AutoVoice. Qhov no ua rau kuv ua rau muaj xwm txheej nrog cov lus txib yooj yim. Piv txwv "ok google, sijhawm pw" tuaj yeem ua rau mobile.go_to_bed. Tab sis koj tseem tuaj yeem ua web-hu rau piv txwv los ntawm IFTTT. Yuav ua li cas txog qhov daj ntsais ntsais LED sawb rau email ceeb toom?

Koj tuaj yeem nug tus neeg rau zaub mov kom ua tau lub vev xaib-hu zoo li cov txuas hauv qab no (hloov ip, chaw nres nkoj thiab token los ntawm koj lub teeb tsa)

localhost: 5061/controlcenter/api? token = secu…

localhost: 5061/action/api? token = ruaj ntseg-rau …

localhost: 5061/mediaserver/api? token = securi…

localhost: 5061/hloov/api? token = ruaj ntseg-rau …

localhost: 5061/ledstrip/api? token = ruaj ntseg-…

Kauj Ruam 5: Xaus

Tseem muaj qee qhov tshwj xeeb los siv: Txij li thaum lub server muab tsuas yog lub vev xaib-api cov neeg siv yooj yim ua ntau qhov kev xaiv tsa. Txhawm rau txo qhov kev xaiv tsa kuv xav tau MQTT kev koom ua ke rau kev ceeb toom zoo dua. Tsis tas li wifi cov khoom siv hluav taws xob yuav tsum ua kom ntseeg tau ntau dua li rc cov khoom siv hluav taws xob vim tias rc tsuas yog ib txoj hauv kev sib txuas lus.

Nws ua rau muaj kev lom zem heev tsim rau txoj haujlwm no. Thiab nws zoo nkauj heev los tswj lub tiaj los ntawm ntau lub cuab yeej, txawm tias kev sib txuas hauv is taws nem tawg.

Pom zoo: