Ceiling fan/light node

  • Background
    Some time back I had posted a project that I was interested in pursuing. On my old X10 equipment that I ran years back, I had used some dimmer modules to control lights and ceiling fans in my house. One part that I liked about the modules was for the lights, it had a soft start in which the light would ramp up to brightness when turned on, and fade to black when turned off. I also had speed control of my ceiling fans with these modules. The only problem was that I had to use 2 modules for each light and fan combo and fit them into the fan shroud.

    The Idea
    I am working on designing some modules for controlling my light fan combos in a similar manner. Right now I am controlling them with Sonoff modules controlled by my Vera controller. I would like to try some node to node communication with these to possibly have them work if my controller is down. The WAF goes down heavily when the controller has issues which has happened on occasion.

    The Circuit
    I would like to include the pro mini and all electronics in the final design. I am also thinking of including both nRF24L01 as well as an option for RFM69 for others that may be interested in this. As a start, here is my proposed schematic for the dimmer control portion of the modules. I have included snubbers on both triac opto circuits, but on whichever one would be used for the light dimming, the snubber could potentially be omitted. I am looking for input on whether people think this design will work.

    I have already made a proto board with the zero crossing detector and tested it with this code which successfully blinks the LED on my UNO when power is plugged in. This tells me too that the zero crossing ISR is working as it should which is a start to the code that will run this.

    const uint8_t ledPin = 13;                          // Digital output pin that has the on board LED
    const uint8_t zeroPin = 2;                          // Digital input pin to which the zero crossing detector is connected
    uint8_t zeroCounter = 0;
    bool zeroState = 0;
    bool ledState = LOW;
    void setup() {
      pinMode( ledPin , OUTPUT );                       // Enable output driver for LED pin
      attachInterrupt(0, zero_crosss_int, RISING);      // Choose the zero cross interrupt and attach it to the ISR
    void loop() {
    void zero_crosss_int()  // function to be fired at the zero crossing to dim the light
      zeroState != zeroState; 
      if ( zeroCounter == 60 ) {                        // Every 60 zero crossings change the LED state
        ledState = (ledState == LOW) ? HIGH : LOW;
        digitalWrite( ledPin , ledState );
        zeroCounter = 0;

    I welcome any input on the design or code as I work through this, so feel free to chime in any time.

  • Mod

    @dbemowsk said in Reviving an old project:

    I had to use 2 modules for each light and fan combo


  • @yveaux One for the fan and one for the light. They didn't make a single X10 module that did both as one unit.

  • Mod

    @dbemowsk ah, ok. Now I get it 🙂

  • @yveaux That's why I'm trying to design a module that handles both as one unit.

  • I've been thinking about trying to make a dimmer using this chip:


    It does the heavy lifting on the zero cross logic and claims to be good with LED bulbs. It's meant to be very easy to make a potentiometer controlled dimmer, but if you can provide a variable voltage signal, you can control it from a microcontroller.

    I have been meaning to get one and experiment with it, but I've been more focused on learning how to use NRF5 modules at the moment.

  • @nagelc Thanks, I'll look into this more.

  • Admin


    Had a quick look at the datasheet for that IC.. It requires either a variable resistor, or a 0-10V input, to control the thing.

    With some RC filtering you could make an analog voltage from the PWM, but that is only 0-3.3V, or 0-5V, depending on supply voltages for the MCU, then you need to boost that up to the 0-10V..

  • Admin


    found some interesting reading about leading / trailing edge dimming: http://www.ledjournal.com/main/blogs/leading-edge-vs-trailing-edge-dimmers/

  • Hero Member

    According to this, avoid trailing edge dimmers to control inductive loads (fan motor in this case).

  • For now I am okay with leading edge triac based dimmers as all I am running are incandescent bulbs right now anyway, so I am going to stick with the triac based dimmers for now. Even in the future I may at least stick with the triac based dimmer with the snubbers for the fan control as that is an inductive load. If I could find some dimmable LED bulbs that use the LM3450 based driver made by national semiconductor or the TPS92210 from Texas Instruments, it looks like that type should work with triac based dimmers. This can be found referenced in this article from Digikey.

  • @dbemowsk Any progress I want to do this as well?

Log in to reply

Suggested Topics

  • 8
  • 2
  • 44
  • 29
  • 3
  • 1