Cov txheej txheem:

12V LED PWM Dimmer Nrog ESP8266: 3 Cov Kauj Ruam
12V LED PWM Dimmer Nrog ESP8266: 3 Cov Kauj Ruam

Video: 12V LED PWM Dimmer Nrog ESP8266: 3 Cov Kauj Ruam

Video: 12V LED PWM Dimmer Nrog ESP8266: 3 Cov Kauj Ruam
Video: LED Light Dimmer (1.8V-12V, 2A) Using PWM Control Module | POWER GEN 2024, Kaum ib hlis
Anonim
12V LED PWM Dimmer Nrog ESP8266
12V LED PWM Dimmer Nrog ESP8266

Thaum sim ua kom kuv tsev neeg muaj kev nyab xeeb dua qub, kuv tau hloov cov qij halogen rau coj teeb. Muaj ntau txoj kev xaiv muaj, los hloov txhua hom teeb pom kev zoo. Thaum ua qhov no, Kuv tau hla cov teeb meem hauv qab no: Kuv muaj lub teeb pom kev zoo uas siv 7 12 volt halogen qij, txhua 10 Watts. Lub teeb no tau tswj los ntawm tus dimmer, uas ua haujlwm tau zoo. Thaum kuv pauv lub qhov muag rau 12 volt coj teeb, txhua 1 Watt, lub dimmer ua haujlwm tsis zoo: lub teeb tau flickering, thiab qhov dimming me ntsis tsis zoo. Qhov no yog teeb meem nrog ntau qhov dimmer classical: lawv muaj qhov ntsuas hluav taws xob tsawg, uas lawv xav tau txhawm rau ua haujlwm.

Yog li, raws li kuv tus txheej txheem domotics, Kuv txiav txim siab los pauv phau ntawv dimmer los ntawm tus tshiab, uas yuav muaj qhov zoo ntxiv ntawm kev tuaj yeem tswj tau nyob deb. Kuv twb tau tsim lub dimmer siv N-channel MOSFET (IRF540), uas yog qhov zoo tshaj plaws rau yam zoo li no: nws tuaj yeem tswj tau los ntawm PWM teeb liab, thiab nws yog qhov tsis tsim nyog, nrog qhov ntsuas siab tshaj ntawm 100 volts thiab 33 Amps, ua kom txaus rau lub hom phiaj no (kuaj nrawm: 7 x 1 Watt = 7 Watts, faib los ntawm 12 volts muab qhov siab tshaj tam sim no txog. 58 Amps). Kuv xav siv lub dimmer no rau lwm lub teeb uas muaj 12 lub qhov muag, txhua 2 watts, uas muab qhov siab tshaj ntawm 2 Amps, yog li ntawd tseem txaus. Tsuas yog saib xyuas nws qhov zaus ntawm PWM teeb liab, tab sis qhov ib txwm muaj txiaj ntsig rau Arduino lossis ESP8266 (500 Hz lossis 1kHz) tsis muaj teeb meem.

Kauj Ruam 1: Kauj Ruam 1: Cov Cheeb Tsam

Kauj Ruam 1: Cov Cheeb Tsam
Kauj Ruam 1: Cov Cheeb Tsam
  1. LED Tsav Tsheb (230 volts AC rau 12 volts DC hloov pauv) Rau kuv lub hom phiaj, kuv xav siv qhov siab tshaj 24 Watts, yog li kuv pib tawm nrog tus tsav LED ntawm 12 volts thiab 2 Amps. Kuv pom ib qho ntawm Suav chaw faib khoom. Tus tsav tsheb no tau ntsuas 12 volts, 28 Watts, yog li nws txaus los tsav lub teeb ntawm nws tus kheej. Rau koj tus kheej qhov xwm txheej, koj tuaj yeem siv qhov sib dua lossis hnyav dua, nyob ntawm koj lub teeb.
  2. IRF540 n-channel MOSFET
  3. Adafruit Huzzah ESP8266 Breakout Vim tias kuv xav siv WiFi, thiab kuv nyiam Adafruit cov khoom, kuv xaiv lub rooj tsavxwm no: nws muab rau kuv ESP8266 nrog rau txoj haujlwm yooj yim pinout, tus tswj hwm lub hwj chim nyob hauv, thiab cov qauv zoo nkauj. Nws yog me ntsis overkill rau txoj haujlwm no, tab sis nws ua rau kev sim thiab debugging yooj yim dua.
  4. LM2596 raws DC-DC hloov pauv Yuav kom tau txais lub zog rau ESP pawg thawj coj los ntawm 12 volt, Kuv xav tau tus tswj hwm; cov hloov pauv me me no ua tau zoo heev, thiab pheej yig heev.
  5. Rotary Encoder nrog khawm ua haujlwm, nrog teeb tsa coj:

    www.sparkfun.com/products/10596

    Txhua tus lej nkag teb chaws yuav ua, tab sis kuv nyiam qhov zoo ntxiv ntawm tus ua-hauv LED.

  6. Pob tshab yas pob qhov rooj

    www.sparkfun.com/products/10597

  7. Resistor 4k7
  8. Resistor 1k ib

Kauj Ruam 2: Kauj Ruam 2: Circuit

Kauj ruam 2: Circuit Court
Kauj ruam 2: Circuit Court

Nov yog lub Circuit Court kuv tau siv: Kuv siv tus pin 4 & 5 ua cov tswv yim rau tus lej nkag teb chaws, thiab tus pin 0 rau khawm. Pin 0 kuj tseem txuas nrog rau ntawm lub rooj tsav xwm liab coj, yog li kuv tuaj yeem tshawb xyuas qhov ua haujlwm ntawm lub pob ntawm qhov ntsuas los ntawm saib cov coj no.

Pin 16 tau siv rau PWM tso tawm, thiab kuv txuas qhov no ncaj qha rau ntsuab coj ntawm Sparkfun encoder. ESP8266 yog 3, 3 volts, thiab txawm tias muaj 100%, kuv ntsuas tsuas yog 2, 9 volts tso tawm, yog li kuv txuas nws ncaj qha yam tsis muaj qhov cuam tshuam. Qhov kev tso tawm tib yam no mus rau Lub Rooj vag ntawm n-channel MOSFET, los ntawm txoj kev ntawm 1kOhm resistor. Qhov Rooj no tau rub siab rau 12 volts los ntawm 4.7 kOhm resistor.

Kuv siv DC-DC hloov pauv hloov 12 volts rau 5.5 volts, qhov no txuas nrog V+ cov tswv yim ntawm Adafruit breakout. Kuv tuaj yeem siv 3.3 volts thiab txuas nws ncaj qha, tab sis qhov no muaj kev nyab xeeb me ntsis.

12 V LED Teeb nyob hauv Circuit Court yog kuv lub teeb.

Kauj Ruam 3: Kauj Ruam 3: Txoj Cai

Kauj ruam 3: Txoj Cai
Kauj ruam 3: Txoj Cai

Kuv tso cai rau GitHub:

Sketch for ESP8266 LED PWM dimmer

Nws yog raws li lub tswv yim lwm qhov qhia tau:

www.instructables.com/id/Arduino-PWM-LED-D…

Tab sis qhov no tsuas yog kev tswj hwm hauv nroog, yog li kuv ntxiv kuv tus kheej MQTT-based domotics daws. Nws yeej ua tib yam nkaus, tab sis qhov sib txawv tseem ceeb yog:

  • tus naj npawb PWM ua ntej nrog Arduino yog 255, nrog ESP8266 nws yog 1023 (raws li kuv pom tom qab, tag nrho sim txiav txim siab vim li cas kuv cov teeb pom kev zoo LED tsis nce mus rau 100% ci ntsa iab …)
  • Kuv tsis tau siv 'Totempole' Circuit nrog 2 transistors, txij li PWM yog DC lawm, thiab ua haujlwm tau zoo nrog IRF 540.
  • Kuv tsis tau siv lub 10k rub-up resistors rau tus encoder, Kuv ntseeg qhov rub tawm ntawm ESP8266.
  • ESP8266 siv 3.3 volt logic siv 5 volt rau Arduino, uas ua pov thawj tsis muaj teeb meem rau IRF540

Lub software muaj cov yam ntxwv hauv qab no:

  • tig lub encoder yuav dim lub teeb (CW) lossis qis (CCW), los ntawm 0 txhua txoj hauv kev mus rau 100%, hauv 1023 cov kauj ruam, nrog qee qhov ua kom nrawm dua hauv qib qis.
  • nias lub pob yuav qhib lub teeb thaum nws tawm, siv qib kawg ci ci ci, lossis tua nws thaum nws nyob.
  • nias lub pob kom ntev dua thaum lub teeb ci yuav txuag qhov ci tam sim no raws li qib pib.
  • nias lub pob kom ntev dua thaum lub teeb tawm yuav tig lub teeb mus rau 100% qhov ci, tsis hloov pauv qib pib.
  • Nws yuav txuas rau WiFi teeb tsa txhais los ntawm 'SECRET_SSID' thiab 'SECRET_PASS' cov hlua, uas tau khaws tseg hauv cov ntawv cais hauv kuv daim duab, hu ua 'secrets.h'
  • Nws yuav txuas rau MQTT server hauv WiFi network, siv 'MQTTSERVER' thiab 'MQTTPORT' cov hlua hauv tib cov ntawv.
  • Koj tuaj yeem siv MQTT cov ncauj lus nkag 'domus/esp/in' los teeb tsa cov lus txib: 'ON' lossis 'OFF' kom qhib lub teeb lossis tua, lossis tus nqi ntawm 0 txog 1023 txhawm rau hloov qhov ci ci.
  • Nws yuav tshaj tawm lub xeev ntawm MQTT cov ncauj lus 'domus/esp/uit' (ON lossis OFF status) thiab 'domus/esp/uit/brightness' (tus nqi ci ci).

Pom zoo: