Cov txheej txheem:
- Kauj Ruam 1: Sib Sau Ua Ke
- Kauj Ruam 2: Txhim Kho Peb Lub Tsev Qiv Ntawv
- Kauj Ruam 3: Txhim Kho Cov Tsev Qiv Ntawv Yuav Tsum Tau
- Kauj Ruam 4: Sib Sau Cov Qauv
- Kauj Ruam 5: Sau Luminosity Module Sketch
- Kauj Ruam 6: Xeem Peb Qhov AtHome Module
- Kauj Ruam 7: Tsim Rooj Plaub Rau Tus Qauv
Video: Tsim kom muaj Lub Teeb Luminosity Nrog AtHome: 7 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:28
AtHome yog qhov qhib tag nrho thiab qhib cov tub ntxhais kawm txoj haujlwm tsim los ntawm pab pawg AtHome los ntawm Epitech, lub hom phiaj txhawm rau txhim kho kev sib txuas sib txuas ntawm ntau tus tib neeg tus qauv ntsuas kev sib txuas lus nrog tus kheej-hosted database nthuav tawm API siv los pub cov ntawv thov smartphone thiab lub vev xaib thov. Cov qauv saib xyuas ib puag ncig sab hauv tsev ntawm lub tsev thiab muaj peev xwm muab cov lus tawm tswv yim rau tus neeg siv, mus los ntawm ntsuab (zoo) mus rau liab (tsis zoo) thiab cov ntaub ntawv kis tau pom los ntawm tus neeg siv los ntawm kev sib txuas lus txuas ntawm tus qauv lossis peb cov ntawv thov yog tias koj siv lawv.
Txawm hais tias txoj haujlwm no tseem tab tom txhim kho, cov haujlwm tseem ceeb ntawm peb cov qauv tau npaj tam sim no thiab xav tias yooj yim siv los tsim cov qauv kev cai. Yog li, yog vim li cas kuv thiaj thov koj kom pom yuav tsim koj tus kheej cov qauv yooj yim nrog qhov piv txwv ntawm cov teeb pom kev zoo li cas.
Cov khoos phis tawj no tau tsim ua nrog Arduino-sib xws board (ib feem Arduino core yuav tsum txaus kom ntev li ntev tau nws muaj kwj, Hlau thiab UART kwj txhawb nqa), LED (liab ib lossis RGB) tig liab thaum muaj teeb meem, sensor, lub hwj huam muab (phab ntsa fais fab mov lossis roj teeb) thiab rooj plaub txiav laser.
Yog, nws tsis yog qhov tshiab, muaj ntau lub phiaj xwm phiaj xwm tab sis peb vam tias lwm yam xws li kev txheeb xyuas teeb meem kev noj qab haus huv, kev sib txuas lus thiab khaws cov ntaub ntawv ntawm tus kheej-host server thiab daim ntawv thov pom kev yuav pab koj. Lossis yog tias koj tsuas yog xav tshuaj xyuas koj lub tsev, cov haujlwm yooj yim lossis tsis txaus siab:)
Kauj Ruam 1: Sib Sau Ua Ke
Txog qhov haujlwm no, koj yuav xav tau ob peb yam los tsim koj li AtHome module:
- 1x Arduino-Compatible board: Ntawm no kuv yuav siv Arduino UNO (tab sis nws kuj ua haujlwm nrog lwm cov laug cam xws li TI Launchpads thiab ESP8266 cov laug cam)
- 1x sensor: Kuv yuav siv TSL2561 lub teeb pom kev zoo (cov npe ntawm cov khoom txhawb nqa muaj nyob ntawm cov ntaub ntawv ntawm peb lub tsev qiv ntawv)
- 1x coj: Kuv yuav siv Grove Chainable RGB LED ntawm no (tab sis nws kuj tseem tuaj yeem yog tus coj liab yooj yim lossis NeoPixel)
- Dupont Hlau
Cov npe ntawm cov khoom siv sib xws muaj nyob ntawm cov ntaub ntawv ntawm peb tes num.
Kauj Ruam 2: Txhim Kho Peb Lub Tsev Qiv Ntawv
Txhawm rau teeb tsa peb lub tsev qiv ntawv, koj yuav tsum rub tawm los ntawm peb lub chaw cia khoom (peb yuav tshaj tawm tom qab ntawm Arduino IDE daim ntawv teev npe thiab PlatformIO) nrog qhov txuas no:
gitlab.com/Woodbox/Framework/-/jobs/artifacts/master/download?job=deploy
Tom qab ntawv, mus rau hauv Arduino IDE thiab xaiv "Sketch> Include Library> Add. ZIP Library …". Tom qab ntawv xaiv tus zip cov ntaub ntawv npe "artifacts.zip" thiab nyem rau ntawm "OK".
Kauj Ruam 3: Txhim Kho Cov Tsev Qiv Ntawv Yuav Tsum Tau
Txhawm rau ua haujlwm, peb lub tsev qiv ntawv xav tau qee lub tsev qiv ntawv lwm tus los nruab rau hauv koj lub khoos phis tawj:
- Arkhipenko TaskScheduler lub tsev qiv ntawv
- NYEEM Studio Grove Digital Light Sensor lub tsev qiv ntawv
- NYEEM Studio Grove Chainable RGB LED lub tsev qiv ntawv
- Adafruit NeoPixel lub tsev qiv ntawv
Koj tuaj yeem teeb tsa lawv los ntawm tus thawj tswj tsev qiv ntawv ntawm Arduino IDE, los ntawm kev mus rau "Sketch"> "Xws li Lub Tsev Qiv Ntawv"> "Tswj cov tsev qiv ntawv …".
Hauv lub qhov rai tshiab uas yuav qhib, sau rau hauv kab tshawb nrhiav dawb lub npe ntawm lub tsev qiv ntawv koj xav teeb tsa, tom qab ntawd nyem rau ntawm nws lub block. Ib qho "Nruab" khawm yuav tshwm, koj tsuas yog yuav tsum nyem rau nws thiab IDE yuav rub nws thiab teeb tsa nws rau koj.
Kauj Ruam 4: Sib Sau Cov Qauv
Peb yuav pib nrog lub sensor. Txuas los ntawm xaim xov tooj VCC tus pin ntawm TSL2561 mus rau 5V tus pin ntawm Arduino, GND tus pin ntawm lub sensor mus rau ib qho ntawm GND tus pin ntawm Arduino thiab SDA thiab SCL tus pin ntawm lub sensor rau SDA thiab SCL pins ntawm Arduino. Tam sim no koj ua tiav!
Tam sim no, txuas VCC tus pin ntawm Grove Chainable RGB LED mus rau 5V tus pin ntawm Arduino thiab GND tus pin ntawm LED mus rau GND thib ob ntawm Arduino. Yog tias koj yog Arduino tsuas yog ib tus 5V tus pin, koj tuaj yeem siv lub khob cij los txuas 5v ntawm Arduino mus rau + kab ntawm lub khob cij thiab txuas tag nrho koj cov khoom 5V tus pin rau nws, lossis siv lawv ua ke ntawm ib daim kab xev lossis siv wago txuas lossis txhua yam koj xav tau. Tam sim no, txuas CI tus pin ntawm koj LED mus rau tus pin 7 ntawm koj Arduino thiab DI tus pin ntawm koj LED mus rau tus pin 8 ntawm koj Arduino. Yog tias koj tsis muaj LED, tsis txhob txhawj xeeb, nws muaj peev xwm siv cov teeb tsa LED ntawm koj li Arduino pawg thawj coj lossis ib qho qub nrog tsuas yog hloov pauv me me hauv cov cai.
Kauj Ruam 5: Sau Luminosity Module Sketch
Cia peb tsim tus qauv tshiab thiab sau cov cai rau peb tus qauv.
Yog tias koj tsis txaus siab los ntawm kev piav qhia ntawm daim duab, koj tsuas tuaj yeem luam thiab muab tso rau hauv koj li Arduino IDE:
#suav nrog
siv LightModule = AtHomeModule; Kwj *ntws = {& Serial, nullptr}; GroveChainableLED:: Pins grovePins = {7, 8}; GroveChainableLED coj (& grovePins); LightModule *module = LightModule:: getInstance (); tsis muaj teeb tsa teeb tsa () {// muab koj cov cai teeb tsa ntawm no, kom khiav ib zaug: Serial.begin (9600); module-> setStreams (ntws); GroveDigitalLightSensor *lightSensor = tshiab GroveDigitalLightSensor (); module-> setSensor (lightSensor); module-> setDisplay (& coj); module-> teeb tsa (); } void loop () {// muab koj tus lej tseem ceeb ntawm no, kom rov ua dua: module-> run (); }
Yog tias koj xav nkag siab txhua qhov kev cai no ua dab tsi, koj tuaj yeem nyeem cov hauv qab no lossis yog tias koj tsis txaus siab, koj tuaj yeem dhia ncaj qha mus rau theem tom ntej.
Txhawm rau pib, peb yuav tsum suav nrog peb lub tsev qiv ntawv hauv peb daim duab kos los ntawm kev sau kab no rau saum daim duab kos:
#suav nrog
Tam sim no, peb yuav tsum tsim cov npe tsis raug rau cov khoom module peb yuav siv. Koj tuaj yeem pom nws yog lub npov uas muaj ob peb lub khawm siv los hloov nws cov khoom, pib nws, nres nws, … thiab lwm yam. Raws li nws yog lub npov tsim los ntawm tus qauv (zoo li tus qauv ib txwm peb siv rau cov haujlwm raws li tib neeg, nws muaj lub hauv paus pib thiab tus sau ntawm Arduino tsim cov lej kawg raws li qhov ntsuas peb muab rau nws) txhais hom sawv cev rau tus nqi sensor thiab tus naj npawb ntawm qhov ntsuas qhov peb xav tuav hauv lub cim xeeb, nws tau teev tseg hauv nws lub npe thiab yuav tsum tau rov ua dua txhua zaus peb xav siv nws. Uas yog qhov tsis txaus ntseeg, yog vim li cas peb thiaj li koom nrog lub npe tshiab, lub npe tsis tseeb, rau lub npe tag nrho ntawm lub npov no.
Cia peb hais piv txwv Kuv xav kom lub npov no muaj npe hu ua "LightModule", vim nws yuav raug siv los teeb tsa lub teeb pom kev zoo saib xyuas thiab kuv xav khaws tsuas yog 1 tus nqi ib zaug. Qhov ci ntsa iab tau sawv cev hauv qhov zoo ib yam los ntawm peb lub TSL2561 sensor, uas tau sawv cev ua uint16_t los ntawm khoos phis tawj. Peb cov npe yuav zoo li no:
siv LightModule = AtHomeModule;
qhov "siv" lo lus tseem ceeb txhais tau tias peb tab tom tsim ib lub npe thiab lub npe peb muab nws tsuas yog tom qab sib raug rau ntu tom qab "=" cim.
"AtHomeModule" yog lub npe tiag tiag ntawm lub npov no peb tab tom muab lub npe tshiab, thiab cov kev txwv tsis suav tus nqi sawv cev thiab tus lej ntawm qhov muaj txiaj ntsig khaws cia hauv lub cim xeeb tau teev tseg ntawm "".
Tam sim no, thaum peb yuav siv tom qab lub npe "AtHomeModule", Arduino yuav paub nws hais txog lub npe tag nrho "AtHomeModule".
Yog tias koj xav kom koj lub thawv muaj peev xwm khaws 5 qhov tseem ceeb hauv kev hloov pauv 1, koj tsuas yog xav hloov qhov "1" los ntawm "5" thiab Arduino yuav tsim rau koj ib lub thawv sib txawv tuaj yeem ua qhov koj xav tau. Nco tseg, txawm li cas los xij, yog tias tus qauv raug teeb tsa xa nws qhov txiaj ntsig ua ntej nws muaj sijhawm los ntsuas 5 qhov txiaj ntsig ntawm lub ntsuas, koj yuav tsis pom 5 ntawm lawv raug xa raws li nws xa tsuas yog qhov txiaj ntsig tshiab txij li rub tawm zaum kawg.
Tom ntej no, peb yuav tsum tsim kom muaj ntau qhov taw qhia uas muaj cov taw qhia ntawm Arduino ntws siv los ntawm tus qauv los sib txuas lus, ib txwm txiav tawm los ntawm cov haujlwm tseem ceeb "nullptr". Ntawm no, Kuv tsuas yog siv "Serial" kwj ntawm Arduino uas sib tham nrog lub khoos phis tawj los ntawm USB chaw nres nkoj, yog li cov kab zoo li no:
Kwj *ntws = {& Serial, nullptr};
Tus cim "*" txhais tau tias hom yog tus taw qhia (qhov chaw ntawm lub hauv paus, tsis yog lub ntsiab lus nws tus kheej) thiab "" cov kab lus txhais tau tias hauv Arduino nws yog ib qho array, yog li peb tuaj yeem tso ntau qhov tseem ceeb.
Tom ntej no, peb yuav tsum tsim peb cov LED. Txhawm rau ua qhov no, peb yuav tsum sau ob kab hauv qab no:
GroveChainableLED:: Pins grovePins = {7, 8};
GroveChainableLED coj (& grovePins);
Yog tias koj tsis muaj Grove RGB LED tab sis tseem xav tau kev tawm tswv yim pom, koj tuaj yeem ua nws nrog kev hloov pauv yooj yim hauv daim duab. Hloov ob kab dhau los los ntawm kab no:
MonochromaticLED coj (LED_BUILTIN);
Hauv qhov teeb tsa no ntsuab tsim-hauv LED yuav qhib kom ntev li qhov saib xyuas tus nqi zoo rau kev noj qab haus huv thiab tua thaum nws tsis muaj nyiaj. Yog tias koj xav kom nws tig thaum nws tsis muaj kev sib cog (vim tias koj siv piv txwv li lub teeb liab liab siv qhov ntsuab ntawm tus pin 13) koj tuaj yeem siv kab no hloov:
MonochromaticLED coj (LED_BUILTIN, muaj tseeb);
Cov kauj ruam tom ntej yog tsim peb tus qauv nws tus kheej. Nws tau ua tiav thawj zaug peb tau txais nws qhov chaw nyob hauv kev nco los ntawm kev hu rau "getInstance" txoj kev, zoo li no:
LightModule *module = LightModule:: getInstance ();
Tom qab ntawd, peb yuav tsum teeb tsa qhov tsis nyob hauv "teeb tsa ()" kev ua haujlwm ntawm Arduino, pib los ntawm kev pib ua "Serial" chaw nres nkoj raws li ib txwm muaj hauv Arduino sketches:
Serial.begin (9600);
Peb tsim lub teeb pom kev zoo los ntawm kev sau kab no:
GroveDigitalLightSensor *lightSensor = tshiab GroveDigitalLightSensor ();
Tom qab ntawd, peb qhia peb tus qauv siv peb qhov taw qhia ntawm Arduino Stream los sib tham los ntawm lawv:
module-> setStreams (ntws);
Peb kuj qhia peb tus qauv siv peb lub teeb pom kev los saib xyuas lub teeb pom kev qhov twg tus qauv yog:
module-> setSensor (lightSensor);
Peb qhia peb tus qauv siv peb cov LED los muab tswv yim pom rau peb:
module-> setDisplay (& coj);
Thaum kawg, peb qhia peb tus qauv nws tau npaj ua ib qho kev teeb tsa sab hauv nws yuav tsum tau ua los ntawm kev hu nws tus kheej "teeb tsa" muaj nuj nqi:
module-> teeb tsa ();
Peb cov kauj ruam kawg tam sim no yog hu rau "khiav ()" ua haujlwm ntawm peb cov qauv, uas yog tsim los hu ua txhua qhov rov ua dua ntawm "voj" ua haujlwm ntawm Arduino los ntawm kev sau kab no hauv "loop" ua haujlwm:
module-> khiav ();
Tam sim no, peb daim duab kos yog thaum kawg npaj txhij xa mus rau Arduino thiab sim peb cov qauv!
Kauj Ruam 6: Xeem Peb Qhov AtHome Module
Txhawm rau rub cov duab kos rau Arduino, xaiv koj li Arduino UNO pawg thawj coj los ntawm kev mus rau hauv "Cuab Yeej"> "Chaw Nres Nkoj"> "[COMx lossis/dev/x] (Arduino/Genuino UNO)".
Qhov kawg, tsuas yog nyem rau ntawm "Upload" khawm (lub voj voos khawm nrog tus xub taw qhia rau sab xis, lub cim thib ob ntawm lub cuab yeej bar) txhawm rau rub cov duab kos rau hauv koj lub rooj tsavxwm.
Nws ua tiav! Tam sim no koj yog tus qauv yuav tsum ua haujlwm thiab xa qhov tseem ceeb rau koj lub khoos phis tawj pom hauv Serial Monitor ntawm Arduino. Koj tuaj yeem tshawb xyuas nws los ntawm kev qhib "Serial Monitor" ntawm Arduino hauv "Cov cuab yeej" ntawv qhia zaub mov thiab koj yuav tsum muaj cov khoom tsim tawm zoo li daim duab thib ob ntawm cov kauj ruam no:)
Kauj Ruam 7: Tsim Rooj Plaub Rau Tus Qauv
Koj tuaj yeem tsim lub thawv ntawv yooj yim rau koj tus qauv los ntawm laser txiav nws hauv 3mm plywood plank.
Txhawm rau ua peb lub thawv ntawv, peb siv cov ntawv me me los npaj tus qauv ntawm qhov ntev xav tau uas peb hloov kho tom qab. Koj yuav pom cov ntaub ntawv svg ntawm lub teeb pom kev zoo txuas rau cov kauj ruam no.
Tom qab ntawd tsuas yog lo lub ntsej muag ua ke tshwj tsis yog ib qho yog li koj tuaj yeem qhib nws tom qab, muab koj lub xov tooj hluav taws xob sab hauv thiab lo LED hauv lub qhov ntawm rooj plaub (peb siv daim kab xev pob tshab txhawm rau sau lub qhov thiab nthuav lub teeb ntxiv rau lo LED hauv ntej ntawm nws).
Tam sim no tsuas yog ntxiv roj teeb rau lub zog rau koj Arduino, kaw rooj plaub thiab koj tus qauv npaj tau thiab yuav tsum saib zoo:)
Pom zoo:
Lub Rooj Kub: Tsim Kom Muaj Xim Hloov Hloov Lub Cev Kub: 7 Kauj Ruam (nrog Duab)
Lub Rooj Kub: Tsim Cov Xim Hloov Pauv Kub Cushion: Xav kom koj tus kheej toasty thaum lub caij ntuj no txias? Lub Rooj Kub yog txoj haujlwm uas siv ob qhov zoo tshaj plaws e -textile muaj peev xwm - hloov xim thiab cua sov! Peb yuav tsim lub rooj zaum hauv ncoo uas sov dua, thiab thaum nws npaj txhij mus nws yuav qhia tawm
Tsim kom muaj Lub Tsev IoT Huab Cua Zoo Sensor Tsis Muaj Huab Cua Xav Tau: 10 Kauj Ruam
Tsim kom muaj Lub Tsev IoT Huab Cua Zoo Tsis Xav Tau Huab Cua: Qhov zoo ntawm huab cua sab hauv lossis sab nraum zoov nyob ntawm ntau qhov chaw muaj kuab paug thiab kuj los ntawm huab cua. Kub Humidity PressureOrganic GasMicro
Tsim kom muaj Binary LED Kho Kom Zoo Nkauj Lub Plawv (Blinkenheart): 6 Cov Kauj Ruam
Tsim kom muaj Binary LED Kho Kom Zoo Nkauj Lub Plawv (Blinkenheart): Nov yog kuv thawj qhov kev qhia, yog li twv yuav raug hu xa kuv cov lus qhia. Yog tias kuv tuaj yeem ua cov phiaj xwm uas tsis txaus ntshai, kuv yuav ntxiv nws ntawm no. Kuv nyuam qhuav pib kawm qee yam khoom siv hluav taws xob yooj yim thiab tus phooj ywg xav tau qee yam tshwj xeeb rau nws tus fiance rau Val
Tsim kom muaj Lub Teeb Hluav Taws Xob Hluav Taws Xob Nrog 555 Timer thiab Relay: 3 Kauj Ruam
Tsim kom muaj Lub Teeb Hluav Taws Xob Hluav Taws Xob Nrog 555 Timer thiab Relay: Kuv yuav qhia koj yuav ua li cas thiaj hloov pauv qhov sib pauv hloov pauv (siv 555 timer) los khiav qhov txuas. Nyob ntawm qhov txuas koj tuaj yeem tuaj yeem khiav 120vac lub teeb. Nws tsis hloov pauv qhov zoo nrog lub capacitor me me (Kuv yuav piav qhia tom qab)
Tsim kom muaj suab paj nruag tsis xwm yeem thiab lub teeb tsim hluav taws xob thiab pom qhov pov thawj ntawm Vajtswv: 4 Cov Kauj Ruam
Tsim kom muaj Kev Nyuaj Siab Suab Nkauj thiab Lub Teeb Hluav Taws Xob thiab Nyeem Ntawv Pov Thawj ntawm Vajtswv: Tsim cov lej tsis raug zoo zoo li tsis yooj yim sua. Txawm li cas los xij, nws yooj yim siv microcontroller los tsim cov lej tsis raug thiab tom qab ntawd siv lawv los tso saib cov suab thiab cov xim sib txawv. Thaum cov nkauj uas tau tsim tawm yog n