Analogue style rotary dimmer switch - Sonoff + ESPEasy + MQTT

This is the other project I mentioned:

Thanks Robin I’ll take a look

1 Like

After a month or so of “soak testing” I’m satisfied with the safety and performance of this solution.
I’ve now finally installed the sonoff in the switch back box and the new faceplate has replaced the old analogue dimmer.
So far its all working great!

Slightly off subject.
Were you able to fit your Sonoff with its case in your light box?

Yes… but it was very tight!
I needed to remove more of the case and use thinner gauge mains flex to extend the wire.

1 Like

If you have a newer build home with stud walls it would probably be easier to pop the box out and hang the sonoff in the void behind box.

Please excuse the electrical noob question: as the lighting circuit is permanently closed (because the hue bulb is doing its own switching internally) why is neutral required at the switch to power the Sonoff?

The lighting circuit is not permanently closed - it’s controlled by relay in the sonoff.
Any mains electrical device requires a L & N to operate.
Where there is only a L at the switch means that the N is supplied to the bulb fitting via another route, but for sure the bulb will have L + N.
You cannot connect a device between L and Earth - it will trip your consumer unit due to earth leakage.
There are other people who posted on the forums who have positioned a sonoff switch by the bulb fitting where there are both L&N supplies.

Thanks for this.

Is this a feature you’re using in your design or just a side effect of the components you’ve used? If wired a different way could the circuit stay permanently closed with MQTT signals being used to tell Hue to switch the bulb off?

The sonoff inherently uses a relay to close the circuit for the connected load.
I guess it may be possible to hard bypass the relay, but I personally dont want to mess with the 240v side of the device.
Nothing to stop you wiring the sonoff in parallel with no load though…
(Although I like to be able to turn off power to the hue bulb with the relay in case I even need to change the bulb etc)

Can every dimmer be used with the sonoff?

Only rotary encoders can be used with sonoff.
You can see the encoder I used in the photos in the very 1st post in this topic.

Can you tell me how you connected the rotary encoder to the sonoff?
Regards
Dirk

I soldered a header on the sonoff, then used dupont cables to connect from the header to the encoder.

You can see in one of the photos in the 1st post:

Only diff is that I connected directly to the encoder thatcher than via the breadboard

I really liked this concept. When I worked with studios we used solid state relays to digitally control all the set lighting effects. The modules had zero crossing switching built in. Banggood sell modules like this plus a lot of arduino compatible switch modules but I doubt those have zero crossing detection. Take a look if interested.
80A SSR-80DA Solid State Relay Module DC To AC 24V-380V Output Not sure how good it would be but it has 50M ohms isolation.

Hey @hijinx

Well done for such a great explanation of your project. I am trying to figure out a way of wiring 4 regular non-smart LEDs like these into a spotlight array:

http://www.ikea.com/au/en/catalog/products/50337702/
http://www.ikea.com/au/en/catalog/products/30304651/

I want to be able to dim them via Home Assistant and Alexa only, not from some app.

The thing is, to the best of my understanding, if I place a Sonoff basic in my wall where the switch is, the Sonoff by itself won’t be able to vary the resistance and hence dim the bulb right? If that is true, then how could I go about solving this? Ideally I don’t want to swap out the current 4 bulbs.

Any tips would be greatly appreciated.

Thanks,

Quentin.

Hi,

Sorry for delay - busy w work atm
You are correct - there is no dimming capability in Sonoff switches.
All the dimming in my project is done in the smart bulb.

I have seen some dimmers that can be controlled by microcontrollers, but not in general availability.

Hey @hijinx FINALLY got around to doing this. Yes it’s taken me that long…

Works fantastically well! Very please.

Did you ever get around to defining these two rules?

Send IP address on start up (supported by my HA config)
Detect a long press of the rotary encoder switch to toggle the relay

Specifically toggle of the relay… I’ve got some smart bulbs that power on after boot so would be a great backup for if HASS or Network goes down. I’m planning on wiring mine slightly differently to your for this to work, was going to use the normal L+N input as you have but output to the bulb.

Thanks again for this, the dimming is super quick and responsive!

1 Like

Hi @badgerhome thanks for the feedback! :smiley: V pleased that someone else got it working!

Regarding the rules:
Yes to IP address (I will reply back with the config if I get a chance)
Sadly no to the long press - I have a hunch its possible, but I couldn’t figure it out. I think there is a bug in espeasy that meant the sonoff rebooted during my experiments, so I gave up.

My bulbs also light up with power (hue). I added a switch in HA so I can toggle the relay, but I know thats not what you’re after - sorry.

Not all bulbs are responsive. I tried to change the hue to a yeelight colour (wifi bulb) and rapid dimming caused the bulb to drop off my wifi network (I guess it crashed). But hue works fab.

No worries! Thanks for sharing. It’s very good.

Ah, that’s a shame. I’ll have to keep giving it a go and see if I can get anywhere. Do you know if the later Esp Easy versions have the rotary encoder or still only the test version?

I’m using AiLight on WiFi bulbs and it’s super responsive. Also tried it on some RF bulbs but the RF causes too much latency but I’m slowly replacing them anyway.

Does the relay button on the ESP still operate the relay? I’m almost tempted to either wire that to a separate momentary switch or expose a little pin hole in the light switch plate so that you can push the button with a SIM card type tool to turn lights on or off in event of network loss