ESPurna smart socket

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.

But, what about an ESPurna board?


ESPurna inside

The ESPurna-H board is released under the Creative Commons Attribution-ShareAlike 3.0 Unported License (CC-BY-SA 3.0) and follows the terms of the OSHW (Open-source hardware) Statement of Principles 1.0. It can be checked out at my ESPurna board repository on Github.

The socket has some placeholders to screw a board inside, but the form factor does not match that of the ESPurna board. They draw a rectangle of 52x34mm while the ESPurna board has holes disposed in a square of 44x44mm. Then I thought about hot-gluing the board somehow. Problem is that the HLK-PM01 gets hot when operating and didn’t feel hot gluing was a good idea.

Then I started thinking about the ventilation dents on the sides of the socket. From the inside they look like rack slots with 6mm step between them. Maybe I could rack the board there? The ESPurna board is 50mm width. I needed around 60mm to rack it in both sides of the socket so I cut an adaptor from a piece of methacrylate of 60x50mm with holes for the ESPurna board.

The 2mm width plastic sheet fits tight in the vents. There is still room to let the air flow and even to add a case mounted push button and a notification LED. Finally I did add some hot glue on these two to prevent the cables to come loose inside the box.



The ESPurna board, fully populated with the methacrylate adator behind.


Connections to the push button and LED. I hot-glued them to prevent the cables to come loose inside the case.


The adaptor fits nicely inside the KEMO STG15 between the side vents. You can also see the hot glued contacts for the push button and the LED.


All connections made. Ground to ground (yellow-green), neutrals connected to both N terminals in the ESPurna board (blue) and the power line to the NO terminal of the relay (brown).

Final result

The final result looks quite nice. Not as slim as the Itead Studio S20 but this one has power monitoring capabilities and flashed with the ESPurna firmware it supports MQTT and Alexa amongst other goodies.


Now it’s time to play with it. I’ve been monitoring my house power consumption for a few years already, now I have the tool to do it for each appliance and manage them remotely from my cellphone or from Node-RED based on different inputs.

CC BY-SA 4.0 ESPurna smart socket by Tinkerman is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

8 thoughts on “ESPurna smart socket

    1. Xose Pérez Post author

      It doesn’t look like having an ESP8266 inside, so I’m afraid it’s not compatible…

  1. Ayre Neek

    Great post. I was also working on a small form factor design that is capable of being fitted into a single gang wall outlet. Would you recommend the use of this design for such a situation?

    1. Xose Pérez Post author

      A would probably change a few things for the next iteration. I’d like to find a way to place the ESP12 antenna further from the mains transformer. Maybe also trying the ACS712 as current sensor (better isolation, but only current monitoring so no active power calculation) and smaller SSR, enough to switch lights.

      1. Ayre Neek

        Thanks for your reply. Could you comment on the use of a transformer-less power supply to reduce the footprint of the board.

        1. Xose Pérez Post author

          It would be smaller but not that much. After all you need a big X capacitor for the step down and another big one for the filtering. This time my bet has been to not reinvent the wheel and use a trusted transformer.

  2. Owen

    Hi Xose,
    Nice design.
    I’ve been looking for something to do this type of thing for many years (X10 and the like), and it seems that now things are starting to get there without a stupidly large price tag. I tried some dedicated RF switches, but they were unreliable, and sat on the face side of the outlet (not behind the wall).
    I have an application (want/wish) to mount these to the *rear* of Australian power outlets to provide a means of control over appliances, some of which might be plugged in behind cabinets and have no easy switch access, and others where I might not want the appliance used (eg: TV in kids room is turned off – no matter what – at 8pm). Power monitoring is an added bonus!
    I would be interested in discussing further how this would fit to the inside-wall-side of Australian outlets. Fitting new outlets is not a problem, but I would like to make minimal outlet modifications and still maintain a high degree of safety… having a heat-shrunk lump in-line with the outlet (even inside the wall) is not only untidy, but would probably violate some regulations as well.
    I assume your software (espurna?) can control these direct over WiFi (eg: direct from a smart phone) and not require an internet connection (or phone connection) to operate?

    1. Xose Pérez Post author

      Yes, it’s getting more and more accessible for anyone to DIY her own’s smart switches. Some companies (mainly chinese) are pushing down really hard in the price but still most of the companies in the market offer end-to-end solutions, which might fit most users needs. If you really want to own a device you either need an open API or a custom firmware (ESPurna is one of them for ESP8266 devices, there are other options as well). Or you can create your own hardware. Price-wise you cannot beat the chinese ones.

      And yes, ESPurna lets you control your devices using WIFI, either through the embedded web interface, via MQTT (Node-RED, Domoticz, Home Assistant,…) or using custom server-side components (that can talk MQTT or REST).


Leave a Reply (all comments are moderated, be patient)