Cov txheej txheem:
- Khoom siv
- Kauj Ruam 1: Txuas Dej Sensor mus rau Particle
- Kauj ruam 2: Txuas Tswb Qhov Chaw rau Raspberry
- Kauj ruam 3: Configure Apache Server
- Kauj Ruam 4: Pab CGI ntawm Apache
- Kauj Ruam 5: Teeb Web Page
- Kauj Ruam 6: Tsim Tsab Ntawv rau Raspi Lub Koob Yees Duab
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:25
Muaj cov qauv ntsuas dej nyab yog qhov zoo los tiv thaiv kev puas tsuaj loj rau koj lub tsev lossis chaw ua haujlwm.
Tab sis nws ua rau nyuaj yog tias koj tsis nyob hauv tsev tuaj koom lub tswb.
Tau kawg koj tuaj yeem yuav cov ntse
Lub tswb ceeb toom dej nyab no txheeb xyuas cov kua thiab ua rau lub tswb nrov thiab hloov kho lub vev xaib txog dej nyab uas tuaj yeem nkag mus tau rau txhua qhov chaw hauv ntiaj teb no, txawm tias koj tab tom so so lossis tsuas yog tom haujlwm thiab koj xav paub txog koj lub tsev li cas.
Khoom siv
Raspberry pi (Kuv siv tus qauv 3 B+) khiav raspbian
Particle Argon
Grove Dej Sensor
Raspi Lub Koob Yees Duab
Buzzer
Jumper xov hlau
Kauj Ruam 1: Txuas Dej Sensor mus rau Particle
dej ntsuas muaj 4 tus pin, uas yog GND, VCC, NC thiab SIG thiab peb yuav siv tsuas yog peb ntawm lawv
Kuv txuas SIG tus pin rau D2 ntawm Argon.
Tam sim no, koj tuaj yeem tso Particle Web IDE los sau cov cai thiab nyem rau Argon
Yog li peb tau sau npe Particle muaj nuj nqi ua kua thiab piav qhia qhov sib txawv isFloodPresent, uas tuaj yeem hu los ntawm Particle Console thiab tau txais tus nqi boolean ntawm isFloodPresent thiab tseem hu ua kua rau kev sim thuam uas siv tus nqi 1 uas yog txhais tau tias muaj tseeb rau dej nyab (dej) tam sim no.
xyuas kom tseeb tias koj tuaj yeem pom qhov ua haujlwm thiab hloov pauv tau los ntawm Particle Console ntawm koj li Particle Device.
Kauj ruam 2: Txuas Tswb Qhov Chaw rau Raspberry
Ntawm daim ntawv qhia zaub mov koj tuaj yeem txuas Buzzer rau Raspberry's GPIO tus pin
Kuv tau txuas me me kawg ntawm buzzer rau GND (PIN 6) thiab ntev kawg rau tus pin 7 ntawm raspberry.
Tam sim no khiav cov cai kom pom. Peb yuav xav tau cov ntaub ntawv nab hab sej ua haujlwm txhua lub sijhawm yog li nws tuaj yeem tau txais cov txiaj ntsig los ntawm lub vev xaib thiab teb raws li.
Xwb, koj tuaj yeem khiav cov ntawv no ntawm kev pib ntawm koj lub raspberry uas koj tuaj yeem ua los ntawm kev kho /etc /systemd
thiab cov ntawv no yuav muab tso rau hauv cgi nplaub tshev ntawm koj lub server apache, Kuv tau ua cov npe tshiab dej nyab-cgi sab hauv/var/www/html/thiab muab cov ntawv no.py uas yuav sib tham nrog kuv tsab ntawv cgi
Kauj ruam 3: Configure Apache Server
koj tuaj yeem nruab apache server los ntawm kev sau sudo apt-tau nruab apache2
thaum nws tau teeb tsa, koj tuaj yeem txheeb xyuas los ntawm kev ntaus hostname -I
thiab koj yuav tau txais koj tus IP chaw nyob thiab koj tuaj yeem nkag mus rau koj tus browser thiab yuav tsum pom server khiav
Kauj Ruam 4: Pab CGI ntawm Apache
koj tuaj yeem pab cgi los ntawm kev sau sudo a2enmod cgi
Los ntawm Default cgi_bin ntawm apache nyob hauv/usr/lib/cgi-bin
qhov no yog qhov uas koj tuaj yeem tso koj cov ntawv cgi tom qab ua kom cgi
kom ua tau zoo, koj yuav tsum rov pib dua apache server
Kuv xav tau cov npe kev cai rau kuv cov ntawv cgi yog li kuv tsim cov npe hauv/var/www/html/hu ua dej nyab-cgi
kom pab tau phau ntawv no kuv yuav tsum ua cov ntaub ntawv conf los ntawm kev ntaus ntawv
sudo nano /etc/apache2/conf-available/flood-cgi.conf
thiab ntxiv cov lus txib raws li qhia hauv screenshot
tom qab ntawd qhib cov npe no los ntawm kev ntaus ntawv
var/www/html $ sudo a2enconf dej nyab-cgi
tam sim no koj tuaj yeem rov pib dua koj lub apache server dua thiab tag nrho cgi los ntawm daim nplaub tshev no yuav nyeem tau los ntawm apache tom qab kev tso cai.
Kauj Ruam 5: Teeb Web Page
Rau qhov kev pabcuam web yooj yim no, Kuv siv HTML, Javascript, CSS, jquery thiab ajax.
Kuv muaj tsib daim ntawv tswj hwm uas tuaj yeem nyem tau, Hauv qhov xwm txheej thaum thaij duab tau nyem los ntawm nplooj ntawv web, nws yuav ua rau lub pob nyem khawm nyem ua haujlwm thiab cov haujlwm no zoo li qhov no
$ ("#photobutton"). nyem (ua haujlwm () {var floodDate = Hnub Tshiab ();
var floodImageName = "Flood_IMG_" + floodDate.toLocaleTimeString ();
$.ajax ({
url: 'dej nyab-cgi/flood_cgi.py', txoj kev: 'post', cov ntaub ntawv: {name_for_image: floodImageName}, kev vam meej: muaj nuj nqi (cov ntaub ntawv) {
ceeb toom (cov ntaub ntawv, xwm txheej)
$ ("#picpic"). attr ("src", "flood-cgi/" + floodImageName + ".jpg");
}
})
});
qhov no yuav hu rau tsab ntawv flood_cgi.py los yees duab thiab khaws cov duab nrog cov npe kev cai tsim los ntawm hnub tim thiab sijhawm tam sim no thiab ajax thauj khoom mus rau nplooj ntawv.
hauv qhov xwm txheej Tswb, peb tuaj yeem siv txoj haujlwm no
muaj nuj nqi callAlarm (alarmType) {
$.ajax ({
url: 'dej nyab-cgi/tswb.cgi', txoj kev: 'post', cov ntaub ntawv: {alarm_type: alarmType}, kev vam meej: muaj nuj nqi (cov ntaub ntawv) {ceeb toom (cov ntaub ntawv)
}, yuam kev: muaj nuj nqi (XMLHttpRequest, textStatus, throwError) {ceeb toom (povError)}});
}
muaj nuj nqi callAlarm yuav raug hu thaum buzzer daim ntawv tau nyem, $ ("#buzzer"). nyem (ua haujlwm () {callAlarm ("test");
})
hauv qab tus lej yog thaum koj xav nyem nyem dej nyab piv txwv li hu rau Particle API thiab hu rau kev ua haujlwm thiab hloov pauv tus nqi kua 1 thiab tshuaj xyuas lub kaw lus yog tias tag nrho ua haujlwm raws li qhov xav tau los ntawm kev ua ib qho kev sib tw dej nyab
$ ("#mockFlood"). nyem (ua haujlwm () {console.log ("thuam dej nyab tau thov");
var floodVal = 1;
$ ("#signal2"). css ("font-size", "me");
var varName = "isFloodPresent";
var deviceID = "Koj li cuab yeej ID";
var accessToken = "KOJ ACCESS TOKEN";
yog (floodVal) {
$.post ("https://api.particle.io/v1/devices/" + deviceID + "/kua? access_token =" + accessToken, {kua: floodVal}, muaj nuj nqi (cov ntaub ntawv, xwm txheej) {
yog (xwm txheej == "kev vam meej") {
ceeb toom ("Mock Flood tau ua !!!");
lwm yam {
ceeb toom ("Thov txim, muaj teeb meem");
}
});
}
});
Cov no yog lub luag haujlwm tseem ceeb uas koj xav tau txhawm rau txuas nrog Particle Api thiab koj cov txiv pos nphuab yog li koj cov raspberry pi thiab cov khoom me me Argon tuaj yeem sib txuas lus.
ceeb toom: Kuv xav upload tag nrho cov cai, tab sis nws tsis tso cai rau kuv upload.html ntawv
Kauj Ruam 6: Tsim Tsab Ntawv rau Raspi Lub Koob Yees Duab
peb tab tom tsim qhov yooj yim.py txhawm rau ntes cov duab thiab uas yuav muaj cov lus piav qhia ntawm hnub thiab sijhawm tam sim no ntawm nws.
tom qab ntawd peb yuav tsim cgi tsab ntawv flood_cgi.py yog li nws yuav raug hu los ntawm lub vev xaib thiab qhov no yuav hais kom.py cov ntawv los yees duab.
nco ntsoov pib cgi tsab ntawv nrog #! /usr/bin/env nab hab sej
thiab tseem muab kev tso cai apache los khiav cov ntaub ntawv no.
apache server khiav ntawm tus neeg siv www-cov ntaub ntawv yog li thaum peb tsim cov.py lossis.cgi ntawv, apache xav tau los ua tus tswv ntawm cov ntawv
sudo chown pi: www-cov ntaub ntawv dej nyab-cgi.py
thiab muab kev tso cai rau txim
sudo chmod a+x dej nyab -cgi.py
koj yuav tsum ua qhov no rau txhua cov ntaub ntawv uas xav tau los ntawm apache server.
NCO TSEG: nthuav tawm koj cov raspberry rau hauv internet thiab muab tag nrho cov kev tso cai no ua rau koj raspberry muaj kev phom sij rau kev nyab xeeb yog li cov neeg siv nruj thiab tso cai yuav tsum tau ua raws thiab teeb tsa firewall zoo li tsis yooj yim firewall (ufw)
Pom zoo:
Dej Tswb Tswb Dej /Saib Xyuas Dej Dej: 6 Kauj Ruam
Dej Tswb Tswb Dej /Saib Xyuas Dej Dej: Peb Yuav Tsum Haus Dej Kom Muaj Dej Txhua Hnub kom txaus noj qab nyob zoo rau peb tus kheej. Tsis tas li muaj ntau tus neeg mob uas tau hais kom haus qee qhov tshwj xeeb ntawm cov dej txhua hnub. Tab sis hmoov tsis peb plam lub sijhawm yuav luag txhua hnub. Yog li kuv tsim
Tsim kom muaj DIY Tus Kheej Dej Dej Nrog WiFi - Dej Tsob Ntoo Tuaj thiab Xa Kev Ceeb Toom Thaum Dej Tsawg: 19 Kauj Ruam
Ua DIY Tus Kheej Tus Kheej Dej Nrog WiFi - Dej Tsob Ntoo Tuaj thiab Xa Kev Ceeb Toom Thaum Dej Tsis Tshua: Cov ntawv qhia no qhia koj yuav tsim kho li cas Wi -nkaus txuas nrog tus kheej cog cog dej siv lub qub vaj cog, cov thoob khib nyiab, qee cov nplaum thiab tus kheej Watering Pot Subassembly Kit los ntawm Adosia
Arduino Push Alerts rau Lub Tswb, Tswb Tswb, Tswb Tswb Tswb Thiab Lwm Yam: 8 Kauj Ruam
Arduino Push Alerts rau Tswb, Tswb Tswb, Tswb Tswb Tswb thiab lwm yam: IoT Cov Ntawv Ceeb Toom los ntawm koj lub Tswb, Tswb Tswb, Tswb Tswb thiab lwm yam siv Arduino Uno thiab Ethernet Shield. Cov ncauj lus kom ntxaws ntawm kuv lub vev xaib ntawm no Hais txog Arduino Push Alert Box Siv Arduino Uno thiab Ethernet Shield raws li Wiznet W5100 nti rau
Av Npaj Kev Ntsuas Dej Ntshav Ntshav: 6 Kauj Ruam (nrog Duab)
Cov av Ntsuas Kev Ntsuas Ntsuas Kev Ntsuam Xyuas: Kev Nyuaj Siab: Tsim thiab ua lub phiaj xwm uas yuav ua kom pom lub RED LED thaum cov av ntub, thiab GREEN LED thaum cov av qhuav. Qhov no yuav koom nrog siv Cov Av Moisture Sensor
LED Tswb Tswb Tswb Tswb Tswb Tswb Tsa Tswm Tsa: 7 Kauj Ruam (nrog Duab)
LED Tswb Tswb Tswb Tswb Tswb Tswb Tsa Tswm Tsa Tswm Tswm: Tsa Kuv Lub Caij Ntuj No Lub caij ntuj no kuv tus hluas nkauj muaj teeb meem sawv thaum sawv ntxov thiab zoo li raug kev txom nyem los ntawm SAD (Lub Caij Caij Nyoog Muaj Teeb Meem). Kuv txawm pom tias nyuaj npaum li cas kom sawv thaum lub caij ntuj no vim lub hnub tsis tuaj