WIFI Light Switch Controller (MQTT)

by Lynlimer in Circuits > Arduino

506 Views, 5 Favorites, 0 Comments

WIFI Light Switch Controller (MQTT)

light switch.jpg
PXL_20230219_223608781.jpg
Light switch.png

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

117.png
caps.png
pcb.png
esp 12 e.jpg
10k.png
servo.png
inserts.png
m2.png

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

 

Pcb Prototype Board x1: https://www.aliexpress.com/item/1005004482992911.html?spm=a2g0o.productlist.main.7.2bf52f1fohxURk&algo_pvid=c758abe6-24fe-4e8b-a29c-312e2616baa1&aem_p4p_detail=202302200921394082779875854790001987735&algo_exp_id=c758abe6-24fe-4e8b-a29c-312e2616baa1-3&pdp_ext_f=%7B%22sku_id%22%3A%2212000029319158672%22%7D&pdp_npi=3%40dis%21EUR%218.58%218.06%21%21%21%21%21%4021224cdb16769136992341075d0723%2112000029319158672%21sea%21NO%212160084717&curPageLogUid=gfN4X8WaSXEX&ad_pvid=202302200921394082779875854790001987735_4&ad_pvid=202302200921394082779875854790001987735_4

10k Resistor x5: https://www.aliexpress.com/item/1005003021542565.html?spm=a2g0o.productlist.main.7.446b3579XkyOlh&algo_pvid=5ebc1105-e4e8-4078-a878-af3705441e83&aem_p4p_detail=2023022009233310250572079625360002121646&algo_exp_id=5ebc1105-e4e8-4078-a878-af3705441e83-3&pdp_ext_f=%7B%22sku_id%22%3A%2212000023277083848%22%7D&pdp_npi=3%40dis%21EUR%213.8%211.9%21%21%21%21%21%402122457116769138135078589d072d%2112000023277083848%21sea%21NO%212160084717&curPageLogUid=EzIp7WByv2Yw&ad_pvid=2023022009233310250572079625360002121646_4&ad_pvid=2023022009233310250572079625360002121646_4


Electrolytic Capacitor, 1x 10uf, 1x 100uf: https://www.aliexpress.com/item/1005002075527957.html?spm=a2g0o.productlist.main.3.13d72ee7BB7Nlx&algo_pvid=3d2d1a33-acdd-4074-8261-e010b587959d&aem_p4p_detail=202302200925372620322909657180013901410&algo_exp_id=3d2d1a33-acdd-4074-8261-e010b587959d-1&pdp_ext_f=%7B%22sku_id%22%3A%2212000018654903084%22%7D&pdp_npi=3%40dis%21EUR%210.97%210.87%21%21%21%21%21%400b0a558a16769139372775972d0736%2112000018654903084%21sea%21NO%212160084717&curPageLogUid=swYYtYtv84v6&ad_pvid=202302200925372620322909657180013901410_2&ad_pvid=202302200925372620322909657180013901410_2

 

LM1117 voltage regulator x1: https://www.aliexpress.com/item/1005004321246364.html?spm=a2g0o.productlist.main.3.614260e3xVZO5V&algo_pvid=05ef8930-0460-44c5-a3e4-3fc416afe9f3&aem_p4p_detail=202302200928516601291172728800002126362&algo_exp_id=05ef8930-0460-44c5-a3e4-3fc416afe9f3-1&pdp_ext_f=%7B%22sku_id%22%3A%2212000028747228148%22%7D&pdp_npi=3%40dis%21EUR%215.47%213.5%21%21%21%21%21%40212272e216769141313254951d06e3%2112000028747228148%21sea%21NO%212160084717&curPageLogUid=p38zBN39tRtn&ad_pvid=202302200928516601291172728800002126362_2&ad_pvid=202302200928516601291172728800002126362_2


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

PXL_20230220_201146604.MP.jpg
PXL_20230220_202325185.jpg
esp 07 wiring.png
lm1117 circuit.png

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