Cov txheej txheem:

Bright Controllable Sunrise Teeb: 6 Kauj Ruam
Bright Controllable Sunrise Teeb: 6 Kauj Ruam

Video: Bright Controllable Sunrise Teeb: 6 Kauj Ruam

Video: Bright Controllable Sunrise Teeb: 6 Kauj Ruam
Video: Dua Lipa - Levitating (Lyrics video) 2024, Kaum ib hlis
Anonim
Bright Controllable Sunrise Teeb
Bright Controllable Sunrise Teeb
Bright Controllable Sunrise Teeb
Bright Controllable Sunrise Teeb

Koj puas tau sawv thaum 7 teev sawv ntxov, lub sijhawm ib txwm koj xav tau sawv los ua haujlwm, thiab pom koj tus kheej hauv qhov tsaus ntuj? Lub caij ntuj no yog lub sijhawm txaus ntshai, puas yog? Koj yuav tsum sawv thaum ib tag hmo (txwv tsis pub yog vim li cas nws thiaj tsaus ntuj?), Rhuav koj tus kheej tawm ntawm lub txaj thiab xa koj lub cev tsis nco qab mus da dej.

Txoj haujlwm no tsom mus daws ib qho ntawm cov teeb meem - tsaus ntuj thaum sawv ntxov.

Muaj ntau lub teeb hnub tuaj pheej yig nyob ib puag ncig, tab sis lawv txhua lub zog qis thiab daj ntseg. Lawv zoo li lub teeb hmo ntuj, uas yuav tsum ua rau koj tsaug zog zoo dua. Tsis yog yam kuv xav tau kiag li.

Nyob rau tib lub sijhawm, tsuas yog tig lub teeb ci ci yuav ua rau koj sawv tam sim, tab sis tsis maj mam txaus. Qhov kuv xav tau yog kev sib txuas ntawm ob txoj hauv kev - ua kom lub teeb ci qis, maj mam ua kom nrawm dua, tom qab ntawd lub tswb nrov tawm mus thiab koj tsis tsaug zog lawm. Cia peb ntxiv me ntsis nkauj noog rau nws, thiab koj sawv hauv ntuj ceeb tsheej txhua tag kis!

Kauj Ruam 1: Teeb Teeb

Teeb Teeb
Teeb Teeb
Teeb Teeb
Teeb Teeb

Ua ntej tshaj plaws, peb xav tau lub teeb nws tus kheej. Kuv muaj chav zoo nkauj zoo nkauj nrog phab ntsa dawb thiab qab nthab, yog li kuv tau mus rau 7 GU10 LED teeb, qee yam zoo li 6W txhua, ntau dua 40W ntawm lub hwj chim ntshiab! Qhov ntawd txaus los ua rau koj xav zoo li nws yog nruab hnub lawm. Tsis tas li nws tuaj yeem siv ua lub teeb pom kev hauv chav ib txwm niaj hnub.

Nws tsis muaj teeb meem npaum li cas koj sib sau ua ke, cov teeb uas koj siv nrog qhov nyob qhov twg. Txhua yam uas tseem ceeb - cov no yuav tsum yog cov teeb uas dimmable!

Hauv kuv qhov xwm txheej, Kuv muaj ntoo ntoo nrog 7 GU10 qhov nyob nrog, txhua qhov txuas ua ke. Kuv mam muab nws tso rau hauv lub thawv yas tom qab.

Kauj ruam 2: Dimming Theory

Dimming Theory
Dimming Theory

Hauv kev xav tsis muaj qhov sib txawv ntawm kev xav thiab kev coj ua. Hauv kev xyaum muaj.

Tswj lub dimmer los ntawm ESP32/Arduino zoo li tsis yooj yim li kuv xav. Kuv tau txais ib qho ntawm RobotDyn AC Light Dimmer modules. Cov chaw tsim khoom qhia lub tsev qiv ntawv rau qhov ntawd. Nws tsis ua haujlwm ntawm ESP32 (thiab nws nyuaj heev rau hloov pauv, vim tias nws siv ntau qib qis ATMega tshwj xeeb rau npe nkag), ua haujlwm ntawm Arduino Nano, ua rau lub ntsej muag txaus ntshai ntawm qhov qis nruab nrab. Tias yog vim li cas kuv siv qee lub sijhawm tshuaj xyuas seb nws txhua yam ua haujlwm li cas thiab ua rau kuv tus kheej txoj kev.

Me ntsis ntawm kev xav

Xaiv dimmer module siv TRIAC nrov heev: BTA16. Muaj ntau ntau kab lus hais txog nws. Kuv yuav sim piav qhia nws ntawm no.

TRIAC yog tus qauv uas tuaj yeem xa cov lus pom zoo lossis tsis zoo rau qhov tso tawm, lossis tuaj yeem thaiv nws. Los ntawm lub neej ntawd nws thaiv txhua yam. Txhawm rau qhib nws, peb yuav tsum muab nws lub teeb liab siab ntawm lub qhov rooj nkag rau 100 peb. Tom qab ntawd nws yuav nyob twj ywm kom txog thaum tam sim no poob rau xoom, uas tshwm sim thaum qhov hluav taws xob nkag hloov pauv qhov kos npe, hla tus lej xoom. Tom qab ntawd ntawm cov voj voog hauv qab no peb yuav tsum ua lwm 100 peb mem tes thiab ntxiv rau. Los ntawm kev xaiv thaum muab lub mem tes, peb tswj qhov ci ci: ua nws thaum pib, thiab nws yuav ze rau 100% kev xa hluav taws xob. Ua nws tom qab, thiab nws yuav dim. Txheeb xyuas daim duab saum toj no, piav qhia nws.

Txhawm rau tsim cov noob taum hauv tib lub ntsiab lus ntawm lub voj voog, peb yuav tsum paub xyov thaum nws pib li cas. Tias yog vim li cas dimmer module muaj Zero-Cross detector ua nyob rau hauv. Nws tsuas yog nce lub teeb liab (uas peb yuav ntes raws li kho vajtse cuam tshuam hauv Arduino) txhua lub sijhawm qhov hluav taws xob hla xoom.

Kauj ruam 3: Dimming xyaum

Dimming xyaum
Dimming xyaum

Yog, qhov no yog qhov koj yuav sawv, yog tias koj lub teeb tsis muaj qhov tsaus ntuj thiab tso tag nrho 40W ntawm lub zog rau hauv koj lub qhov muag tsaug zog.

Cov teeb meem tshwm sim

Muaj ntau yam teeb meem peb xav tau los daws.

Flickering.

Lub sijhawm tswj lub microcontroller yuav tsum yog qhov tseeb tiag hauv kev tig lub qhov rooj tawm thiab tawm. Lub tsev qiv ntawv RobotDyn qhia, muaj lub sijhawm cuam tshuam txhua 100us, thiab hloov lub qhov rooj ntawm lub sijhawm xwb. Nws txhais tau tias nws tuaj yeem yog +/- 50 microseconds tawm ntawm tus nqi zoo. Nws muab qhov txiaj ntsig zoo ntawm qhov ci ci siab, tab sis flickers ntau ntawm qhov ci qis. Tsis tas li yog tias microcontroller ua ntau yam khoom, nws txo lub sijhawm kom raug, yog li lub hom phiaj tshwj xeeb microcontroller yuav tsum siv rau lub dimmer.

Qhov tsawg kawg nkaus ci ci. LEDs muaj lub tshuab hloov hluav taws xob, uas yuav cia li tsis kam ua haujlwm uas tsis muaj lub hwj chim txaus. Kuv cov teeb pom kev ua haujlwm zoo pib los ntawm 10-11%.

Txawm hais tias muaj tus nqi no, qee qhov ntawm kuv lub teeb tsis kam qhib thaum pib. Txawm tias thaum nce qhov ci ci tom qab, lawv nyob tsaus ntuj nti. Tias yog vim li cas, thaum peb mus los ntawm OFF lub xeev mus rau qee qhov pom kev zoo, peb pib nrog lub sijhawm sov so ntawm 5 mus, thaum peb muab lub zog rau lub teeb. Tom qab ntawd peb txuas ntxiv nrog qhov xav tau ci ci. Nws yuav luag tsis pom, tab sis pab tau tiag tiag.

50/60 Hz mains zaus. Koj yuav tsum paub ntau npaum li cas tos ua ntej xoom tom ntej. Nws yooj yim zoo nkauj - peb tsuas yog saib lub sijhawm sib txawv ntawm ob qhov cuam tshuam kawg.

Hloov pauv qhov ci me ntsis. ESP32 qeeb heev, nws siv sijhawm 0.5 sec los ua qhov tsis tseem ceeb HTTP lossis txawm tias WebSocket thov, yog li tsis txhob cia siab tias yuav hloov pauv qhov ci ci, nws yuav tsum tau ua qee yam ntawm qib qis dua. Tias yog vim li cas, thaum nws tau txais qhov ci ci tshiab los ntawm chaw nres nkoj txuas, nws tsuas yog teeb tsa lub hom phiaj, thiab tom qab ntawd maj mam mus ze nws dhau sijhawm.

Kev daws teeb meem

Nov yog kuv tus lej Arduino yooj yim rau dimmer. Nws tos rau qhov kev hais kom ua (ib byte nrog lub ci tshiab) los ntawm cov lej nkag, ua haujlwm Zero-Cross cuam tshuam, tswj TRIAC, daws txhua yam teeb meem saum toj no.

Kauj Ruam 4: Teeb Meem (ESP32)

Teeb Meem (ESP32)
Teeb Meem (ESP32)
Teeb Meem (ESP32)
Teeb Meem (ESP32)

Nov yog cov phiaj xwm sib txuas ntawm txhua qhov khoom kuv muaj. ESP32 pawg thawj coj saib yog qhov txawv ntawm qhov kuv siv (Heltec), yog li cov pins tau xaiv zoo li coj txawv txawv, tab sis nws tseem yuav tsum ua haujlwm zoo. Xav tias dawb siv cov pins sib txawv hauv koj qhov project.

Nov yog txoj cai tswj hwm nws txhua qhov. Nws zoo nkauj ncaj nraim.

Cov yam ntxwv tseem ceeb

Tswj tau. Lub teeb txuas rau WiFi, pib WebSocket server ntawm chaw nres nkoj 81, tos rau kev hais kom ua. Qhov hom ntawv yog

Tsuas yog ob lo lus txib tau txhawb rau tam sim no: "set_brightness" thiab "update_settings", uas yog … zoo nkauj piav qhia tus kheej.

Tau txais sijhawm los ntawm NTP. Kuv tsis xav ua yam nyuaj dhau thiab ntxiv lub sijhawm tiag tiag rau cov phiaj xwm. Peb muaj Internet nkag mus, uas txhais tau tias peb tuaj yeem tau txais lub sijhawm tiag tiag los ntawm qee lub NTP server thiab tom qab ntawd taug qab lub sijhawm tam sim no siv cov txheej txheem kaw lus.

Tswb Tswb. Koj tuaj yeem teeb tsa ib lub tswb. Dab tsi nws ua tau tiag tiag: pib nrog qhov pom kev tsawg tshaj plaws thiab maj mam mus rau qhov ci tag nrho li 10 feeb. Tom qab ntawd nws nyob rau ob peb teev. Tom qab ntawd nws maj mam tig tawm ntau dua 60 vib nas this.

Txhua qhov ntsuas saum toj no yog teeb tsa tau.

Noog hu nkauj. DFPlayer mini siv los ua suab paj nruag. Muaj ntau cov lus qhia rau nws, tab sis qhov tseem ceeb koj tsuas yog xav tau ntsaws daim npav MicroSD, ua qauv rau hauv FAT32, nrog ib daim ntawv hu ua 0001.mp3. Cov ntaub ntawv no tuaj yeem muaj txhua yam uas koj nyiam, hauv kuv cov ntaub ntawv nws yog 15 feeb ntawm cov noog hu nkauj (nws yuav raug kaw), thiab nws ua rau kuv sawv ntxov zoo kawg. Nco ntsoov tias muaj lub peev xwm loj ntawm lub zog, thiab 1 kOhm resistors ntawm kab kab ntawm ESP32 thiab DFplayer - lawv yog nyob ntawm yeem, tab sis pab txo cov suab nrov.

Khaws cov chaw nyob hauv EEPROM. All teeb tsa tau sau rau hauv EEPROM thiab thauj khoom thaum pib. Nws ua rau nws muaj peev xwm siv lub teeb nrog tsawg kawg lub tswb nrov yam tsis muaj tus tswj txuas nrog.

Muab qee cov ntaub ntawv rau lub vijtsam OLED. Kuv Heltec ESP32 muaj lub hauv SSD1306 128X64 I2C screen. Tag nrho cov ntaub ntawv tseem ceeb tau muab rau nws Kuv paub, lub thawv zoo li tsis zoo, Kuv tsuas yog 3D luam tawm qee yam khoom thiab txiav lub qhov thiab lub qhov rais nrog lub laum. Ceev, qias neeg, tab sis nws ua haujlwm!

Kauj Ruam 5: Tswj Vaj Huam Sib Luag

Tswj Vaj Huam Sib Luag
Tswj Vaj Huam Sib Luag
Tswj Vaj Huam Sib Luag
Tswj Vaj Huam Sib Luag

Qhov ntawd yog lub plawv ntawm txoj haujlwm. Raspberry Pi nrog thawj 7 zaub, khiav qee Kivy pem hauv ntej-kawg.

Nov yog qhov chaws tag nrho.

Cov yam ntxwv

Sau hauv Python. Kuv nyiam Kivy, nws yog Python lub moj khaum rau cov neeg siv cuam tshuam. Yooj yim heev, tseem yoog raws thiab muaj txiaj ntsig (siv ntau C code sab hauv rau kev ua haujlwm siab thiab kho vajtse nrawm).

Huab cua Qhia qhov kub thiab txias tam sim no sab nraum. Yog tias koj txuas lub ntsuas hluav taws xob nyob deb - sab hauv qhov kub thiab.

SunriseLamp maub los. Lwm lub vaj huam sib luag qhia qee cov ntaub ntawv tseem ceeb txog lub tswb thiab tso cai rau koj kho qhov ci ci. Yog tias koj mus rau qhov chaw teeb tsa, koj tuaj yeem teeb tsa ib qho ntsuas ntawm lub teeb, suav nrog lub tswb ceeb toom, lub suab nrov tshaj plaws thiab ntxiv rau.

Screensaver. Renders Game of Life ntawm lub vijtsam tom qab qee lub sijhawm tsis ua haujlwm.

Muaj siv ntau dua li qhov ntawd, tab sis lwm yam zoo li tsis muaj txiaj ntsig.

Kev teeb tsa

Kuv teeb tsa txhua yam ntawm tus kheej ntawm Raspbian, thiab tam sim no tuaj yeem hais: tsis txhob rov ua kuv qhov yuam kev. Siv KivyPie, nws muaj txhua yam ua ntej teeb tsa.

Sib nrug los ntawm qhov ntawd, tsuas yog ua raws li phau ntawv qhia teeb tsa hauv cov chaw cia khoom.

Kauj ruam 6: Txaus siab rau

Tus kheej kuv zoo siab nrog lub cuab yeej. Kuv siv nws ua lub teeb pom kev zoo nyob hauv tsev ib hnub, thiab nws cia kuv sawv thaum sawv ntxov, nws zoo heev.

Kuv paub cov lus qhia tsis yooj yim thiab piav qhia. Yog tias leej twg ua qhov qub thiab muaj teeb meem - Kuv yuav zoo siab los pab!

Pom zoo: