Posted on September 21st, 2016
The Sonoff from Itead Studio is a fantastic little mains-switching module with a built-in ESP8266 and WiFi. If you want an easy way to control mains devices such as lamps and fans, this could be it!
Sonoff modules are preloaded with firmware that allows them to be controlled by a phone app, so they’re very easy to get started. But that’s just the beginning: using a USB-serial converter and the Arduino IDE, you can load your own software on the Sonoff and make it do your bidding. I used the Arduino IDE to load a sketch with MQTT support and OTA (over the air) updates, allowing it to be controlled by OpenHAB.
Sonoff: www.itead.cc/sonoff-wifi-wireless-switch.html (basic version)
Sonoff TH: https://www.itead.cc/sonoff-th.html (Temperature / Humidity version)
Slampher: www.itead.cc/slampher-wifi-wireless-light-holder.html (lamp holder version)
Start by adding ESP8266 support to the Arduino IDE by following the instructions at github.com/esp8266/Arduino. I used the simple “Boards Manager” method.
For OTA (over the air) update support you’ll also need to install Python 2.7.
You’ll also need a USB-serial converter with support for 3.3V I/O. I used the Freetronics USB-Serial Converter (of course!), which has a switch that lets you select 3.3V or 5V mode.
The “BasicOTABlink” example shown in the video can be found at github.com/superhouse/BasicOTABlink.
The “BasicOTARelay” example shown in the video can be found at github.com/superhouse/BasicOTARelay.
For more information, a fantastic resource is Pete Scargill’s blog post about Slampher and Sonoff.
If you want to upgrade the FLASH memory on your Sonoff, check out Pete Scargill’s blog post about upgrading ESP8266 memory.
Update 24 Sep 2016: fixed the example links.