Close

Figuring out the best way to do it

A project log for Sonoff Mini dual switch support

Add support to a second toggle switch to the Sonoff Mini

turo-heikkinenTuro Heikkinen 12/06/2020 at 22:030 Comments

So, there is one input and I need two - easy task as there are only four GPIOs used (button, relay+led, another LED, S2) and all the open firmwares support using any GPIO for anything. The stock Sonoff firmware I didn't look at, I prefer to control my devices myself instead of some Chinese cloud service.

I see a ESP8285 on the PCB so I already know it can be done. First drilled one more hole for replacing the stock gray (black in V1) two wire screw terminal by a three wire one, using a piece of proto board as a template .

Then need to figure out the most convenient GPIO to connect the new input to, GPIO0 and 2 would have nice pads, but the device won't boot, if any of those in a wrong state thus need to use something else.

Didn't find a convenient pin layout diagram for the 8285 so added GPIOs to the datasheet's diagram:

Stock GPIOs:

GPIOs 5 and 14 are available, fully free to use and both are the last pin of their row so relatively accessible, but need soldering to the tiny 0.5 mm pads, which might need some practice and microscope (both of which I do have but prefer to productise stuff to be applicable to broader public).

GPIO 3 = Rx has a pad and doesn't look to be used for anything (except flashing of course), might be a more convenient choice.

In the older V1 version (with external antenna included, V2 has a tiny internal antenna and pads for an external one) GPIO 16 is routed to a 2 pin header, thus might be viable in V1 (just use a resistor between the pin and ground) but not in V2.

At least in the V2, the S2 input is connected to the pin (GPIO 4) via a 1kOhm resistor, and the pin is pulled up by a 10 kOhm resistor:

In addition to the resistors there is a ceramic capacitor C23 (measured 32 uF in my devices) and a transient-voltage-suppression diode array D4 protecting against possible high voltage pulses induced to the switch line.

I'd suggest adding at least similar-ish resistors and some capacitor (value is not critical, something like 1 uF should do fine) to the new line. The protection diode array would be good to have but if you're not going to accidentally connect mains voltage to the switch line and your location doesn't have much lightning spikes, it'll probably be fine without (your consideration of course, I'm not recommending this).

Discussions