I have made some more progress on the PCB for the switches, and hopefully they will fit in. The next step will be to print it out on paper, then try to put it into the case.
But first, lets see what we got.
This is the side that will face up in the case, and not much will actually be visible here, like the original PCB. To the right in the top, we got the power supply. It will bring the 230V AC down to 3.3V DC, so we can use that directly to power the ESP8266, and also drive the relay.
A bit further down and to the left, the relay is located, with a LED in between the power supply. To the right of the relay, the in- and outputs are located. This is where mains will come in, where one will be switched by the relay, and the other to drive the electronics.
Wiring will be LI = Live In / LO = Live Out / NI = Neutral In.
In the far left of the PCB a programming header is located, along with the FLASH jumper to enable flashing for the ESP8266.
On the bottom we got a few more components.
Top left corner of the PCB, we got 3.3v coming from the power supply on the opposite side, and some of that goes to the pull-up resistors, and come continue down to the ESP8266 and relay coils.
Just next to the 2×4 array of resistors, there are two transistors to help drive the relay coils. Next to those, there are two filter capacitors which should bring the noise a bit down.
In the right top corner, we got the ESP8266, and below that two diodes to take the EMF spike from the coils. By now you might wonder why there are two diodes, but only one relay, and the answer is simple. The relay I decided to use is a bi-polar latching relay, which means one coil can be energized, and the relay will switch, power can then be removed from that coil again, but the relay will stay in the position it was put in. When energizing the opposite coil, the relay will switch back again. The reason I decided to do it like this, is because in some cases, the relay might be switched on most of the time, and occasionally only switched off for a brief moment, before being switched back on again. So instead of having to hold the coil energized, it now has no difference if it is on or off.