After a busy month I decided to spend some energy on doing hardware instead of software and the result was the ESPurna board I posted about just yesterday. The goal was to have a device based on the ESP8266 I could fit into my house wall gangs, with an SPDT relay to work with multi-way switches and power monitoring using the same IC the Sonoff POW uses: the HLW8012.
As a side project today I’ve been searching on the box of the TODO projects and I have rescued a KEMO STG15 [Ebay] plug housing with socket. These sockets are somewhat expensive and really bulky but the good thing is that there is quite some room to fit some electronics inside, but not a Sonoff board, too big.
If you have read me, you might know I have a firmware for ESP8266-based smart switches called ESPurna. The firmware integrates with Alexa, Domoticz, Home Assistant and about any other service that supports MQTT or HTTP REST APIs. It supports a variety of devices, including almost the whole Sonoff family by Itead Studio, but also some other commercially available boards and light bulbs, and open source hardware projects as well.
But sometimes you just don’t find the proper hardware for your specific case. Maybe it doesn’t expose enough GPIOs, maybe it’s short of analog ports, maybe you need a double-throw relay,… Sometimes we manage to work around these limitations of the hardware adding peripherals or using a thin iron tip. But other times the problem is that it just doesn’t fit.
And size was the main reason I started creating my own smart switch board.
Following the bright path (sic) of the Ai-Thinker AiLight / Noduino OpenLight I wrote about a few weeks ago, now it’s turn for one of those devices you purchase but once they arrive they are stored in the TODO box until they eventually come back to life.
A while ago I wrote about how to use PlatformIO with PunchThrough Lightblue Bean in a post here on how to use the new Bean Loader CLI from PlatformIO. Of course the reason for that was not merely being able to do it, but having a agile development environment to do something useful with them.
I’ve been looking for a paper I had read a few weeks before I started playing with the Beans. But I have not been able to find it. The paper talked about using sensors and controllers to create simple but fun games for the kids. One of the projects described in the paper was a “play catch” game where the kids had to chase each other trying not to trigger and alarm they had on a bracelet with an accelerometer. If they ran too fast or move too sharply an LED would flash and they had to stop until it went off.
One might think that one of the typical uses for a smart wireless switch (like Sonoff devices) is to be embedded behind a normal wall switch so it becomes a “smart” wall switch. It may seem obvious but it’s not that straight forward. There are several things that get in the middle.
Most (all?) the boards have momentary push buttons while wall switches are (normally) toggle switches
Most of the available boards in the market are SPST, even those with SPDT relays often only provide terminals for COM and NO, not NC. I only have one one-throw switch at home, all the others are one-way-two-throw and are being used as part of a multi-way switch.
First problem can be easily solved in code. Instead of detecting one edge of the button signal (usually the rising edge since most push buttons are configured with pull-ups) you can detect both edges.