Cov txheej txheem:
- Kauj Ruam 1: PowerHub Webserver Project & Internet Enabled Outlet Setup Instructions
- Kauj ruam 2: Pab kom RaspberriPi Advanced Options
- Kauj Ruam 3: Pib Txhim Kho Cov Pob Yuav Tsum Muaj
- Kauj Ruam 4: Txhim Kho WEB API
- Kauj Ruam 5: Cov Khoom Xav Tau
- Kauj Ruam 6: Tsim Lub Qhov Hluav Taws Xob
- Kauj ruam 7: Nruab Nyees khawm
- Kauj Ruam 8: Hlau Txuas
- Kauj Ruam 9: Ntxiv Xov Tooj thiab Sib Dhos Duab
- Kauj Ruam 10: Daim duab thaiv
- Kauj Ruam 11: Kuaj Qhuav Qhuav
- Kauj ruam 12: Teem Startup Scripts
Video: Internet Enabled Power Outlet: 13 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
PowerHub Webserver Project & Internet Enabled Outlet Setup Instructions
Lub hauv paus cov ntaub ntawv tseem nyob ruaj khov rau Internet qhib lub teeb thiab qhov hluav taws xob hauv koj lub tsev!
Kauj Ruam 1: PowerHub Webserver Project & Internet Enabled Outlet Setup Instructions
Lub hauv paus cov ntaub ntawv tseem nyob ruaj khov rau Is Taws Nem qhib lub teeb thiab qhov hluav taws xob hauv koj lub tsev
Flashing RaspberriPi Hard Disk/Install Required Software (Using Ubuntu Linux) Download "RASPBIAN JESSIE LITE"
Tsim koj lub hard disk tshiab rau DashboardPI
Ntxig lub microSD rau koj lub khoos phis tawj ntawm USB adapter thiab tsim cov duab disk siv cov lus txib dd
Nrhiav koj daim npav microSD tso ntawm df -h hais kom ua, unmount nws thiab tsim cov duab disk nrog daim disk theej daim ntawv dd
$ df -h/dev/sdb1 7.4G 32K 7.4G 1%/media/XXX/1234-5678
$ umount /dev /sdb1
Ceev faj: nco ntsoov tias cov lus txib yog qhov tseeb, koj tuaj yeem ua rau lwm lub disks puas tsuaj nrog cov lus txib no
yog = qhov chaw ntawm RASPBIAN JESSIE LITE duab cov ntaub ntawv ntawm = qhov chaw ntawm koj daim npav microSD
$ sudo dd bs = 4M yog =/path/to/raspbian-jessie-lite.img ntawm =/dev/sdb (ceeb toom: qhov no, nws yog/dev/sdb,/dev/sdb1 yog lub koomhaum uas twb muaj lawm muab faib rau ntawm microSD)
Teeb koj li RaspberriPi
Ntxig koj daim npav microSD tshiab rau raspberrypi thiab siv nws nrog lub ntsuas saib txuas nrog rau HDMI chaw nres nkoj
ID nkag mus
neeg siv: pi pass: raspberry
Hloov koj tus lej password rau kev nyab xeeb
sudo passwd pib
Kauj ruam 2: Pab kom RaspberriPi Advanced Options
sudo raspi-teeb tsa
Xaiv: 1 Nthuav Cov Ntaub Ntawv System
9 Advanced Options
A2 Hostname hloov nws mus rau "WIFI-OUTLET"
A4 SSH Pab kom SSH Server
A7 I2C Pab kom i2c interface
Pab kom Askiv/Asmeskas Keyboard
sudo nano/etc/default/keyboard
Hloov cov kab hauv qab no: XKBLAYOUT = "peb"
Rov pib dua PI rau Keyboard hloov pauv / cov txheej txheem txheej txheem hloov pauv kom muaj txiaj ntsig
$ sudo kaw -r tam sim no
Auto-Txuas rau koj li WiFi
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Ntxiv cov kab hauv qab no kom muaj koj cov raspberrypi txuas nrog koj lub WiFi hauv tsev (yog tias koj lub wireless network npe "linksys" piv txwv, piv txwv li hauv qab no)
network = {ssid = "linksys" psk = "WIRELESS PASSWORD HERE"} Rov pib PI txuas rau WiFi network
$ sudo kaw -r tam sim no
Tam sim no tias koj tus PI yog qhov kawg ntawm lub network hauv zej zog, koj tuaj yeem nkag mus rau nws deb ntawm SSH. Tab sis ua ntej koj yuav tsum tau txais tus IP chaw nws tam sim no muaj.
$ ifconfig Saib rau "inet addr: 192.168. XXX. XXX" hauv cov lus txib hauv qab no tso tawm rau koj tus PI IP Chaw Nyob
Mus rau lwm lub tshuab thiab nkag mus rau koj li raspberrypi ntawm ssh
$ ssh [email protected]. XXX. XXX
Kauj Ruam 3: Pib Txhim Kho Cov Pob Yuav Tsum Muaj
$ sudo apt-tau hloov tshiab
$ sudo apt-tau hloov tshiab
$ sudo apt-tau nruab vim git nab-thov python-gpiozero python-smbus i2c-tools python-imaging python-smbus build-essential python-dev rpi.gpio python3 python3-pip libi2c-dev python3-spidev nab hab sej-spidev
Hloov kho thaj chaw sijhawm hauv cheeb tsam
$ sudo dpkg-reconfigure tzdata
xaiv koj lub sijhawm siv lub interface
Teeb cov npe yooj yim l hais kom ua [xaiv tau]
vi ~/.bashrc
ntxiv cov kab hauv qab no:
alias l = 'ls -lh'
qhov chaw ~/.bashrc
Txhim kho VIM default syntax highlighting [yeem]
sudo vi/etc/vim/vimrc
tsis pom zoo cov kab hauv qab no:
syntax yog
Nruab i2c Python Tsav Tsheb
Kauj Ruam 4: Txhim Kho WEB API
Cov lus qhia hauv qab no yuav tso cai rau koj los tsim lub hauv paus nruab nrab uas piav qhia rau ntau yam wifi qhib lub qhov hluav taws xob thiab cov phab ntsa hloov pauv uas koj tuaj yeem tsim, cov cuab yeej twg tau qhib thiab tawm. Nov yog tsab ntawv PHP me me tso rau ntawm lub vev xaib uas koj xaiv. Nws muaj cov API hauv qab no kom tau txais thiab teeb tsa cov ntaub ntawv rau nws. Nco tseg: tsis txhob hnov qab suav nrog.htaccess cov ntaub ntawv kom tsim nyog URL txoj hauv kev los ua qhov chaw.
Nruab qhov "index.php", "values/" folder thiab settings.php (teeb tsa rau koj tus kheej qhov tseem ceeb) rau PHP qhib webserver ntawm koj xaiv. Tus lej tseem ceeb zais cia hauv "settings.php" cov ntaub ntawv yuav tsum phim tus nqi zais cia uas koj yuav teeb tsa hauv "settings.py" cov ntaub ntawv. Qhov no yuav nyob rau theem pib tiv thaiv lwm lub vev xaib los ntawm kev teeb tsa / sau qhov tseem ceeb, tig rau koj li khoom siv, tam sim no koj xav tau qhov hashed API qhov tseem ceeb hauv HTTP thov header kom ua li ntawd.
API txhawb nqa cov yam ntxwv hauv qab no, rau txoj haujlwm no peb yuav siv tsuas yog "tus chij" qhov muaj txiaj ntsig uas yog tus nqi boolean uas qhia qhov hloov pauv kom qhib thiab tua. Tej zaum yog tias koj xav ua kom zoo dua qhov "nyeem" qhov txiaj ntsig koj tuaj yeem muaj nws yog li yog tias chav sov tau kub dhau los ntawm kev ntsuas kub nyob ntawd, nws tuaj yeem tig lub qhov rai kiv cua, thiab lwm yam.
Tau txais Txoj Cai
Clone cov haujlwm hauv qab no los ntawm GitHub kom tau txais txoj cai los ua haujlwm webserver thiab qhov hluav taws xob RaspberryPI.
github.com/khinds10/PowerHub
API Endpoints thaum khiav ntawm webserver
myhost/message (tau txais cov lus tam sim no teeb)
myhost/message/set (HTTP POST a string string value to this URL to set a new message)
myhost/flag/{id} (tau txais tam sim no boolean xwm txheej ntawm tus chij los ntawm tus lej: {id})
myhost/chij/tag nrho (tau txais tag nrho cov xwm txheej tam sim no boolean ntawm txhua tus chij raws li kab lus)
myhost/flag/{id}/set (teeb tsa tam sim no boolean xwm txheej rau 'tseeb' rau tus chij los ntawm tus lej: {id})
myhost/flag/{id}/unset (teeb tsa tam sim no boolean xwm txheej rau 'cuav' rau tus chij los ntawm tus lej: {id})
myhost/nyeem/{id} (tau txais tus nqi nruab nrab tam sim no rau kev nyeem los ntawm tus lej: {id})
myhost/nyeem/tag nrho (tau txais tus nqi nruab nrab tam sim no rau txhua qhov kev nyeem ua ib qho array)
myhost/nyeem/{id}/teeb tsa (HTTP POST tus lej tus lej nyoos rau qhov URL no ntxiv tus nqi tshiab rau tam sim no xam nruab nrab) - saib hauv qab no seb muaj pes tsawg tus nqi hauv tag nrho suav nrog tus nqi nruab nrab Kev teeb tsa Tus lej 'nyeem' raug suav ua qhov nruab nrab ntawm qee tus lej ntawm kev nyeem tsis ntev los no tseem muaj nuj nqis. Teem cov hauv qab no tas mus li pes tsawg ntawm cov ntawv nyeem tshiab tam sim no yuav tsum suav nrog los tsim qhov nruab nrab.
$ readingsAverageLimit = 5;
Datastore Server yuav ua kom muaj nuj nqis rau cov ntaub ntawv yooj yim nyob ntawm kev teev npe cov lus pom hauv qab no. Nco tseg: {id} yuav raug hloov los ntawm tus lej tiag uas tau nthuav tawm los ntawm qhov kev thov nkag URL.
$ valueFileFolder = 'qhov tseem ceeb' (lub npe ntawm daim nplaub tshev kom muaj cov ntaub ntawv ntsuas) $ messageFileName = 'message.msg' (lub npe ntawm cov ntawv xa ntawv) $ readingsFilesNames = 'nyeem {id}.avg' (lub npe ntawm CSV nruab nrab nyeem cov ntawv) $ flagFilesNames = 'chij {id}.flg' (lub npe ntawm tus chij tus nqi boolean tus chij)
Xyuas kom tseeb tias txhua cov ntaub ntawv tus nqi raug sau los ntawm systemchmod 777 qhov tseem ceeb/*
Kauj Ruam 5: Cov Khoom Xav Tau
1 nti qhov pom (rau kev xyaum)
5V 2 Channel Relay Module
Duplex Receptacle Wall Phaj
Duplex Receptacle
Pi Zero W
Nto Mount Backbox Dual Gang
Dawb Illuminated Laub Khawm
Kauj Ruam 6: Tsim Lub Qhov Hluav Taws Xob
Rhuav Tawm Tabs
Ua txhaum lub tab ntawm ib sab ntawm lub qhov hluav taws xob kom txhua lub qhov (socket) qhib/tawm ntawm nws tus kheej
Kauj ruam 7: Nruab Nyees khawm
Ntawm lub ntsej muag qhov hluav taws xob siv 1 qhov pom pom txiav 2 qhov rau cov nyees khawm tso rau ib sab ntawm lub qhov hluav taws xob
Xeem Sizing ntawm cov khoom
Ua kom ntseeg tau tias txhua qhov khoom siv yuav haum rau hauv lub qhov hluav taws xob sab saum toj lub thawv
Kauj Ruam 8: Hlau Txuas
Hlau txuas mus rau lub qhov hluav taws xob, los ntawm txoj hlua txuas mus rau ntawm phab ntsa, txuas hauv av (ntsuab) thiab nruab nrab (dawb) ncaj qha rau lub qhov hluav taws xob tus kheej
Kauj Ruam 9: Ntxiv Xov Tooj thiab Sib Dhos Duab
Kauj Ruam 10: Daim duab thaiv
Siv daim duab kom raug xaim cov khoom kom ua haujlwm nrog RaspberryPI Python code.
Kauj Ruam 11: Kuaj Qhuav Qhuav
Tom qab kev sib dhos zaum kawg ua ntej ntsia lub qhov nyob ua ke, ua kom qhuav ntawm lub cuab yeej kom paub tseeb tias tsis muaj luv, thaiv tsis zoo
Kauj ruam 12: Teem Startup Scripts
crontab -e
ntxiv cov kab hauv qab no
@reboot sej /home/pi/PowerHub/device/outlet/buttons.py @reboot sej /home/pi/PowerHub/device/outlet/relay.py
Pom zoo:
TextPlayBulb: REST Enabled PlayBulb Siv Raspberry Pi 3, BLE thiab Telegram: 3 Kauj Ruam
TextPlayBulb: REST Enabled PlayBulb Siv Raspberry Pi 3, BLE thiab Telegram: Cov lus qhia no qhia yuav ua li cas txuas rau PlayBulb Xim bluetooth LED teeb siv Python, Raspberry Pi 3 thiab Bluetooth lub tsev qiv ntawv thiab txuas ntxiv kev tswj hwm ntawm REST API rau IoT qhov xwm txheej , thiab raws li cov suab paj nruag, txoj haujlwm tseem qhia ntxiv yuav nthuav dav li cas
Qhov Taw Qhia Tsheb kauj vab Minimalist, Kov-Enabled !: 10 Kauj Ruam (nrog Duab)
Qhov taw qhia tsheb kauj vab Minimalist, Touch-Enabled!: Nyob zoo! Nov yog kuv thawj Phau Ntawv Qhia. Kuv ib txwm xav ua tej yam los ntawm kos tsuas yog pom nws ua haujlwm li cas thiab leej twg tsis nyiam DIY (Ua koj tus kheej) cov khoom thaum koj tuaj yeem hloov kho qee yam raws li koj xav tau txoj cai? Zoo li nthuav raws li DIY m
OpenLogger: Kev daws teeb meem siab, Wi-nkaus Enabled, Qhib Qhov Chaw, Portable Logger Logger: 7 Kauj Ruam
OpenLogger: Kev daws teeb meem siab, Wi-nkaus Enabled, Open Source, Portable Data Logger: OpenLogger yog lub tshuab nqa tau, qhib qhov chaw, tus nqi qis, daws teeb meem cov ntaub ntawv logger tsim los muab kev ntsuas zoo uas tsis tas yuav siv software kim lossis sau software. los ntawm kos. Yog tias koj yog tus kws tshaj lij, kws tshawb fawb, lossis tus neeg txaus siab uas tsis yog
IoT APIS V2 - Autonomous IoT -enabled Automated Plant Irrigation System: 17 Cov Kauj Ruam (nrog Duab)
IoT APIS V2 - Autonomous IoT -enabled Automated Plant Irrigation System: Txoj haujlwm no yog kev hloov pauv ntawm kuv cov lus qhia yav dhau los: APIS - Cov Tshuab Cog cog cog qoob loo Kuv tau siv APIS tau yuav luag ib xyoos tam sim no, thiab xav txhim kho raws li kev tsim yav dhau los: Muaj peev xwm saib xyuas cov nroj tsuag nyob deb. Nov yog li cas
Bluetooth Enabled Analog VU Meter: 6 Kauj Ruam
Bluetooth Enabled Analog VU Meter: Nov yog kuv qhov haujlwm rau ib ntawm kuv chav kawm hauv tsev kawm qib siab hu ua SMP. Raws li peb siv STM32F103RB pawg thawj coj txhim kho, Kuv ua raws kuv txoj haujlwm mus rau qhov no, pib los ntawm qhov ntsuas VU yooj yim. Kuv mam li ntxiv qee qhov tshwj xeeb ntxiv xws li Bluetooth txhawb rau tshaj tawm xov xwm