Analogue style rotary dimmer switch - Sonoff + ESPEasy + MQTT

@hijinx Thanks. I suppose the lag comes mainly from the fact that I dim 3 HUE lights at once. so it has to send three commands each time. I also did not multiply by four. so I have more dimming levels. But yeah maybe that is a good idea - i might twerk mine.

Looking at your sketch I think you might improve the latency by increasing the step size from 5 to 16 (= 16 steps between 0 and 255)

A Hi!

I’m brand new to this system And have just got it running on my NUC. On the homepage I notice It’s picked up my chromecast audio.

Do you think that the hardware in this thread could be used to be a volume controller for the CCA?

Would be cool to control the speakers with the rotary and maybe play/pause with a press of the dimmer and next track with a double press?

Hi @Jammyb
Absolutely you could use the same approach to control audio volume or any other parameter driven change.
The things you’d need to change are:

  • the automation- to control a media player entity volume instead of a lights brightness
  • the value template for the brightness mqtt value as I would think that volume is in % rather than 8 bit decimal number (but check this)
  • the espeasy config that sends the brightness - this is 0-64 value that gets scaled by x4 - you could send 0-100 direct from the sonoff if that works for you

Also I saw another project posted a few days ago to control volume with a rotary encoder… have s search as that should give you inputs for automation. That project used a pi zero rather than esp8266

Nice project, be great to see it on Hackster :slight_smile:

1 Like

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.