Electronic – get some opinions on this design please

esp8266mainsrelay

Before I start, I totally know that I could buy one of these, I don't want to.

I'm building a simple circuit that will allow me to use an ESP8266 (I have the -01 variant) to control my big shop lights above my workbench. Obviously the lights will be controlled by a relay, which is driven by a transistor which is switched by the ESP. I already built the prototype circuit and it works well, so I designed a circuit board that I think will work and I'd just like some more experienced opinions on things like design and whether or not it'll catch fire. Here is the schematic and PCB layout:



The idea is that I'll have a 12v power supply (for the relay) and this circuit board mounted in an enclosure with one cable coming in for AC and two going out to the lights (300W Halogen shop lights). The 12v supply will get its power from the mains, and will be regulated down to 3.3v for the ESP by the regulator on the board. In my breadboard tests the circuit works well, I even tested it by switching on and off a 500W shop light and a 144W string of outdoor patio lights at the same time. The relay I have is rated for 120VAC at 20A, the lights I'll be switching total 600W, resistive load, so should only draw around 5A.

The reason for the blank section at the bottom-left is the relay I'm using has 4 pins on the bottom, but two spade connectors on top. I'll be using the spade connectors. I wanted to make sure the relay was still securely fastened to the board, but those pins are well clear of the rest of the circuit as they'll be live at mains voltage. I'm going to cut a slot in the circuit board itself between those pins, and between the right-most pin and the ground plane.

Anyway, any suggestions or reprimands, things I should change or anything at all to say about it, I'd be happy to hear it. Please bear in mind, I dabble with this stuff on occasion, I'd call myself an enthusiast, so I'm still trying to learn.

Edit

I rearranged the circuit board, moving the ESP itself off the board (except for its headers) and hopefully making things better for attaching a heatsink. Here they are:

Best Answer

Traces or leads must keep a minimum distance of 8mm away from mains. It's better to enlarge the boards and rotate the relay 90 degrees away from the 12V supplies. Also not recommend to flood ground around and under the relay.