DIY Hybrid Sonoff Smart Switch for $10

20,890

238

30

Introduction: DIY Hybrid Sonoff Smart Switch for $10

About: A computer geek with 10 fingers and 10 toes and 10 heads...(binary joke)

I wanted to replace all my home wall switches with smart switches but everything I saw either looked ghetto, was overly expensive or failed to fit in the small footprint of standard North American switch boxes. I had played with the ever popular Sonoff Basic modules from ITEAD (http://www.itead.cc/) but I struggled to find an elegant solution to placing them safely in a single wall socket along with a suitable (non fugly) switch... then, while fumbling to reinstall a standard switch after a failed upgrade, I noticed something.

I saw that the mechanical switch was essentially two parts fused together and I wondered if I could somehow split them apart and replace the back with a laminated Sonoff Basic...

Not only was the end result a success, but the total completed depth was exactly the same as the original unmodified simple (aka dumb?) mechanical switch.

Simple, elegant and complete with ambient backlit indication, I had found the holy grail of cheap, clean, safe and easy-to-install smart switches.

Follow along and see how you can build one for yourself.

This is what you are building:

and this is what it should look like once it's installed!

Step 1: DISCLAMER

This project assumes that you understand the risks of dealing with high voltage (110V) and home MAINs current. This instructable is NOT for beginners. You should have (at a minimum) a good knowledge of soldering and working with electronic components.

I don't want to sound like an old maid, but PLEASE don't do this project if you don't feel comfortable with any of these things.

It should go without saying that I cannot be held responsible for any and all damage to property and/or you or anyones life either directly or indirectly related to this instructable! Please take any and all precautions. Work in a safe and clean environment.

PLEASE BE SAFE! I CAN'T STRESS THIS ENOUGH!

...

Ok, if you are still with me, lets get started!

Step 2: Gathering the Required Parts and Tools

Step 3: Disassemble the Mechanical Switch

Just as the title implies, here we want to deconstruct the old-school dumb switch. It's actually pretty simple.

Start by locating the tabs that hold the metal plate to the plastic module. There should be four, two at each end. With a small flat head screwdriver, wedge it underneath each and pry them back. Don't break them as you will need them later. It's very easy to break them so work slowly and don't bend them more that needed to free them from the plastic part.

After prying the tabs, you should be able to separate the metal and plastic parts with very little effort. Take the metal part and put it away for later.

Next, using a pair of needle nose pliers, place one end into the space where the tabs were located previously and twist to apply pressure and hopefully break the bond (either glue or sonic welding). Repeat this process for all four tab locations. If all goes well, the two parts should separate cleanly leaving only trace marks. Don't worry about them, they will not be visible in the final product.

Take the base (the part with the metal screws and loose metal tab and put them away (future project?) you won't need it for this instructable.

Step 4: Disassemble the Mechanical Switch (Continued)

Using the flush cutters trim and remove all of the loose tabs exposed. Everything except the round bumps and the two long rails on either side need to go to make the area as clean and even as possible. Don't worry if its not perfect. Just do your best. The cleaner the job the easier and cleaner the final lamination step will be.

Now turn it over and using the small flat head screwdriver, place it on one side into the crack to pop out the toggle switch (the part you normally use to switch it on or off). Gently lever it out, this should be quite easy. Don't force it or you will mar the finish.

Turn over the toggle switch part you jut freed to pry and free the tension pin and the spring under it. It should come out with very little effort but be careful as it can pop out pretty unpredictably. If you are afraid for your eyes, wear protection... that's probably a good advise in general. :P

And now that that's done, hopefully with your eyes still intact, create a channel through the center using the flush cutters. This is so we can pass wires later.

Step 5: Flash the Sonoff (with TASMOTA)

Alright! Now we are ready for the fun part!

The Sonoff out of the box is a pretty great little (and crazy cheap) IoT device than can turn almost any light, appliance or plug into a internet controllable device. While you could use it as it comes with the default firmware, for this tutorial we will need to flash it with a shiny new and completely awesome custom firmware called TASMOTA. I did consider writing the how-to here on how to get that done, but I felt that would be a bit redundant as there are already a TON of awesome tutorials that cover it much better than I could.

Take a moment and watch this video by DrZzs over at YouTube. While you're at it, do him a favour and give him a like and if you like his videos as much as I do why not Subscribe to get notified when he releases new videos.

Step 6: Prep the Sonoff Hardware

Once you have the Sonoff firmware updated, we need to remove the two screw terminals, extend the LED and attach the push button to the board.

This may seem a little daunting but it's really not that hard.

First locate the small LED, just beside the very tall push button (actually while were talking about the push button, now would be a great time to trim it down so that it extends no more than the height of the relay [the black box], shorter is fine). The LED has three leads (wires) but we only need two of them. The centre lead is the common wire (3V) and the lead on the side nearest the pushbutton is connected to the micro-controller pin. The remaining pin is unused. Using the flush cutters clip the unused pin right at the base of the board (we don't need it) and cut the other two roughly 1cm (1/4 inch-ish) from the board. This will free the LED from the board.

Using two thin wires (roughly 7 cm or 3 inches) solder each to the centre pin and the short lead of the led. If you are using coloured wire I recommend using red for the centre and black for the short lead. The remaining longer lead should be removed completely as it is not used. If you are using shrink tubing slip some over each wire making sure to cover all the exposed metal, and using a heat gun or lighter/match heat them to shrink them in place, slip two more pieces of shrink tube onto the wires and then solder the other end of the wires to the LEDs original lead locations. Once firmly in place slide the tubing over the exposed connections and repeat the heating process to set them in place.

Now we need to desolder the two screw terminals. I found that the easiest way to achieve this is using a little lateral pressure on each side while heating up the solder under each pin. Alternating from pin to pin. With a little skill (or luck) the terminal should fall out and leave two holes under each. This was probably the most difficult part of the process as now you need to remove the excess solder filling the holes. This will involve heating the solder and using copper solder weave remover or a solder removal tool... I still haven't found an easy way to do this so I simply used a very small drill bit and re-drilled the holes exactly in the same place. Hopefully if you haven't totally messed things up (I did on my first try) you should end up with something that resembles the photo here.

With the holes all clean and open, you need to solder heavy (but not solid core) gauge wire in place of the screw terminals. At the end of the board that has the relay (black box) you should attach the the neutral (usually white) wire (the one on the outer edge) and the live wire (usually black) and on the other end you only need to solder the live wire (usually red) in the hole closest to the centre. Check the photos for reference. I didn't have any white wire so I used yellow... but I really recommend using the standard colours so anyone looking at the installation in the future should understand what they are looking at.

Last but not least, you need to solder and shrink tube another two wires, this time to the new push button. The button should have four leads. Two on pointing out of each side. Most of the time they are mirrored so you should clip/cut off the leads from one side flush so they don't get in out way later on. The other end of the wires should be soldered to the sonoff in the outer two pins (order doesn't matter here) of the header. The same place you used to flash the firmware in the previous step.

Step 7: Final Assembly

With all the soldering done, it's time to start the assembly.

The first thing to do is hot glue the push button to the inside of the plastic enclosure. Locate the end that has the word TOP engraved into the metal frame. This is the end we want the button to be installed. Pass the button through the hole from the back and place a small dab of hot glue on the underside (the side that doesn't have the small round button) and glue it directly below the round rubber stopper. Placement is not critical but I found it works best when it is as close to the centre-line as it will make the next part a little easier.

Now take the switch cover and place a large blob of hot glue at the place that will meet with the button. This is why I placed the button in the dead centre just below the rubber stopper. If you look closely at the underbelly of the cover, you should see a small point sticking out about the size of the tip of a pen. This marks the exact location where the cover will meet with the stopper. So the hot glue should go below this spot.

Once it dries hard, do a test fit by re-installing the cover and testing the button. If you put enough hot glue, the button should not move at all but it should still give a satisfying little click when depressed. If it's loose, remove the cover and add more glue, if it's not clicking and doesn't move at all, you've put too much glue; remove the glue and start over. It sounds harder than it is. There is a lot of margin here so don't worry about using too much glue. Check the pics to see what I found seemed to be the just-enough point for me. :)

With the glue gun still hot, turn over the switch assembly and place a blob of hot glue (a little higher than the round extrusions) at each of the four corners. This is to provide a stable surface that has a safe distance from any metal to mount/laminate the sonoff. When dry and hard, do a test fit and make sure the sonoff sits level and doesn't wobble. If it wobbles, just add some more glue and check again.

When you feel you've got it right, take the LED and bend the wires at the base, slowly as to not break them, so that they are perpendicular to the LED. Then place the LED in the hole at the back of the switch assembly. You don't really need any glue here, but if you feel differently go ahead and add a dab. Just make sure not to cover the front of the LED or obstruct the light on its sides. Otherwise the effect will be far less impressive.

If you used shrink tubing during the soldering steps you should be good right now to continue to the final lamination step, but if you see ANY exposed metal on the LED, now is the time to cover it with some electrical tape. I can't stress this enough. You REALLY DON'T want to have a short here. Unless you want to burn your house down or cause serious harm. I know I mentioned this earlier, but I feel it's important to re-iterate how important it is to be extra cautious when dealing with high voltage.

Step 8: Final Assembly (continued...)

Last stretch. All your hard work is about to pay off.

Laminate the Sonoff to the switch assembly and wrap any excess wire from the LED and Switch in a tight loop and place them in the centre of the switch.

While holding the two components together, glue them together by placing a glob of glue over each corner where they meed the existing stabilization glue spots, so that glue touches the existing glue spots and extends over to the other side of the board. This will keep the board laminated together and stop them from separating easily.

Step back, take a deep breath and admire your newly created smart switch!

You may have noticed that I added some black electrical tape around the entire switch. I did this because my 3D printed enclosure wasn't completed yet and I was being a bit paranoid about installing it naked as it was. In hindsight, I think it was a good idea so I recommend you do the same. You know what they say, "better safe than sorry".

Share

    Recommendations

    • Water Contest

      Water Contest
    • Fix It! Contest

      Fix It! Contest
    • Tiny Home Contest

      Tiny Home Contest

    30 Discussions

    0
    None
    awelsh4

    Tip 3 months ago

    This is not a very safe install as-is. But, with a 3D printer, you can print out a new enclosure to mount everything in, making this a safe hack to install in the wall, and enable plenty of breathing room for the circuit.

    2 replies

    Are you offering to help design and print one for me? ;)

    0
    None
    chadwr

    2 months ago

    I used this same module about a year ago to control a room at my house but had no elegant interface for it. I used a push button on a blank cover plate and while this worked it didn't match the outlets and other cover plates at my house. After seeing this instructable I immediately went and modified it to use a standard decora style switch as you did. I took it a step further and 3d printed a back cover to enclose the electronics. Then I 3d printed a flat spring for the bottom of the rocker lever and another piece to activate the tactile switch. I use the stock firmware for now, so I also mounted the LED to the rear of the circuit board and drilled a hole in the switch housing. This allows the switch to be lighted from the front and then you know the WIFI status as well. I don't have the pictures right now but I have done this to 2 rooms at my house and it has worked beautifully. Just wanted to thank you for the instructable and ideas as the interface was stopping me from adding more of these. Now I need to figure a way to make the dimmers as the Lutron Caseta Dimmers that I currently use can add up quickly.

    1 reply

    That sounds awesome! I wish I had a 3D printer at home. One of the reasons I left those types of elements out of this is precisely because I am sure the availability of a 3D printer is still not as prevalent as I would like. I would love to see the end result. Maybe even collaborate on a future project?

    0
    None
    JPe22

    3 months ago

    Would it not be handy to use the third wire of the LED, I think it's for RED, and connect it to a not used pin (via a resistor) so you can see a different color for ON and OFF?

    This is BTW one of the best descriptions I've seen, great work!

    5 replies

    That is a great idea! The only issue I see with it is that there are no easily accessible GPIOs. It is doable but it would require soldering to the chip ESP8266 directly. Maybe I'll add it in a future instructable. Thanks for the compliment and great ideas!

    isn't GPIO14 free?

    Afbeeldingsresultaat voor sonoff basic

    It's being used for the tact switch/push button

    Push button is GPIO-0 !

    The onboard button is on GPIO-0, I don't mess with the GPIO-0 because it can easily cause unintended firmware resets and that's really not fun to deal with. Using GPIO-14 with the tact switch allows better switch control especially if you decide to use SwitchMode 5 or 6. There are other options for the LED like swapping it out for a NeoPixel (WS2812B) for example. This would not require any additional pins and would allow you to output any RGB combination with a single LED or even an entire addressable strip over only one wire. If that's not good enough, you could also use a I2C GPIO expander and add as many extra GPIO pins you need.

    0
    None
    M.J2

    3 months ago

    Nice work, truly the best looking implementation I've seen on these switches.

    A caveat for those doing projects like this. Sonoff switches are not UL or CSA certified or rated. Nor are they rated for in wall usage especially when modified. Those standards are not arbitrary or capricious, they come from learning; from accidents, from loss of property, loss of lives! The UL or CSA rating informs consumers that the product has been tested and verified to meet some minimum safety standards.

    Also if, God forbid, a Sonoff switch should start a fire in your home, your insurance will not cover you for using non UL listed products and/or self modified switches.

    These switches are cheap and great for projects, just keep in mind their limitations and above all be safe, be smart, and have fun! My $0.02.

    2 replies

    First, thank you for the kind words! These are all very valid points. I am a strong advocate of standards and safety. If you know what you are doing and take enough caution, however, this setup should be quite safe. I think the main reason the Sonoff is not UL or CSA certified is a cost issue. It can cost from a few thousand to a few million dollars. This would make a $5 product turn into a $50 product...

    Again your project here is top notch, really. My warning was intended to add to your disclaimer and to be sure people are going into this project with both eyes open.

    No doubt cost is a factor there. Though Id like to point out there are switches out there with similar features, UL listing, are already built as an in-wall switch, and are sub $30, e.g. Inovelli switches.

    Thanks for your Instructable, I love to see what people come up with!

    Is it possible with the sonoff to make the light fade on slowly? I'm not finding good solutions off the shelf to have a sunrise sort of effect for waking up in the morning.

    1 reply

    It would depend on what kind of light. Standard light bulbs (those you screw into a regular outlet) are not with this setup. It is doable with a dimming circuit but it's a bit complicated. However, if you are using LED lighting, especially something like Adafruits NeoPixel strips, then absolutely. The TASMOTA firmware supports most addressable LEDS and it's relatively easy to setup. I will put together another instructable soon that shows how this can be achieved.

    0
    None
    HGC

    3 months ago

    Yes Brilliant, I’ll be making this ASAP. You are only using the plastic housing from the switch, and if the sonoff is UL approved, you would probably have a pretty good case with the insurance. The chances are though if you had a fire it would be from an electrical short caused by the user, not sure if insurance covers that or not. So I don’t have to reinvent the wheel or get the wrong size, please put in a link to your switch or at least the dimensions

    2 replies

    After further searching, it seems that there are a few that might be affordable at amazon, I still recommend a local hardware store, but if you really want to buy it online check this out https://amzn.to/2IrOqJ0

    Thank you! The switches I bought are from a local hardware store called Rona. But they are made by Cooper. The specific model is 7501W-JP-C. I looked on Amazon and their prices are far more expensive that in store. I bought them by the box of 10 for only $18 CAD. That makes them less than $2 each. As for the module, it's the Sonoff Basic and I recommend you get it from iTead directly. Here is the link: https://www.itead.cc/smart-home/sonoff-wifi-wireless-switch.html . Amazon does have some but they are generally much more expensive and sellers pop in and out of existence too quickly to make any link I give you any good.

    Amazing, just need a case.