Hey! This thing is still a Work in Progress. Files, instructions, and other stuff might change!

Sonoff Basic Decora Cover (Push Button Version)

by Timpro Mar 17, 2018
Download All Files

Thing Apps Enabled

Please Login to Comment

Hi Tim,
I'm trying out your design but i'm a bit puzzled on how to install the sonoff in your case design ?
Is the Sonoff's back PCB facing the front or the back of the design ? (looks like the back because the front way is blocking the switch mount.

Also, Is there a back piece that needs to be printed to keed the sonoff in the case ?

By the looks of it, the back of the design is to wide to "snap" the sonoff's PCB in and hold it.

Thanks ;-)

Great design BTW

Nevermind, I found that you need to download the back and cover from https://www.thingiverse.com/thing:2804973/files :-)

Sonoff basic wallbox enclosure with decora faceplate
by mmasson

Glad you figured it out! Hope it turned out well for you :)

Have you had issues with the device resetting?
I've had this wired up on my work bench for about 2 hours and it has reset itself 6 times. If it is on it will reset to off and if it is off, it will stay that way. I see the light blink several times and then complete.

I am running Tasmota 5.13.1

I've had a couple odd issues, and Ive just sort of blamed it on the production quality of the sonoff, which may or may not be your case. I've had the wifi disconnect every 10 seconds on one sonoff, while another with the same firmware works just fine in the same location.

Does the up time on your sonoff reset? Or is it just the connection?

Have you tried a reflash with the minimal firmware (there's a line you need to comment/uncomment to toggle this), followed by a full firmware flash? I found this resolved most of my issues.

It appears to be a full reset - the logs start over with a new time stamp. I think that the GPIO 0 tact button may be hitting the button plate or maybe a wire has it bound up and activated. I'll do some digging today.
I made some changes in the way the wires connect - I have stranded cables that are soldered directly to the bottom (I posted some pictures on the "I Made This" section). One drawback is that the sonoff board doesn't sit all the way flush as intended. I think this difference is enough for the tact button to be activated against the reset button plate.

I ran into this as well, I ended up soldering some wires in place of the screw connections as I didn't want to risk them coming loose in the wall and causing a fire. My sonoff board also sits slightly elevated because of this, and exactly as you mentioned, the tactile button rubs against the hole and it's just enough to trigger a reset.

I ended up cutting the solder down with some wire cutters so it was a little lower, it helped a bit. If you edit the firmware to re-assign that GPIO as I've done with my newer sonoff's, then you should't have to worry about it anymore as the button will become disabled.

Also, I've uploaded a newer version of the frame (added a wider notch in the top so the toggle actually sits centered now), and a new version of the button support which holds more tightly and sturdy against the frame.

I'm more puzzled now. It is not the button. I left the cover loose and ran it for a while. I had the same issue so, I reflashed it per your recommendation and that seemed to help for a while then it started up again. However after the reflash, it is retaining its state after restarting so i hear the relay open for a few milliseconds and then go back to its last state.

I'm going to try a second board later this weekend using the same firmware I used on this one. We'll see how it goes.
What version of tasmota are you using?

Thanks for all the feedback. I'm determined to get this one figured out.

I tried a second sonoff board and only changed the project name. I even used the same momentary button and LED and it is working as expected. So, it looks like I have run across my first flakey sonoff board. As a side note, I've been testing this version of tasmota against a previous version that I've flashed 12 boards with and there is a significant delay in response times over MQTT. Not of concern to your project specifically, but just thought it was interesting.

Thanks again for all your hard work on this project! I'm sending a tip your way.

Flakey boards can definitely make things interesting. The first one out of my last batch refused to go into flash mode. Because I was determined it was something I was doing wrong, I spent a whole day on it until I tried another and it worked just fine. Lesson learned on that one. Interesting that you're experiencing delay times over mqtt, the only time I noticed this on mine was when it was having troubles staying connected to the mqtt server. Have you checked your MQTT logs?

I'm currently running tasmota version 5.12.0 on all of my switches, so far I haven't had any problems with the software. I have yet to experience a power outage or a loss of network connectivity, so I'm curious to see how they handle those situations. If I've set them correctly, they should retain their settings, and hopefully function if the wifi happens to go out.

Also, thanks for the tip!! Greatly appreciated =)

Odd, the second device works fine all day without issue. I put it in the case and it starts resetting like the first device. It seems to get worse with time which seems like an overheat issue but it isn't hot at all. This is bizarre. I'll retest with the case off tomorrow.

As it turns out, I have three distinct issues - two are solved and the last I believe I understand and will test. I was seeing two types of behavior:
1) Boot issues - in this scenario the device would light up but the web interface and the MQTT service would never publish. This was due to the onboard button being either slightly depressed or triggered horizontally when power was applied to the device. I clipped down the button to a shorter length and this issue was resolved.
2) Software restart issues - I was seeing two scenarios - one resulting in a random software restart ranging from 15 to 30 minutes and the other was a shorter interval (30 seconds to 2 minutes) software restart. Their triggers are different.
The longer interval restart appears to have been triggered by my not having serial logging disabled. I disabled that and it greatly stabilized the device.
The shorter interval issues occur when the sonoff board is fully seated in the box. If I pull the board up slightly off of the bottom of the box so that the contacts aren't near the plastic, the restart interval will go up to once every hour. If I take it out of the case entirely, it will run all day without issue. The reported WIFI strength ranges from 75-100 seemingly independent if it is in the box or not. The fluctuation looks more directly tied to me being between the device and the AP than if it is in the box.

I am going to try to print with different material and see how this affects the behavior.

That is some interesting behaviour. I had some issues when I soldered a few extra wires to the extra GPIO's on the sonoff. A solder joint ended up puncturing one of the wires I installed for a GPIO and shorted out when it was pushed in too far into the case. Is it possible one of your connections on the underside is shorting out? I don't think the type of material will affect this behaviour, but you never know. Did you trim the button on this sonoff as well? I found leaving the second portion of the sonoff case off (the piece that holds the sonoff down and in place, the one that fits around the headers) helped in troubleshooting. I found I was still able to slip the decora cover over the backside of the sonoff case and it functioned normally, this is how I discovered my wires were shorting out. Every time I put more force on the sonoff into the case, it would reset.

Keep me posted, I'd say bring it over and lets figure it out! But I don't think you're all that close lol.

Ok, it is still early in testing but already, most of the issues I was having are no longer presenting themselves. I brought up the issues I was having over on the sonoff github issues area and they recommended downgrading from the arduino esp8266 2.4.1 board driver to 2.3. I'll update you with my comment I had on this thread: https://github.com/arendst/Sonoff-Tasmota/issues/2678

"Ok, I am simply amazed at the difference between 2.3 and 2.4.1!
I reflashed the device and the only changes I made was to downgrade to 2.3, add the appropriate .ld and boards.txt files and now the device is lightning fast.

  • Before it would take a second or 2 for individual webpages to load from the device, now they are almost instant.
  • Before MQTT command responses would vary from 1-6 seconds, now they are nearly realtime.
  • You are aware of how long the NTP data would take to refresh, now it is updated in the first 10 seconds of uptime.
  • I am seeing no socket or timeout errors in the logs

I fully buttoned up the board in the wall switch box as before and, while it hasn't been online for long, it is definitely performing far better than it was on 2.4.1. Fully enclosed I have RSSI values of 90+

Thank you very much for the recommendation to change board versions. This is incredible!"

Even if this doesn't fully correct my issue (and I believe it will), I wanted to post this as the difference in behavior on both of my test switches is substantial. I am also posting this recommendation on my "I made one" page here.

I printed the enclosure and I like how it assembles but I have a question, what size LED did you design this for? 3mm?

Yes I designed this around a 3mm LED. I found that my new roll of filament printed a lot different than the first, and I actually had to ream out the hole slightly to get the LED to fit snugly.

I do have a second version which I hope to upload tomorrow, I can't tell you how many times I've printed and tweaked it to get it just right lol. The LED shows as a nice circle on this one, which was my original intent. Its similar to the TP link wifi light switches, as I have one in my home and I really like the look of it.

On my new version I found I had to add a spring around the switch to get the toggle to go back to its normal position, you may or may not need to do this depending on how strong your push button is.

Hope you enjoy! If you notice anything that needs tweaking let me know and I'll do my best to fix it.


I was wondering if a spring would be needed. I ordered the button and it should be here in a couple of days. I look forward to seeing what further improvements you have in mind. I too have a tp link and like the switch but not the price and am hoping that this will be a viable alternative. I am also playing around with pulling the LED line from the existing LED - just cutting the lead, adding extension wires and using that in the mount point you designed. I believe in tasmota the LED can be selectable on for off state or on state.

You could definitely pull the LED line from the existing LED. That is what I was going to do until I realized how easy it was to change the couple lines of code that gives access to the extra GPIO's. This way it was less soldering, and I find it to be a little neater in the end being able to use Dupont connectors.

If you're programming the sonoff using Arduino IDE, open the sonoff_template.h file and look for the lines below and edit them to look like this:

// Default module settings
const mytmplt kModules[MAXMODULE] PROGMEM = {
{ "Sonoff Basic", // Sonoff Basic (ESP8266)
GPIO_USER, // GPIO00 Button
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
0, // GPIO02
GPIO_USER, // GPIO03 Serial TXD and Optional sensor
GPIO_USER, // GPIO04 Optional sensor
0, // GPIO05
0, // GPIO06 (SD_CLK Flash)
0, // GPIO07 (SD_DATA0 Flash QIO/DIO/DOUT)
0, // GPIO08 (SD_DATA1 Flash QIO/DIO/DOUT)
0, // GPIO09 (SD_DATA2 Flash QIO)
0, // GPIO10 (SD_DATA3 Flash QIO)
0, // GPIO11 (SD_CMD Flash)
GPIO_REL1, // GPIO12 Red Led and Relay (0 = Off, 1 = On)
GPIO_USER, // GPIO13 Green Led (0 = On, 1 = Off)
GPIO_USER, // GPIO14 Optional sensor
0, // GPIO15
0, // GPIO16
0 // ADC0 Analog input

I've just uploaded my new version, I highly suggest giving this version a try as I much prefer it over the first design.

That's a good idea. Thanks for the code! If you're just switching the gpio but the functionality is the same, then you should be able to control that light via mqtt updates.

Also, your updates look good, it should help with with button return. Nice work!