Disclaimer

Please, proceed carefully following the tips published in this blog, specially when Main Power is involved. I'm not responsible for any damages caused by what is written in this blog.
Thank you

Saturday, 22 July 2017

Home Automation System - Discovering sonoff




In the last few months, thanks to Piero's suggest, I discovered some small device called SONOFF, by iTead https://www.itead.cc/smart-home.html

In simple words, they are low-cost wifi controlled relays. A basic switch is less than 5 euro!

The following products, among others, are the most interesting, for my purpose:

Sonoff Basic: a standard switch - https://www.itead.cc/smart-home/sonoff-wifi-wireless-switch.html



Sonoff Pow: a standard switch with power consumption measurement - https://www.itead.cc/smart-home/sonoff-pow.html


I bought them on eBay, for testing purpose.

These devices are easily configurable and ready to use; just connect them to the power. The onboard firmware let them be controlled by a mobile APP (iOS and Android), called EWeLink. A step by step procedure helps user to pair the device to the home wifi network (mandatory...). The devices will be controlled directly through internet, using an Amazon AWS server managed by iTead.

This is a simple guide: https://www.itead.cc/wiki/EWeLink_Introduction

This is a simple and rapid mode to operate with these devices; but if your home network is offline, they stop working.

Furthermore, to get all the capabilities of these devices, you need a custom firmware, because the original one is not so open. For example, you cannot integrate sonoff devices in a Home Automation System like OpenHAB or Domoticz

So, my first step was googling for "Sonoff Firmware"...Bingo!

To be simple, Sonoff is a device built on ESP 8266 chip, so it's easily programmable (as Arduino board) and you can find many free custom firmware: you choose it according to your needs or experience...

I chose this one:

Sonoff-Tasmota firmware: https://github.com/arendst/Sonoff-Tasmota

At the first glance, it seems the most complete, for my purposes..It allows to control the device by MQTT, Web and Serial Communication.

Please, take a look at the official Wiki page:

https://github.com/arendst/Sonoff-Tasmota/wiki

About MQTT, I can suggest you to take a look at the official website: http://mqtt.org. It is a very useful protocol to manage IoT messages.

In a nutshell, MQTT is a connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is based on a central service, called broker, which receives published messages and forward them to the subscriptors. Every message is published on a particular "topic" and only the subscriptors of that topic will received it.


So, we have to manage another service, the MQTT broker. But don't worry about that, it's very simple and also Raspberry PI is able to run this service (Mosquitto https://mosquitto.org is one of the best...). Just for testing purpose you can use a free public MQTT broker, but I discourage you to use it for your real Home Automation System

After choosing the firmware, just upload it on the chip.

WARNING...you will lose the original firmware and you will not be able to upload it back; will no longer be possibile to use the EWeLink app again

The custom firmware will be upload using the serial interface on the sonoff, through a 3.3V USB-Serial adapter. I bought one on banggood. You could upload the firmware using the Arduino IDE or PlatformIO. Please follow the step by step guide provide by the firmware developers.

Before, we spoke about Home Automation System. I suggest you 3 system I tried:









Home Assistant - https://home-assistant.io


There are many others...the final choice it's up to you. Internet has lots of information and guide to assist you...

I chose OpenHab v.2; in my opinion it's the most versatile one (but I could be wrong :) ).

Shortly I will publish the results of the first tests performed with SONOFF

So, please, Stay Tuned


No comments:

Post a Comment