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
This project requires surprising few ingredients. Essentially all you need is:
- A Sonoff basic
- Standard new style square North American wall switch *
- Small flat head screwdriver *
- Soldering iron *
- Solder and flux *
- Small push button/tact switch *
- Pair of flush cutters (or wire snippers) *
- Pair of needle nose pliers *
- Hot glue gun *
- A few glue sticks *
- Electrical tape *
- Shrink tubing to seal the wires *
you could use tape but the job won't be as clean
*= Affiliate Links
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".
Step 9: Optional, Print an Enclosure (or Have One Printed for You)
A lot of people asked me if I had a 3D printed model for the back to make the switch safer and even easier to install.
Well, I just bought myself a brand spanking new 3D printer from Creality (the CR-10S specfically) and after printing a lot of useless things to get that out of my system. I went into SketchUP and designed a simple, yet easy to clip-into-place back cover.
If you have built this switch (or a similar variant) head over to thingaverse and download your very own. If you don't have a 3D printer, you can also have one ordered for a small fee (I have never use the services nor do I make any money from endorsements of any kind)
Thingaverse Download: https://www.thingiverse.com/thing:3182660