2
\$\begingroup\$

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:

\$\endgroup\$
4
  • \$\begingroup\$ 50 ohm relay coil transistor needs Ib>5%Ic to saturate! \$\endgroup\$ Jul 9, 2018 at 2:16
  • \$\begingroup\$ If you use an OKI 3 terminal regulator then no 1W heatsink needed \$\endgroup\$ Jul 9, 2018 at 2:58
  • \$\begingroup\$ The LDO temp rise is how much wth 150mA ?? Get the OKI DCDC 3 term reg. Or use 5V \$\endgroup\$ Jul 9, 2018 at 5:15
  • \$\begingroup\$ You would miss out on the learning experience but you could buy a Sonoff Basic (around 5-10 $/€), which is exactly this: An ESP8266, a power supply for the ESP and a relay. You can use the original firmware or reprogram it just like any other ESP8266. \$\endgroup\$
    – AndreKR
    Jul 9, 2018 at 5:59

3 Answers 3

2
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ I think I can make that fit in the enclosure, and I'll remove the ground plane from under the relay. Thank you! \$\endgroup\$ Jul 9, 2018 at 1:32
1
\$\begingroup\$

Just a few observations:

  • R1 and R2 seem to be interchanged in the PCB compared to the schematic
  • You have quite a large voltage difference between voltage regulator input and output. This and the current draw of the ESP8266 lead to a large amount of waste heat. It would be a good idea to put a heatsink on the regulator or screw it to a copper plane on the PCB for heat transfer. Watch out, on some regulators the heatsink is connected to Vout, then you can't have it touch the ground plane. Even then you should do calculations how hot your regulator will become. Ask for help if you don't know how.
  • Be careful with mains power. Switch the live wire. Learn how to do proper mains wiring and what connectors to use. Best ask an electrician to help you install it.
\$\endgroup\$
12
  • 1
    \$\begingroup\$ I consulted with my grandpa, a master electrician, to make sure the mains side was all good. Strangely enough, mains wiring and convention is fairly easy to me, my grandpa trained me from a young age. It's small electronics and circuits and whatnot that I struggle with. As far as the other considerations, thank you, I will look into them. I have some heatsinks that I can use. Do you have a suggestion for a better way of getting 3.3v to power the ESP? \$\endgroup\$ Jul 9, 2018 at 1:09
  • 1
    \$\begingroup\$ Good point on voltage difference. I'd rather recommend using 5V supply than adding heatsink inside closed box. \$\endgroup\$
    – Maple
    Jul 9, 2018 at 1:10
  • \$\begingroup\$ @Maple Unfortunately I don't have a sufficiently rated 5v relay, and I'm trying to use components I have on hand instead of buying more. \$\endgroup\$ Jul 9, 2018 at 1:15
  • \$\begingroup\$ You could try to find a relais with a 5V coil that fulfills your requirements and use 5V power supply to power the relais and the regulator like Maple suggested. In that case you should use a low-dropout (LDO) regulator. \$\endgroup\$ Jul 9, 2018 at 1:15
  • 1
    \$\begingroup\$ Fair enough. I did do a redesign of the board, arranging things in a way more conducive to adding a heat sink. I've got a ton of aluminum extrusions lying around, ready-made heat sinks! Anywho, check the edit in the OP for the updated layout, if you're interested. \$\endgroup\$ Jul 9, 2018 at 2:32
1
\$\begingroup\$

I'd like to add to @Marco answer:

  • placing Q1 between resistors and diode will give you much better routing
  • It is better to place ESP with antenna as close to board corner as possible
  • Do not pour copper or place traces under ESP. If you rotate it with antenna facing outward it will be easy to do.
  • 4 mounting holes at the corners will save you a lot of headaches later. Actually, the best way to do this is measure your board after initial design, find suitable enclosure and then adjust your PCB design for mounting locations usually found in the enclosures.
  • Even if you don't use bottom relay pins I'd recommend adding at least traces for some heavy-duty connector to the left of relay. It won't increase your PCB size much and will give you space to add 2 of the mounting holes mentioned above.
  • Also if you add alternative holes for power spaced 0.1" you can have convenient pin header there to use during testing.
\$\endgroup\$
7
  • \$\begingroup\$ Thank you! I love the idea of moving Q1, that hadn't even occurred to me! I will definitely look into reorienting the ESP, but I'm not sure the enclosure I'm using (salvaged, but plenty skookum) will support it, unless I cut a slot for the ESP antenna to stick out...Anyway, thank you for the suggestions, I'll look into them! \$\endgroup\$ Jul 9, 2018 at 1:19
  • \$\begingroup\$ How can ESP antenna stick out? It is just a trace on the ESP-01 board. Simply rotate ESP 180 degrees with 8-pin connector next to resistors. \$\endgroup\$
    – Maple
    Jul 9, 2018 at 1:23
  • \$\begingroup\$ The antenna is the part of the circuit board with the traces in the zig zag pattern. There's nothing else on the board there, so that part of the board could stick out of the enclosure. Thus, the antenna is sticking out. I know I'll have to rotate it and reroute. \$\endgroup\$ Jul 9, 2018 at 1:31
  • \$\begingroup\$ I still don't understand how it can stick out if ESP board is right above your main PCB. For ESP antenna to stick out your main PCB must stick out. Unless under "stick out" you mean there will be a hole in the enclosure above ESP. \$\endgroup\$
    – Maple
    Jul 9, 2018 at 1:45
  • 1
    \$\begingroup\$ I said I'm going to rotate and reroute the ESP, I'll move the pins closer to the edge of the board so that the ESP itself sticks out from the main PCB. \$\endgroup\$ Jul 9, 2018 at 1:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.