WIFI Light Switch Controller (MQTT)
by Lynlimer in Circuits > Arduino
538 Views, 5 Favorites, 0 Comments
WIFI Light Switch Controller (MQTT)
I wanted a safe way to controll the ceiling light.
No relay, no 230v...
This is a wifi controlled servo articulated Light switch controller.
5v Usb cable, usb powersupply
Its communicating over MQTT, so you need a MQTT system up and going.
The lever is allways going back to center, so its not interfering for manual use of the switch.
Supplies
Servo x1: https://www.towerpro.com.tw/product/sg90-7/
esp-12e x1: https://www.aliexpress.com/item/1005001520382593.html?&_t=pvid:d5876dea-23c7-4c4a-9f78-34867a6169de&afTraceInfo=1005001520382593__pc__pcBridgePPC__xxxxxx__1676913659&spm=a2g0o.ppclist.product.mainProduct
Heat inserts M2 x3: https://www.aliexpress.com/item/1005004624377733.html?spm=a2g0o.productlist.main.1.75f864286jYy5E&algo_pvid=b64181d1-bf0c-4f75-a0b3-0406e70afe0c&aem_p4p_detail=202302201304563148468652295900002830455&algo_exp_id=b64181d1-bf0c-4f75-a0b3-0406e70afe0c-0&pdp_ext_f=%7B%22sku_id%22%3A%2212000029877028144%22%7D&pdp_npi=3%40dis%21EUR%211.05%210.89%21%21%21%21%21%40212244c416769270966878847d070d%2112000029877028144%21sea%21NO%212160084717&curPageLogUid=3ngfsJN6FgqB&ad_pvid=202302201304563148468652295900002830455_1&ad_pvid=202302201304563148468652295900002830455_1
M2 x6 and up socket or button head: https://www.aliexpress.com/item/32810872544.html?spm=a2g0o.productlist.main.1.5a3e5e8eRSg80S&algo_pvid=0907f467-27fa-4930-8df2-85bb182374e9&aem_p4p_detail=202302201308232627818458345820014218738&algo_exp_id=0907f467-27fa-4930-8df2-85bb182374e9-0&pdp_ext_f=%7B%22sku_id%22%3A%2212000026955302077%22%7D&pdp_npi=3%40dis%21EUR%211.8%211.43%21%21%21%21%21%40211bd4cd16769273034514407d06b4%2112000026955302077%21sea%21NO%212160084717&curPageLogUid=y4Cv59e7JkpE&ad_pvid=202302201308232627818458345820014218738_1&ad_pvid=202302201308232627818458345820014218738_1
Make Electronics
Cut prototype pcb board to right size, 7x12 holes.(20x32 ish)
It can be done quickly by scoring it with a knife along the holes at both sides, then brake it off in a wise.
Prepare esp-12e unit.
Solder a thin wire(solid conductor) on every solder points around esp module. 8-10mm length.
Spread them to fit 2,54 holes at pcb.
After fitting the wires in each hole, press module down. ensure they dont have a chance for short cicuiting. solder them to pcb.
Place 4 resistors under the esp module. se picture for referance.
Solder them. the top ends near esp, should all be connected to esp`s vcc.
The 5th resistor is mounted from other side crossing the 4 resistors, ending next to start/end of the 4 resistors.
5th resistor is ment for a pulldown resistor for gpio 15. (ref.esp wiring picture )
The capacitor in the wiring picture can be ignored.
The voltage regulator (117.3,3) should be at center on back side (esp facing down)
Solder it, and add the capacitors. (ref. voltage regulator picture)
Connect wires for power in/out of regulator now.
Connect 3,3v power to esp.
Now you can do the esp wiring (ref esp wiring picture)
Wire your servo power to voltage in(5v) at regulator, gnd to gnd. Signal to Gpio 14
Look over your connections!
If good, you can power it up(5v)
Load Up Code
You need a MQTT broker up and going.
I use mosquitto mqtt broker on a raspberry pie.
Lots of tutorals on that, so i dont need to repeat them.
You need to set your broker ip, wifi-name and password in the code
android app:
https://play.google.com/store/apps/details?id=com.app.vetru.mqttdashboard&hl=en&gl=US
app payload:
0 = off
1 = on
Print Parts
Glue the lever to a servo horn