WiFi switchbox

In my next openHAB journey, I come across another needed thing, because what is software for homeautomation, if there is no hardware to control?

Earlier I have briefly written about how to use an ESP8266 with a reed switch, but in this, I am going to take it a step or two up.

2015-11-01 14.21.04 (Large) 2015-11-01 14.21.45 (Large)

I got some of these dual outlet boxes. They are pretty cheap, and inside the two outputs are not connected together, so it is easy to make them individually controlled.

To control the outputs, it is easy to use either a relay, or triac. In this case, I decided to use relays, because I also want it to completely break the circuit when the output is disabled. With a triac, some led bulbs would continue to flicker when the output is off, because a little is leaking through the triac.

Much space, yet to little space

Next up, is to find a place for everything inside the box. While the box is pretty big, there isn’t actually that much room inside it.

2015-10-31 12.29.47 (Large)

Here is the layout I ended up with. In the top are the two relays, one for each outlet. Just below are the two outlets where the plugs will come through the top of the box, and make contact. In the bottom middle of the box, is a 5v power supply, it will make the voltage to drive the two relays, and also the ESP8266 which will once again be the brain in this project. To the left of the power supply there is going to be a pinheader, so it is easy to attach a TTL adapter, and reprogram the ESP8266. To the right of the power supply, I found room for the ESP8266.


This is the first try of the PCB design. Some components are still missing, but I wanted to try how it looked with components on, and if I got my measurements right. So far so good…

2015-11-01 12.15.27 (Large)

But at a closer look, I found some components a bit too close to my preference. There would still be enough room for them to be there, but when there is enough room to give them a bit more distance, why not do it? 🙂

2015-11-01 12.15.35 (Large) 2015-11-01 12.15.43 (Large)

After a few adjustments, to both the placement of components, traces, and the dimension of the PCB, it ended up actually fitting in the box.

2015-11-02 20.08.49 (Large)

It did cost a few tries, and a few pieces of paper before the shape was correct, but I would rather spend that extra time on printing and cutting the paper, than ordering some PCB’s in the wrong shape.

And here it is, in all it’s glory.

Under the right outlet connector, a 3v3 regulator is located, along with a set of capacitors. To the right of the regulator, are two 10k pull-up resistors, which are used to make sure the relays will be released while the ESP8266 is starting up, and to prevent the outlets to be switched on if the pins on the ESP8266 is not set and just floating.

To the left of the ESP8266, there are a few resistors to make sure it starts up in operation mode, unless the jumper under the TTL adapter is in place. If the FLASH jumper is put in, the ESP8266 will start up in flash mode, and it is then possible to flash it with NodeMCU or something similar. After flashing NodeMCU to it, it is no longer needed to have the FLASH jumper in place, instead it is only needed to attach the TTL adapter, and by serial send the code to it.

On the bottom, most of the mains power is routed. Only the outlet to the left had to have one routed on the top layer, but without a ground pour, it is still isolated pretty well.


Leave a Comment