December 10, 2022
Description
This is a case for the Sonoff Basic Wifi switch designed to fit tightly enough (like a Speedo) to allow in-wall light switch installation. I do not know if this is safe or legal, so do it at your own risk! It is definitely safer than just wrapping it in electrical tape like one Youtube video I saw.
There are two versions, thin and normal, but I only use the normal one. The normal one is designed to be rigid and thick enough to protect the board while installed. There is a thickness variable in the scad you could tweak if you want to.
The thin variation will only work with flexible material, as it actually wraps around the PCB and holds tight. Trying to get this top on is probably a lot like trying to get a real Speedo on! I printed it in TPU, and it works, but ultimately I decided that I wanted the protection of the Sonoff over the couple of millimeters saved by the super tight design. The thin version is only like two layers thick, so you need to have good printer TPU settings for it to work.
Hah, I didn't realize how many in-wall solutions were already posted! This approach keeps the light switch looking the exact same as before installation, but does heavily modify the Sonoff itself.
No one in the house even noticed the first install I did!
Printer Brand:
Monoprice
Printer:
Select Mini
Rafts:
No
Supports:
Yes
Resolution:
0.175mm
Infill:
Doesn't matter
Filament: 3d Solutech/Pxmalion PLA/ABS White
Notes:
This case is designed to fit exactly over the components, so print quality is important. However, my printer is poorly calibrated, so I designed in a fudge factor that you can change in the scad if you are having fit problems. I have tested it on 9 Sonoff devices (8 from one vendor and 1 from another) and they all fit. The biggest issue is the thick wires might be placed differently than my model, so you may need to push those around to get a fit.
I choose to print the top inverted. It takes a full support structure to get the overhangs to print right, and on my printer at least, the supported parts end up pretty rough and nasty looking. I print it upside down so that the inside of the case is nice a precise, and the outside is goopy from the supports. It also makes it easier to remove the supports.I print with 12% supports, using the "Cross" infill in Cura. That seems to come off most easily. For the normal version, you should make sure supports are touching build-plate only to avoid filling in the wire holes. If you're printing the thin top, than you need supports everywhere and you'll need to clean out the lip section.
The bottom should print just fine without supports.
Installation
The Sonoff Basic is an ESP board connected to a relay, designed to be installed in-line with the device you want to control. I am using them to make my lights "smart" lights, while still keeping their light-switch functionality. I use Home Assistant for central control, and ESPHome for the ESP firmware. I'll paste the ESPHome yaml file I use below.
In order to fit in a light switch box, I remove the built-in switch and LED, and then solder two thin-gauge wires to the top two pins of the built-in switch. These thin wires go through the board (through one of the cut-outs with a knot in the wire for stress relief) and comes out one of the small holes in the bottom of the case. They connect to the old light-switch in the wall. This allows local control of the Sonoff switch just like before the Sonoff was installed.
There are two options for the old light switch input:
I have been using the second option because I don't like inverted switch behavior.
Actual installation is a lot like installing a dimmer switch:
The installation pictures shown might help a little. The white one is printed in PLA, and the clear-ish one in ABS. The material shouldn't matter too much.
Here's the ESPHome yaml:
esphome: name: light_swtich_name platform: ESP8266 board: esp8285
wifi: ssid: 'myssid' password: 'mywifi'
mqtt: broker: 'broker.addr' username: 'mqttuser' password: 'mqttpass'
logger: level: DEBUG
ota: password: 'updatepass'
output:
id: relay pin: number: GPIO12 inverted: false
light:
id: light_output name: Light output: relay
binary_sensor:
name: Light Switch pin: number: GPIO0 inverted: true filters:
on_press: then:
on_release: then:
This was designed using my $10 plastic calipers and OpenSCAD. This is my most involved OpenSCAD design yet and could probably be improved, but it seems pretty well organized and manageable. The trickiest part was figuring out how to turn my model into a shell of the model, but the grow function seems to work well enough.
License:
Creative Commons — Public Domain
8