DONOFF – WiFi enabled light dimmer


Part-1 – Introduction

Years ago I started building RF devices to measure temperatures and switching lights on or off. I even wrote a small book (in Dutch) about my findings and experiments. But I always wanted to overcome the main disadvantage of RF devices: no feedback about the status of the lights. I thought that could be done better and with the introduction of the small ESP8266 WiFi enabled processors it could! But SONOFF beat me with there WiFi enabled switches. One great disadvantage of the SONOFF devices is the poor software. To make the switches usable you have to upload third party (mainly Open-Source) firmware and install a Home-Automation solution to control the switches. Another disadvantage of the SONOFF switches is .. well they are switches (Switch On Off). So there is room for improvement!
Albeit: I introduce to you: DONOFF (Dimmer On Off)!

Een nederlandse versie van deze post kunt u hier vinden.

Project goals

The goals of this project is to make an ecosystem that is self sustained. So: you don’t need a Home-Automation system to control the DONOFF devices! Also, there is no substitute for a physical switch (ask your spouse)! You can attach an external toggle– or push-switch to the DONOFF hardware with which you can either switch the light On or Off (toggle-switch) or, with a push-switch, you can switch the light On or Off and dim-up and dim-down by long-pressing the (push) switch.
Every DONOFF has a web-server on board that you can use directly from any (Javascript enabled) browser. Accessing the web-server on a browser gives you the control page for this device:

I will, in four parts, explain how you can build and use this DONOFF ecosystem.

Every DONOFF installation has one DONOFF designated as a Master whilst all the others are designated as Slaves. From the Master’s webpage all the other (Slave) devices can be controlled.
Slave’s automatically register to the Master with their IP-address and Device Name. If you power-up a new DONOFF device it will automatically be added to the Master’s page. If you unplug a DONOFF device it will (after a while) disappear from the Master’s page.

Switches are always shown below the dimmers (yes, you can upgrade a SONOFF switch to this ecosystem but for obvious reasons it will not have the dimmer functionality).
The controls have the following function:

Every DONOFF device has a unique hostname (i.g. “floorlamp”) and an indication of which lamp it controls (i.g. the “Floor Lamp”). With the slider you can control the brightness of the lamp. Clicking on the Toggle-Switch-icon will turn the device “On” or “Off”, which does not affect the slider controlled brightness of the lamp. The lightbulb-icon shows whether the lamp is “On” or “Off”. Every DONOFF device has a settings page to control the various attributes of the device. Clicking on the “Settings-icon” brings you to this page.

The attributes have the following meaning:

this Device Here you can give this Device a hostname. The IP-address is assigned by the DHCP server in your network and can (will) change every time you reconnect the DONOFF device (but this will not affect the installation as the new IP-address will automatically be updated)
Device Role This can either be “Master” or “Slave”. Be aware: there can only be one (1) Master in your installation!
Master If this Device is a Slave, than you must enter the Master credentials. Every Master has the hostname “DONOFF” that can not be changed. But do enter the Master’s IP-address!
Device Type This can either be “Dimmer” or “Switch”. A Switch can only be “On” or “Off” (obviously)
BuiltIn Led pin This is the GPIO pin at which a Built In Led is connected (GPIO1 for an ESP-01, GPIO16 for a NodeMCU, GPIO13 for a SONOFF basic etc.)
External Switch This is the GPIO pin at which an external switch is attached. On the DONOFF board with the ESP-01 this is GPIO2
You have to indicate the type of external switch. Either “Toggle” or “Push”. A Push switch gives, besides the On/Off functionality also the ability to dim-up or dim-down the light
PWM out On the DONOFF board with the ESP-01 this is GPIO3. On the SONOFF basic this is GPIO12 (for a switch type there is no PWM but only HIGH [1] or LOW [0])
PWM frequency Well, the PWM frequency in Hz. A value between 200 and 900.
Min Percent This is the lowest value (in percent) at which the Led lamp still glows
Max Percent This is the maximum percentage you will control using the slider or push-switch. Normally this will be 100(%)
default Light State The value used by a Toggle-switch if the light is switched On
device Label The name of the light as shown on the web-page of this Slave or on the DONOFF Master’s web-page

So far for this short introduction of the DONOFF ecosystem.
In the next part I will introduce the DONOFF electronics.

This entry was posted in Arduino, DONOFF, ESP8266, Hardware, SONOFF, WiFi and tagged , , , , , , , , , . Bookmark the permalink.

22 Responses to DONOFF – WiFi enabled light dimmer

  1. Rob de Bie says:

    Beste Willem,
    Grandioos, wederom een hele diepe buiging !
    Mooi, zinvol en bruikbaar project.

  2. Rob says:

    Hoi Willem,
    na je slimme meter monitor gebouwd te hebben, ga ik dit zeker even volgen.
    Groet, Rob (andere rob dan hierboven!)

    • Hallo Rob,
      Het is zeker een project dat de moeite waard is. Ben nu nog druk in de Research & Development (eerste print-ontwerp heeft een verkeerd formaat Hi-Link 🙁 )
      Verder nog wat punten op I-en zetten. Maar dan krijg je ook wat!

      Ondertussen werkt DONOFF bij mij al vanaf februari 2019 probleemloos met één master, drie DONOFF slaves en een SONOFF switch.

      Je kunt hier een complete kit (zonder project box) kopen.

  3. diy electric bike says:

    Your style is unique in comparison to other folks I have read stuff from.
    Many thanks for posting.
    I will just bookmark this page

  4. K.G. Dik says:

    Willem , ik ben iedere keer weer onder indruk van de mogelijkheden van de huidige electronica, maar dat wist je al!
    Ik ben benieuwd wat je dit jaar allemaal weer fabriekt!

  5. Erik Meinders says:


    This is exactly what SONOFF misses; the ability to dimm your lights. Even LED lights, which of course is today’s standard. I can’t wait to see what else you come up with in 2019!?

    Keep up the good work,


  6. Roland says:

    Hi Willem,
    I’ve done your smart meter reader project with great pleasure before.
    And now see that you have another nice project; Donoff
    Maybe you have the Donoff pcb for sale separately?
    I will send you my personal data by mail
    Thnx in advance, Roland

    • Willem Aandewiel says:

      Hi Roland,

      Nice you like my projects.
      Send you a PM.

      In the mean time is selling DONOFF as a complete kit that you can order here.

  7. Rob says:

    mooi project willem. Nu nog een versie ontwerpen die zoals de zwave en shelly systemen achter een schakelaar in een wcd past.

    • Willem Aandewiel says:


      I’m not familiar with zwave and shelly but I wonder if they have PWM dimmers that small …. But of course that is the ultimate goal.

  8. Sune Bielefeldt says:

    Dear Willem Aandewiel
    It is a great project you have made here, just what I have missed for a long time.
    I am a great consumer of Sonoff, but have missed this dimmer feature that Donoff offers.

    I want to try to build one or more sets myself.

    Is it possible to buy PCBs from you, or maybe just Gerber files so I can order them myself?

    Best regards from Denmark
    Sune Bielefeldt

  9. Andrew Bennett says:

    Hi Willem, this looks interesting. Could you tell me if you still have PCB’s or files available? Thanks.

  10. Ed says:

    Well done, but just one remark: you also do not “need” a home automation system for the sonoff, can do that with a webserver as well, just as you did with the donoff

  11. Sorin Tudor says:

    Hi Willem,

    Congratulations for this project!
    I would like to reproduce it too, the presentation seems pretty clear to me and I would like to control some LED bulbs …
    My question is the following: what kind of LED bulbs can I use? Dimmable LED bulbs working at 220V AC are OK considering the DC power supply? If not, what kind of bulbs do you recommend?

    Sorin from Romania

    • Willem Aandewiel says:

      Nice you like my project.
      I have tested with Ikea, Philips and a view other brands “dimmable led-bulbs”. Mind you, all ‘mains’ led bulbs work internaly with DC voltage. The Donoff work as well with normal light bulbs.

      You can buy a complete kit here.

      • Sorin Tudor says:

        I’m glad to hear that!
        I hope not to bother with other questions if necessary.
        Thanks for the quick response!

    • Willem Aandewiel says:

      No problem!
      Keep me posted about your findings and progress.

  12. andrew says:

    Hi Willem,
    R1 marked on the board is not on the Bill of Materials. What value is it?

Leave a Reply

Your email address will not be published. Required fields are marked *