Cov txheej txheem:
- Kauj ruam 1: Rub tawm Express rau Pi
- Kauj ruam 2: Pi Server Teeb
- Kauj Ruam 3: teeb tsa IFTTT (Ua kom pom tseeb)
- Kauj Ruam 4: IFTTT Teeb (Ua)
- Kauj Ruam 5: Kev Xa Mus Rau Chaw Nkoj
- Kauj Ruam 6: Txheeb Xyuas Koj Txoj Haujlwm Kom Kawg
- Kauj Ruam 7: Tsim Circuit Court
- Kauj Ruam 8: Xeem Nws
Video: Google Tsev Tswj LEDs: 8 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
Tsis ntev los no, Kuv tau muaj sijhawm ntau ntawm kuv txhais tes, yog li kuv tau ua haujlwm ntawm ib pawg ntawm cov phiaj xwm.
Txoj haujlwm no yuav tso cai rau koj los tswj RGB LEDs ntawm Google Tsev siv Raspberry Pi. Tam sim no muaj 3 ntu ntawm txoj haujlwm, teeb tsa Raspberry Pi, teeb tsa Google Tsev nrog kev cai hais kom ua siv IFTTT, thiab tom qab ntawd tsim lub Circuit Court rau teeb. Kuv tau ua tus Circuit Court kuv tus kheej, tab sis kuv twv tias koj tuaj yeem tau txais qee yam los ntawm Adafruit uas ua raws li qhov xav tau.
Cov ntaub ntawv rau Raspberry Pi Tshooj
- Raspberry Pi - ib qho yuav ua haujlwm, tab sis kuv siv Xoom
- Wireless Dongle - yog tias Pi tsis tau tsim hauv Wifi
- Google Tsev - Yeem yog tias koj muaj Google Assistant ntawm koj lub xov tooj
Cov ntaub ntawv rau Circuit Part- Tsis txhob cia qhov no cuam tshuam koj… Nws yooj yim heev
- Protoboard
- Hlau
- LED Sawb
- 12V Cov Khoom Siv Hluav Taws Xob - Txhua yam saum 2 Amps yuav tsum zoo
- DC Barrel Jack - Qhov loj ib yam li koj lub zog siv
- NPN BJT Power Transistors (x3) - Kuv siv TIP31C
-
Txiv neej & Poj Niam Pin Headers - Yeem tau, tab sis pom zoo heev
Kauj ruam 1: Rub tawm Express rau Pi
Kuv yuav tsis nkag mus ntau dhau txog kev teeb tsa Pi vim tias muaj ntau qhov kev qhia tawm rau teeb tsa lawv.
Qhov koj yuav tsum tau ua uas kuv tsis npog …
- Flashing Raspberry Pi nrog Raspbian tshiab tshaj plaws
- Teeb tsa daim npav network kom koj tuaj yeem nkag tau internet los ntawm Pi
- Teeb IP zoo li qub ntawm Raspberry Pi
Tam sim no ntawm no yog qhov pib kev lom zem! Peb yuav tsum teeb tsa nodeJS, npm, nthuav tawm, thiab nthuav tawm lub tshuab hluav taws xob.
sudo apt-tau hloov tshiab
sudo apt-tau nruab nodejs npm
Thaum cov no raug teeb tsa, khiav cov hauv qab no
npm nruab qhov qhia tawm-tsim hluav taws xob
Kev nthuav qhia tso cai rau koj los ua lub vev xaib yooj yim heev rau koj li Raspberry Pi siv. Express-generator tsuas yog pib tsim cov ntawv rau tus neeg rau zaub mov nthuav tawm.
Ua cov npe thiab cd rau hauv phau ntawv teev npe. Kuv npe kuv tus piWebpage. Tam sim no khiav cov hauv qab no (pom hauv daim duab ib yam nkaus)
mkdir piWebpage
cd piWebpage nthuav qhia -pom = ejs webApp
Qhov no yuav tsim daim nplaub tshev npe webApp nrog txhua cov ntaub ntawv nthuav tawm hauv nws. Yog tias koj npaj yuav ua ntau dua nrog lub vev xaib no tom qab thiab koj nyiam PUG, hloov --view = ejs nrog --view = pug. Peb yuav tsis kov lub vev xaib, yog li rau daim ntawv thov no, nws tsis muaj teeb meem dab tsi peb siv.
Kauj ruam 2: Pi Server Teeb
Txav mus rau hauv phau ntawv teev npe webApp tshiab.
cd wb web
npm nruab
npm nruab yuav siv qee lub sijhawm vim tias nws tau txhim kho txhua qhov kev cia siab rau nthuav tawm.
Muab tshuaj txhuam setColor.py tso rau hauv webApp nplaub tshev. Cov ntaub ntawv no muaj qee qhov presets hauv nws rau cov xim yooj yim. Xav tias dawb ntxiv ntau li koj nyiam. Qhov ntau yog 0 txog 255 qhov twg 255 yog xim puv. Qee lub sijhawm, Kuv yuav zoo li muaj peev xwm ua kom lub teeb tsaus, tab sis rau tam sim no, lawv ci tag nrho.
Tsiv mus rau txoj kev
cd lus
Tam sim no hloov index.js nrog cov ntawv txuas nrog. Qhov no yuav ntxiv qee kab kom tau txais POST hais kom ua uas yog Google Tsev yuav xa. Los ntawm POST ntawd, peb yuav tau txais cov xim xaiv thiab qhia rau Pi kom khiav cov ntawv setColor nab nab los kho lub teeb.
Ib qho kawg… Rov qab mus rau webApp nplaub tshev.
cd ~/piWebpage/webApp
Siv koj tus kws kho mob nyiam, muab tshuaj txhuam thiab khaws cov cai hauv qab no rau hauv koj lub webApp.js. Txhua qhov txhia chaw zoo li nws tau ua ntej "module.exports = app;"
// Teeb LED kho vajtse driverconst {exec} = xav tau ('child_process'); exec ('sudo pigpiod', (ua yuam kev, stdout, stderr) => {yog (yuam kev) {console.log ('Yuam kev thauj khoom LED Tsav Tsheb'); rov qab;} lwm qhov console.log ('LED tsav tsheb ua tiav Loaded'); });
Zoo li cov lus hais, pigpiod yog tus tsav tsheb kho vajtse rau PWM cov cim uas peb yuav siv los kho cov xim LED. Kuv ntseeg tias nws los twb tau teeb tsa hauv Raspbian, tab sis yog tias tsis yog …
sudo apt-tau nruab pigpiod
Tam sim no rau qhov kev sim tiag! Pib server!
DEBUG = webapp:* npm pib
Kauj Ruam 3: teeb tsa IFTTT (Ua kom pom tseeb)
IFTTT tuaj yeem ua ntau yam, thiab kuv xav pom zoo kom saib ib ncig ntawm qee qhov kev thov.
Ua ntej, koj yuav tsum tau ua tus as khauj. Siv tib tus lej Google cuam tshuam nrog koj lub Tsev Google, txwv tsis pub lawv yuav tsis sib sau ua ke. Thaum ua tiav thiab nkag mus, nyem rau sab xis sab xis ntawm IFTTT nplooj ntawv uas nws qhia koj lub npe thiab tus avatar. Tom qab ntawv nyem Applet tshiab los ntawm qhov nco cia.
Yog tias koj xav paub, IFTTT sawv rau YOG Qhov No Yog Li Yog tias koj tsis tau hnov dua los ntawm lub vijtsam uas tshwm tuaj. Yog li qhov peb xav tau yog Yog Google Assistant, tom qab ntawd Webhook yog peb cov kev xaiv.
Ua mus ntxiv los ntawm txhaj +qhov no uas yuav thauj khoom tshawb. Hauv kev tshawb nrhiav, ntaus Google Assistant thiab nyem lub cim hauv qab kev tshawb nrhiav.
Hauv Xaiv Qhov Ua Rau, xaiv qhov kev xaiv thib 3 hu ua Hais ib kab lus nrog cov ntawv sau. Tam sim no qhov no tso cai rau koj kom muaj 3 cov lus txib uas yuav ua tib yam nkaus. Koj ntxiv $ rau hauv kab lus uas koj yuav hais txog xim. Piv txwv li, yog tias kuv ib txwm xav hais tias Hav Google, Teeb LEDs Xiav (zoo li lub suab nrov ntawm lub cuab yeej tuaj yeem ua tau), tom qab ntawd kuv yuav ntaus rau hauv daim teb Teeb LEDs $. Ua qhov ntawd rau tag nrho 3 daim teb nrog cov lus sib txawv ntawm cov lus txib.
3 kuv siv yog
LEDs $ ib
Teeb LEDs $
Teeb LED xim $
Daim teb kawg yog yam koj xav kom koj Lub Tsev Google teb tom qab hais koj cov lus txib. Nws tuaj yeem yog txhua yam koj xav tau, tab sis kuv siv Teeb xim rau $. Tus $ txhais tias nws yuav rov ua xim dua.
Nyem Tsim Qhov Tseeb
Kauj Ruam 4: IFTTT Teeb (Ua)
Tom qab nyem Tsim Qhov Tseeb, koj yuav rov qab mus rau yog tias qhov no yog qhov pom, tab sis qhov no tau hloov nrog Google Assistant lub logo. Ua mus ntxiv los ntawm txhaj +qhov ntawd
Ib yam nkaus li ua ntej qhov twg nws coj koj mus rau qhov tshawb fawb bar. Ntaus hauv Webhooks thiab nyem lub cim webhook hauv qab kab ntawv tshawb nrhiav. Hauv qab Xaiv Ua rau Webhooks, tsuas muaj ib qho kev xaiv, yog li nyem Ua lub vev xaib thov.
Nov yog qhov uas cov khoom ua kom yuam kev me ntsis. Vim tias Google tsis yog lwm lub khoos phis tawj hauv koj lub tsev, koj yuav xav tau koj tus IP chaw nyob sab nraud. Qhov no yuav xav tau qee qhov chaw xa mus tom ntej, tab sis peb yuav kov qhov ntawd tom qab. Kom tau txais koj tus IP chaw nyob sab nraud, mus rau
Hauv qhov URL teb, ntaus https://xxx.xxx.xxx.xxx:3000/{{TextField}} (nrog x yog koj tus IP chaw nyob sab nraud). Yog tias koj xav paub, TextField yuav muaj xim uas koj xaiv thaum koj hais kom ua. Qhov laj thawj peb siv 3000 yog vim qhov ntawd yog qhov chaw nres nkoj Raspberry Pi Express server tau ua haujlwm. (Koj tuaj yeem hloov chaw nres nkoj hauv txoj cai, tab sis peb tsuas yog siv lub chaw pib rau Express)
Txog Txoj Kev, xaiv POST.
Rau Cov Ntsiab Lus Hom, xaiv cov ntawv/dawb.
Rau Lub Cev, ntaus hauv {{TextField}}
Cov ntawm koj uas paub tias POST hais kom ua li cas, koj yuav xav tias yog koj cais lub cev lub cev ntawm qhov kev thov uas koj yuav tau txais xim. Vim li cas, tsis muaj ib yam dab tsi tau muab tso rau hauv lub cev ntawm qhov kev thov, yog li kuv tau txheeb xyuas qhov URL rau xim. Vam tias yuav tau kho sai sai, vim qhov ntawd yuav yooj yim rau kuv cov cai hauv kab ntawv index.js. Tab sis kuv digress.
Thaum kawg, nyem Tsim Ua thiab tom qab ntawd ua tiav ntawm nplooj ntawv tom ntej. (Kuv kaw cov ntawv ceeb toom, tab sis qhov ntawd yog qhov nyiam)
Kauj Ruam 5: Kev Xa Mus Rau Chaw Nkoj
Nov yog qhov uas nyuaj rau piav qhia vim tias txhua tus routers sib txawv …
Tam sim no peb muaj Google xa lus txib rau peb lub tsev siv chaw nres nkoj 3000, tab sis nws tsis paub lub cuab yeej twg ntawm LAN nws yuav tsum mus. Txhawm rau kho qhov no, peb yuav tsum xa chaw nres nkoj 3000 mus rau IP chaw nyob ntawm koj li Raspberry Pi.
Mus rau hauv koj lub router siv 10.0.0.1 lossis 192.168.1.1 (Kuv kuj tau pom nws qhov twg tus lej kawg yog 254) thiab nrhiav chaw nres nkoj xa mus. Hauv qhov chaw xa mus tom ntej, zoo ib yam li daim duab, koj yuav sau lub cuab yeej tshiab (IFTTT) thiab xa cov chaw nres nkoj (3000) mus rau Pi tus IP chaw nyob (hauv kuv li 10.0.0.11).
Txuag koj qhov chaw tshiab, rov pib dua koj lub router, thiab txheeb xyuas kom paub tseeb tias koj li Raspberry Pi server tseem tab tom ua haujlwm. Yog tias nws tsis ua haujlwm, pib dua.
Rov qab mus rau lub vev xaib uas yooj yim https://canyouseeme.org/. Hauv qab koj tus IP chaw nyob, nws muaj chaw kuaj chaw nres nkoj. Xav tias koj qhov chaw nres nkoj xa mus yog qhov raug, ntaus hauv 3000 thiab ntaus qhov chaw nres nkoj. Nws yuav tsum rov qab los nrog Kev Ua Tau Zoo.
Kauj Ruam 6: Txheeb Xyuas Koj Txoj Haujlwm Kom Kawg
Tam sim no… lub sijhawm uas koj tau tos… Qhia rau Google cov lus txib xws li LEDs xiav (yog tias koj ua raws li kuv tus piv txwv).
Piv txwv tias txhua yam mus raug, koj yuav tau txais cov zis pom hauv daim duab. Peb tseem tsis muaj lub Circuit Court, yog li txhua yam koj yuav pom yog cov ntawv ntawm lub vijtsam. Feem ntau yog ncua thib ob lossis 2 ncua ua ntej nws tau ua tiav los ntawm Google thiab tshwm ntawm Pi.
(Hla mus rau kauj ruam tom ntej yog tias qhov no tawm zoo ib yam li daim duab)
Tam sim no muaj qee yam los saib yog tias nws tsis ua haujlwm …
Hauv daim duab, muaj kab uas hais tias
POST /xim /xiav 200 250.458 ms - 2
200 yog qhov tseem ceeb. Yog tias koj tsis pom 200, tom qab ntawd muaj POST tsis zoo txhais tau tias koj lub server tsis paub yuav ua li cas nrog cov ntaub ntawv. Rov qab mus rau Kauj Ruam 2 thiab tshawb xyuas koj cov ntawv index.js.
Kuj nyob hauv daim duab
siv: blu
stderr: tus
Nov yog qhov tso tawm los ntawm cov ntaub ntawv nab nab uas khiav cov LEDs. Yog tias koj pom qhov yuam kev nyob ntawd, nws yuav yog qhov koj tsis muaj tus tsav tsheb teeb tsa ntawm Kauj Ruam 2.
Thaum kawg, yog tias tsis muaj dab tsi tshwm sim txhua qhov … koj li IFTTT yuav tsis tau teeb tsa kom raug lossis ua tsis tiav txuas rau lub server. Rov qab mus rau IFTTT nplooj ntawv, thiab nyob rau sab saum toj nav bar, nyem Ua Haujlwm. Nyob ntawd, koj tuaj yeem pom txhua lub sijhawm koj app tau ua haujlwm, thiab yog tias muaj qhov ua yuam kev, koj tuaj yeem pom nws yog dab tsi. Kuv tau ua Google cov lus txib nrog Pi server tawm thiab tau txais qhov yuam kev hauv daim duab.
Kauj Ruam 7: Tsim Circuit Court
Qhov laj thawj vim li cas peb yuav tsum ua qhov no yog vim tias Raspberry Pi tsis muaj lub zog txaus… Yog li cov lus daws yog… MUAJ HNUB NYOOG (Tim lub cuab yeej txiv neej Taylor yws hauv qhov deb). AKA lwm lub hwj chim (12V 2A)
Cov ntaub ntawv rau Circuit Part
- Protoboard
- Hlau
- RGB LED Sawb
- 12V Cov Khoom Siv Hluav Taws Xob - Txhua yam saum 2 Amps yuav tsum zoo
- DC Barrel Jack - Qhov loj ib yam li koj lub zog siv
- NPN BJT Power Transistors (x3) - Kuv siv TIP31C
- Txiv neej & Poj Niam Pin Headers
Siv cov duab yooj yim Kuv tau nyiag los ntawm kev sib cuam tshuam nrog GPIO ntawm Pi Zero, koj tuaj yeem pom GPIO17, GPIO18, thiab GPIO 27 yog txhua tus nyob ib sab nrog GND. Peb yuav siv qhov xwm txheej ntawm 4 tus pin (Pins 11, 12, 13, 14).
Ua ntej tshaj, Kuv xav kom muab tus txiv neej tso lub taub hau rau ntawm koj daim kab xev LED raws li pom hauv daim duab (tsis yog kuv txoj haujlwm zoo tshaj). Qhov no tso cai rau kev tshem tawm yooj yim yog tias koj xav tau. Kuv siv poj niam lub taub hau rau kev txuas ntawm LED kab rau kuv tus protoboard thiab txiv neej lub taub hau los ntawm protoboard mus rau Raspberry Pi. (Ib txwm siv poj niam sib txuas rau lub zog/teeb liab qhov chaw). Koj tsis tas yuav txav txhua tus Pi tus pin txhua tus nyob ib sab ib yam li kuv tau ua … Kuv tsuas yog xav kom nws saib huv, tab sis nws tau ua haujlwm ntau heev.
Piav Qhia
Rau cov uas koj tsis tau paub dua nrog transistors, transistors yog qhov pib hloov digital. GPIO tus pin los ntawm Pi ua rau peb qhov hloov pauv (liab, ntsuab, thiab xiav). Saib tshwj xeeb ntawm RED hauv daim duab qhia chaw, thaum GPIO_17 tau qhib, qhov hloov "kaw" txuas RED rau GND ua rau lub teeb liab tig rau. Thaum GPIO_17 tua tawm, tom qab ntawv qhib tau qhib thiab yog li lub teeb tawm.
Hauv paus - GPIOs
Collector - Xim (Liab, Xiav, Xiav)
Emitter - Hauv av (ntawm ob qho khoom siv fais fab thiab Pi)
Nco ntsoov txuas Pi lub hauv paus rau hauv av ntawm lub zog siv hluav taws xob. Lub teeb tseem yuav ua haujlwm, tab sis lawv yuav tshwm sim heev kom txog thaum hauv av txuas nrog.
Kuv muaj lub transistor thib 4 saib lub cuab yeej ntawm kuv tus protoboard. Nws yog L7805CV uas yog siv los hloov 12V rau 5V yog li kuv tuaj yeem siv zog Pi ntawm tib lub Circuit Court. Nws ua haujlwm tab sis khaws cia dhau cua sov, yog li kuv tshem nws cov kev sib txuas.
Kauj Ruam 8: Xeem Nws
Thaum ua tiav nrog lub Circuit Court, rov pib dua koj Pi ua ntej ua kev sib txuas. Qhov no yog vim tias cov pins tej zaum tseem ua haujlwm los ntawm kev sim server. Xwb, koj tuaj yeem tua tus neeg rau zaub mov thiab kev pabcuam pigpiod.
Plug rau hauv LEDs thiab cov dhia los ntawm protoboard mus rau Pi. Muab ob npaug rau xyuas txhua qhov kev sib txuas ua ntej muab lub zog. Yog tias koj xaim nws tsis raug, koj tuaj yeem kib koj Pi (tsis muaj qhov siab).
Daim ntawv teev npe
- Xyuas cov xov hlau
- Lub zog Pi
- Lub Hwj Huam Circuit Court
- Pib Server (DEBUG = webapp:* npm pib thaum nyob hauv ~/piWebpage/webApp directory)
- Qhia Google ua koj li kev twv!
CONGRATULATIONS koj tsis tau cuam tshuam dab tsi, thiab tam sim no koj tuaj yeem tswj koj cov LEDs los ntawm Google Tsev.
Tawm lus yog tias koj muaj teeb meem, thiab kuv yuav ua qhov zoo tshaj plaws kom tau rov qab los rau koj!
Pom zoo:
Plug & Ua Si CO2 Sensor Zaub Nrog NodeMCU/ESP8266 rau Cov Tsev Kawm Ntawv, Tsev Kawm Qib Siab lossis Koj Lub Tsev: 7 Kauj Ruam
Plug & Ua Si CO2 Sensor Zaub Nrog NodeMCU/ESP8266 rau Cov Tsev Kawm Ntawv, Lub Tsev Kawm Qib Siab lossis Koj Lub Tsev: Kuv yuav qhia koj sai npaum li cas txhim kho lub plug & ua si CO2 sensor qhov twg txhua qhov ntawm txoj haujlwm yuav txuas nrog DuPont xov hlau. Yuav muaj tsuas yog 5 cov ntsiab lus uas yuav tsum tau muab siv, vim tias kuv tsis tau muab tshuaj txhuam ua ntej qhov haujlwm no txhua lub sijhawm
Ua Lub Tsev Tswj Xyuas Ntse Tsev ntawm STONE HMI Disp: 23 Cov Kauj Ruam
Ua Smart Home Control System ntawm STONE HMI Disp: Kev qhia ua haujlwm Cov lus qhia hauv qab no qhia koj yuav siv STONE STVC050WT-01 kov zaub module ua kom yooj yim tswj cov cuab yeej siv hauv tsev
Siv Kev Cia Siab Lub Hauv Paus txuas ntxiv txhawm rau Nrhiav Lub Tuam Tsev Tsis Ua Haujlwm Txoj Cai Ua Haujlwm Hauv Koj Tsev Neeg Tsob Ntoo ntawm Kev Tshawb Nrhiav Tsev Neeg: 11 Kauj Ruam
Siv Kev Cia Siab Lub Hauv Paus Txuas Ntxiv kom Nrhiav Lub Tuam Tsev Tsis Ua Haujlwm Ua Haujlwm Hauv Koj Tsev Neeg Tsob Ntoo ntawm Kev Tshawb Nrhiav Tsev Neeg: Lub hom phiaj ntawm cov lus qhia no yog los qhia seb yuav tshawb nrhiav koj tsev neeg tsob ntoo li cas hauv Tsev Neeg Nrhiav rau cov poj koob yawm txwv nrog kev ua haujlwm hauv lub tuam tsev tsis tiav siv Kev Cia Siab lub hauv siab txuas ntxiv. Siv Kev Cia Siab Lub Hauv Paus tuaj yeem ua rau koj qhov kev tshawb nrhiav tsis tiav
Kev Tswj Lub Suab Hauv Tsev Automation (zoo li Alexa lossis Google Tsev, tsis xav tau Wifi lossis Ethernet): 4 Cov Kauj Ruam
Kev Tswj Lub Suab Hauv Tsev Automation (zoo li Alexa lossis Google Tsev, tsis xav tau Wifi lossis Ethernet Xav Tau): Nws yog qhov yooj yim SMS raws li arduino tswj kev xa xov nrog google tus pabcuam teeb tsa xa cov lus ntawm kev qhia lub suab. Nws yooj yim heev thiab pheej yig thiab ua haujlwm zoo li Alexa tshaj tawm nrog koj cov khoom siv hluav taws xob uas twb muaj lawm (yog tias koj muaj Moto -X ntse
DIY Lub Suab/Internet Tswj Tsev Automation thiab Saib Xyuas Siv ESP8266 thiab Google Tsev Mini: 6 Cov Kauj Ruam
DIY Lub Suab/Internet Tswj Tsev Automation thiab Saib Xyuas Siv ESP8266 thiab Google Tsev Mini: Hav !! Tom qab so ntev kuv nyob ntawm no vim peb txhua tus yuav tsum tau ua ib yam dab tsi tho txawv (txoj haujlwm) kom khwv tau. yooj yim tab sis ua tau zoo tshaj plaws