During my adventure of creating my own smart-home system, which does not rely on any company services, I looked out for all those different wifi-based power switch adapters. I found a rather cheap wifi-based switch-box called sonoff.
https://www.itead.cc/smart-home/sonoff- ... witch.html
Interestingly (and I thing we have to honour this) the manufacture makes no secret out of the fact that they utilise an esp8266 for the wifi functionality and the program logic. Furthermore, the box can be easily open and closed (no glue or easy breakable plastic clips) and the PCB enables user to access the esp8266 directly. I guess such an openness make it valid to post a link here (above), without falling into any advertisement category.
However, using the device, with the manufacture firmware, a connection via the users wifi network to a server will be established. An app on the mobile phone can then connect (via the server) to that switch box and the user and remotely set the switch state.
The benefit of this switch box compared to other solutions:
- * Included power supply directly from mains
* Proper (at least from a first view) isolation between main and dc voltage parts
* Relatively small in size
* Proper enclosure
It worked out very well . The board has an unpopulated 5-pin header: 3.3V, RX, TX, GND and GPIO. Connecting a TTL-serial adapter to it, I was able to flash the recent git version of micropython onto it, in the same way as it is done with any other ESP8266 unit. I received a prompt and was able to program the unit.
Hence, right now I am adding the MQTT protocol, which will enable me to operate those switches via my own MQTT broker on my network. I got a first proof of a working MQTT driven power switch via micropython and woahh it was so relaxing to do that in micropython interactively, with a minimum of code.
The switch box comes with at least 4 direct accessible functions (there might be even more unused GPIOs but those are more difficult to access).
- * GPIO14 - free GPIO Pin of the above 5-pin row header (I might want to use this to connect an external switch)
* GPIO12 - Relay (for 110/230V mains)
* GPIO13 - Status LED (inverse)
* GPIO0 - onboard button (inverse) also used for flashing