I have a question regarding A/C lighting for IoT just basically where to go for the information/parts I need.

I want to control the lighting in my bedroom/bathroom via IoT devices that will act as a dimmer.

I'll probably write my own small Django/Python server to control them via JSON Web API using JWT from my Raspberry Pi 3. They'll need to communicate with the light switches through some means like WiFi as the RPI3 is set up next to the TV, so I'll put whatever microcontroller board into the physical walls and route power to them (I'm not a hardware engineer so getting mains electricity behind the wall and converting it down to 5V DC is a little beyond my skillset at the moment).

In the bathroom there are 4 incandescent vanity lights, I have them controlled by manual dimmer right now. In the bedroom I have 3 incandescent lights in the ceiling fan, ceiling fan is not dimmable. The electrician who wired them did not use a neutral wire. I'd like to stay with incandescent lighting for the main lights for reasons outlined here:


I only use my Smart-Link LB130 LEDs for auxiliary lighting, they'll be using my RPI3's access point as soon as I get that set up and then controlled via Web API.

I'd prefer not to use a store bought solution for a variety of reasons.

A) Smart Hubs are ridiculously overpriced and unnecessary, and there's too much "magic" going on behind the scenes from a software perspective, not to mention highly insecure if a company produces write papers that reveal their internal radio communications protocols, which on an Insteon dimmer I bought a while back they did.

B) These lights were not wired for neutral, and most of the store bought solutions require that. It looks like there is a neutral wire behind the wall, but I'm not sure if I need to do anything more than just hook it up.

C) I'd like to create my own custom security encryption scheme and protocol for communication with the lights rather than vendor-provided, which, if my UDP-based LB130s that I reverse engineered are any indication, need a lot of improvement from a software perspective.

I'm still learning the ropes with hardware though, only have done some basic DC wiring and soldering yet.

Any ideas on how to dim A/C lighting from a microcontroller board like a TI Launchpad (I've got a MSP530F5529LP I'm playing around with, also got a Teensy I haven't touched yet) and get power to the MCU from behind the wall?

  • \$\begingroup\$ I'd say someone hacking into your dimmer and playing with your lights is a pretty minor issue compared to the learning curve you're going to have to go on to do all this yourself. Mains electricity is not something for the novice. \$\endgroup\$
    – Finbarr
    Commented Oct 24, 2017 at 15:44
  • \$\begingroup\$ In what part of the world would an electrician not use Neutral? That has to be the first misunderstanding you need to cope with. \$\endgroup\$ Commented Oct 24, 2017 at 16:13
  • \$\begingroup\$ America, believe it or not, and apparently the guys who wired this house (built 2013) also wired the same circuit that was in the garage also fed outdoors to a lighting system which got water damage and created several shorts to the GFCI in the garage and we had to have the wiring leading outside and the housing for it replaced and rewired to handle higher current recently. That's a story. \$\endgroup\$ Commented Oct 24, 2017 at 21:57
  • \$\begingroup\$ I found this here that seems to maybe point me in the right direction, but I'm not sure if that could control the 3 lights in the ceiling fan, it looks like it's 230V according to the diagram. instructables.com/id/… \$\endgroup\$ Commented Oct 24, 2017 at 22:06

1 Answer 1


I think using a Triac and a Opto-coupler hooked up to your MCU GPIO or PWM output it is enough... check this circuit for reference... I have used a similar circuit to control transformers instead lights to deliver DC current and works nice

Circuit example

  • \$\begingroup\$ Don't forget that the uC will need a zero cross reference \$\endgroup\$ Commented Oct 31, 2017 at 0:37
  • \$\begingroup\$ Although output might just average out without minding ZC? Simple and dirty. \$\endgroup\$
    – jalaffo
    Commented Oct 31, 2017 at 5:40
  • \$\begingroup\$ you are right, I missed the Zero Cross reference, thanks! \$\endgroup\$
    – zeke
    Commented Oct 31, 2017 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.