I am doing a home automation project in which I should be able to control the lights on/off but more than that, the brightness of the lights.

I am using Home Assistant (not hassbian) and Node-Red along with MQTT.

I am using a normal bulb I purchased from a hardware store connected to a Sonoff ESP8266 and am able to use Node-RED to trigger a on and off state but am unsure how to trigger the specific brightness level.

Is it possible to control the brightness of any normal light that is made into a 'smart light' through the use of Sonoff? Or must they be devices that have that functionality made into the light itself.

(same for any other appliances, such as things such like a normal portable fan made into a smart fan through ESP8266 and controlling its speed.)

3 Answers 3


No, you can't do that using Sonoff since it is an on-off switch with relay.

You need an Triac to do that. Normally the brightness control applications for AC will be done through Triac by changing the firing angle.

  • Hi thanks for the suggestion on top of the answer! If I may ask, will the triac then enable me to control the brightness via nodered payload?
    – Eric Lim
    Commented Dec 23, 2018 at 19:51
  • Yes, you need to design a Triac based dimmer circuitry.
    – Electron
    Commented Dec 23, 2018 at 19:58

No, most Sonoff devices are just remote controlled relays, they can only turn the power on or off.

You can not use them to dim lights.


There are devices made specially for dimming using only on-off impulses to set the brightness. A common pattern is to use a short on/off signal for on/off, and a longer on/off signal to increase brightness in n % steps.

So provided you can make the Sonoff switch on and off sufficiently fast, and reliably to get the timing right, adding a device like this or any other similar impulse switch with dimmer should work.

(Note that I'm not suggesting to pulse-width modulate it - the shortest impulse necessary is ~0,5 sec. The output remains as set, until it receives the next command signal).

  • The Sonoff drive a relay, you really should not be driving these on/off quickly as you will just end up welding the contacts
    – hardillb
    Commented Dec 23, 2018 at 22:22
  • Please clarify that via edit in your answer. Future readers should not need to read the comments.
    – Helmar
    Commented Dec 24, 2018 at 0:19

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.