DIY automation of an old house might sound like a tiresome and difficult project – and you might think the easy solution is to buy a off-the-shelf product like the Philips Hue. But you might discover that the easy comes with the price of flexibility.
In a truly smart home all devices are wireless connected to each other using standard protocols. Many homeowners have previously installed various wired protocols such the Danish LK IHC – but nobody today would ever consider installing a wired solution. A house is not considered smart if you reconfigure the lighting without replacing the wires in the walls.
The cheap ESP8266 chip has been a true revolution for makers and the Arduino community – the Chinese manufacture AI-Thinker has really pushed the envelope. Many different products have arisen upon the popular ESP8266 chip – since it is accessible for the manufacturers for a fractional of the traditional ARM IOT chips.
Some time ago I discovered the ITEAD Sonoff WiFi Automation products based on the ESP8266 – the Sonoff line are very cheap and in a high quality. At this price point it would be difficult or impossible to design something similar at such low cost.
ITEAD provides the full documentation including schematics for the products. In this article I will show you how to hack the WiFi socket called Sonoff S20.
You get the S20 WiFi socket for under 10$. The products do not have a genuine CE mark. However, the internal PDB layout is very good and a CE should not be a problem in my opinion if it were requested.
Unboxing the Sonoff S20
When I ordered my first Sonoff directly from China, I didn’t expect much more than the standard bobble wrapping. ITEAD actually ships the S20 in a nice box.
The initial impression is pretty good – the Sonoff unit seems to be produced in high quality materials. In many ways the S20 could feel like a 100$ product – and you don’t get the usual disappointment as with other Chinese products.
Since I live in Scandinavia my Sonoff is with the EU plug – but you can get different versions for US, UK and China also.
On the backside of the S20 you don’t find any references to FCC, IDA or other security certifications – so to some degree you are left to trust ITEAD and their Quality Assurance. That being said everything about this product seems rock-solid – and you should probably not worry too much.
Flashing the S20
I can’t say anything about the ITEAD original firmware. I have always immediately flashed Tasmota firmware on all my Sonoffs units. One giant reason to skip the eWeLink app is that this app is dependent on being connected to a Chinese cloud vendor – which is a no-go for most of us. The ITEAD firmware is not open source – and you basically don’t know what it is doing behind the scenes.
Getting started – soldering pin headers
In order to flash the Tasmota firmware to board you will need a serial programmer – and some pin headers, dupont jumper wires. You need pin headers for RX, TX, VC and GROUND.
Opening the housing is easy.
Where to solder the pin?Luckily, ITEAD has already provided soldering holes on the boards for soldering the pin headers.
As always it is a good idea to prepare the PDB with a quality flux pen since it will ensure a better soldering joint.
Your soldering joints should look like small mountain tops – and in order to ensure a quality joint, it is really a question about applying the right amount of solder.
I have bought several S20’s from China – on some of them the soldering holes is filled with solder. I really don’t why they have done this – and it is a bit for difficult to solder these. You will first have to unsolder these with a vacuum tool.
Be careful – a word of caution
Sonoff offers a very easy access to home automation – but you will still need to take precautions in order not to injury yourself.
The 230v mains voltage are not fun and you should respect it. The necessary expertise is a prerequisite. Under no circumstances should the devices be operated openly on 230v.
If you are connected to 230v, you should not program the boards with the computer. NEVER.
Always use a separate 5v power supply.
The programming of the boards is 100% equivalent to a normal ESP8266 board.
To get into the Programming mode, you have to do a little trick. GPIO-0 and reset of the programming board are not connected. But it’s easy. GPIO0 is accessible via the button on the Sonoff board.
And instead of reset you can simply do the following:
- Connect the USB plug of the programming board.
- Press and hold the button on the Sonoff board.
- Insert the USB plug.
- Release the button on the Sonoff board.
- After that you can program the board normally, e.g. with the Arduino IDE.
- Upload the Tasmota firmware – download here
The Gpio assignment of the Sonoff:
GPIO12 relay (high = ON) + LED (blue); LED only at S20
GPIO13 led Green (low = ON)
GPIO14 pin 5 of the pin bar-Sonoff switch only
PN25F08 Flash (1MByte)
Blue LED S20