Circuit 1

i am quite new to PCB and circuit designs. I am trying to build two PCB consisting of ESP8266-12E and Shift Register (SN74HC595N) as a core of it and a high voltage relay control circuit. I have designed a low power PCB design to control via manual switchs which can be connected on terminal.

I am using SN74HC595N because there is a ready library for arduino to control, which makes things easier to code.

here is how my PCB looks like:

enter image description here

here the RED tracks are for jumpers i guess, that will help to keep things on single layer PCB.

Circuit 2

To control the high voltage (220V) appliances i kept things on the another PCB. This is a PCB design not executed anything yet. Need professionals feedback to understand in case if i need to improve something in this. Because i know i might have made mistakes while designing. So just to educate myself i am trying to build this PCB Design. I try to keep proper distance between the tracks and keep the expose copper area as well, so i it can allow higher current to flow.

enter image description here

Note: I am not going to build this relay control circuit. As it might be dangerous, just trying to understand where to improve it.

Also one more thing, is it a good idea to keep ground plane around 220v AC supply in relay circuit? Because i have seen in ready modules available in market they keep it, but i am not sure how much it will be helpful.

Here is complete schematic diagram for the same.

enter image description here

Any feedback from your end will be helpful to understand and gain more knowledge.


As per the suggestions here are the new updates, i try to maintain as much gap as possible on the relay (HV - Circuit 2) board circuit. To keep low voltage component as far as possible.

With circuit 1, i just changed the whole layout basically, to bring 2 layers to make things easy and also to bring more flexibility on the platform. Please feel free to keep the reviews posted.

enter image description here

TOP VIEW of Circuit 1

enter image description here


enter image description here

Thank you so much for your kind support guys!

  • 2
    \$\begingroup\$ "keep things on single layer PCB" - 2 layer boards are easier to lay out, better electrically, more robust and more reliable. Small boards like these are cheap to have manufactured in small quantities. Any reason you must use a single layer board? \$\endgroup\$ Dec 27, 2020 at 8:35
  • 2
    \$\begingroup\$ The ground on the first board is all cut up, with not a decoupling cap in sight on the IC's. Use a dual layer PCB with proper groundplane and correct decoupling. I'd not put a groundplane around the 220V AC lines on the relay board. Keep the required clearances. \$\endgroup\$ Dec 27, 2020 at 8:45
  • 2
    \$\begingroup\$ I strongly recommend using a 2 layer board because you can make the power traces thicker and more direct while keeping them way from signal traces, and plated through holes hold components more firmly (particularly things like screw terminals). It will also make assembly a little easier because you won't need to install any jumpers. \$\endgroup\$ Dec 27, 2020 at 8:57
  • 2
    \$\begingroup\$ @user3201500 Correct placing is also very important. Look at C6. It's positive side is connected to 3.3V close to the ESP pin, good. But how does the negative side make it back to the ESP ground pin? With such a long detour, the cap might just aswell not even be there. \$\endgroup\$ Dec 27, 2020 at 9:09
  • 1
    \$\begingroup\$ @user3201500 A dual layer PCB. One side completely ground plane. Place the decoupling caps right next to the positive power pin of each IC. Stitch the negative side of the capacitor trough to the ground plane with via's. \$\endgroup\$ Dec 27, 2020 at 9:30

2 Answers 2

  • It's hard to find useful layout documentation to your ESP8266-12E; but I bet the antenna mustn't be placed above signals, and it's likely it shouldn't be placed above any copper at all. Espressif themselves have reference designs where the antenna should be sticking out from the rest of the board: espressif hardware design guidelines
  • It's a good idea to route signals on the top layer, sure, but not because your board is single-layer: every board house I've met will give you the same price for single- and two-sided boards. You want the bottom side to be (almost completely) reserved for a ground plane. You want your decoupling capacitors to be able to take a short current return path – otherwise, they're useless, or worse, they even distribute noise into other systems.
  • I don't know your relay type, but I think something is very wrong in your component footprint: in all sensible relay designs, the three "high voltage" contacts are on one side, and the lower-voltage coil is on the opposite. So, verify with your relay datasheet how your footprint looks like. That pretty much changes the largest part of your relay board layout, so re-do that (from scratch).
    • (did I mention datasheets? Save documentation to all your parts with your project; if a part has no datasheet, go to a reputable distributor like farnell or digikey and buy a part with a datasheet instead.)
  • I don't know your 220 V AC -> 5 V DC supply, but usually, if there is a rectangular box, you can't put a resistor in there – don't R10, R11 collide with the supply?
  • as your layout software indicates, you've basically split your top-layer ground plane in half on your relay board with the long horizontally running 5V rail. That won't do well, but doesn't matter because I guess you'll be re-doing that layout with the correct relay pinout, anyway.
  • generally: layout the relay board such that all high voltage is on one side, and that there is absolutely no board copper crossing from the high-voltage side to the low-voltage side. Again, your relay footprints are almost certainly wrong, and that's what makes this harder. Google "PCB Clearance 220V". You never want your high-voltage circuitry to be close to your low-voltage one, and your design doesn't allow for that separation. That also means "no ground plane under your relay's dangerous side".
  • You're missing decoupling caps at the shift register (it's not what we'd normally call an "IO expander", it's a just a shift register). Adding one close to each relay would also make the whole system more robust.
  • Your relay board (the other one, too, but here it's a real show-stopper) needs mounting opportunities: some holes to put a screw in, or free edges to slide it into some guide or something. Mounting is necessary, because the bottom of your board will have 220 V contacts sticking out – can't have that flying around, or you will at some point either touch it or have some dirt cause a short and then a fire.
  • Print out your design in "real" size before ordering it. This is probably smaller than you think it is (always happens to me, still, after years), and since boards are cheap, making things larger is always a good idea
  • 1
    \$\begingroup\$ I will also add that the shift register will power up in a random state, and while the ESP is not properly up and running or at least having pull-up or pull-down resistors enabled, the shift register can drive the relays quite randomly. There is nothing to prevent that, as OE is always active, and the CLR input is always inactive, and there is no external pull-up or pull-down resistors on the shift register control pins. \$\endgroup\$
    – Justme
    Dec 27, 2020 at 9:21
  • \$\begingroup\$ @Justme Can you please suggest where i should be adding a pull up or pull down resister in here? Because i had this problem last time also your guidance helped me. Because of your suggestions only i planned to create two different circuit for the same. Your last time suggestions was really helpful. \$\endgroup\$ Dec 27, 2020 at 9:37
  • \$\begingroup\$ @MarcusMuller I am using HLK-5M05 as 220V to 5V supply. And that in on upper layer and resistors are in the lower level and HLK-5M05 is in plastic pack which never caused any interference in my circuit usually. \$\endgroup\$ Dec 27, 2020 at 9:39
  • \$\begingroup\$ @MarcusMuller 1) your first suggestion is very important and seems more sensible. I will definitely do that. 2) I will make a special track for it or do you suggest that i should be using a higher value then 100nF? 3) I will need to recheck my relay datasheet again for the same 5) Just asking, what is the problem with long track of 5V in relay circuit board? Should i be keeping it short? 7) Yes, shift resistors are not IO expanders, but to keep the circuit cost low, i use shift resistor. Initially i planned the same with PCF8574 but they are comparatively expensive. \$\endgroup\$ Dec 27, 2020 at 9:53

HV board

enter image description here

#1 the copper pour should NOT get close to the high voltage traces. You need a good distance between high voltage and low voltage, so get rid of that pour. You can keep it on the low voltage part of the board, but it should not get close to the high voltage pads.

The bottom left part looks good, nice distance between high voltage and ground plane.

#2 Low voltage trace is too close to high voltage pad

#3 You could use 3 terminal blocks to be able to use both the normally open and normally closed positions in the relay, you might need it, who knows? Traces and pads are free. If you don't want to use the normally closed position, you can always put a 2-terminal block.

There are no mounting holes. How will you mount the board? It's okay to make a bit larger board that is more convenient to use. When making mounting holes for M3 screws the simplest is to just use pads with 3.5mm holes. Don't forget the screws have heads, so make the pad 0.5mm wider than the screw head. It will act as a visual reminder of the screw head, to make sure you don't put it in a place where it will collide with another component.

Don't trust copper pours:

enter image description here

Here the layout software thinks "yay ground is all connected" but all the current is going through the tiny bit of trace between the pins of the connector! Since the Chinese pcb shops like jlcpcb charge the same price for single and double layer PCBs, you can put the ground plane on toplayer, but mind the distance with high voltage pads.

ESP board

Add mounting holes.

Put ground plane on toplayer. Copper pour on bottom layer is unnecessary.

Put ESP antenna somewhere NOT above ground plane, for example sticking out outside the board, or remove ground plane below it. Otherwise, ground plane will act as a shield and you'll get no wifi.

Add more capacitance at the output of voltage regulator. AMS1117 datasheet says "tantalum blah blah" but what this really means is this regulator needs a capacitor with some ESR, not just a ceramic. So you can put a 100µF or more electrolytic on the output. More µF will give better transient response. To keep it small, pick the cap with 2.5mm pin spacing that has the most µF in 6.3V rating. That will also be cheaper than the tantalum cap.

  • \$\begingroup\$ Your HV board changes i understand and i completely implemented it :) thank you so much for those amazing suggestions. But to control the relay i have to keep relay related circuits on same PCB itself. Mounting holes will not be needed as i am planning to have a heat shrink sleeve on the top. So it will become a over all protection on circuit board. Feel free to share your suggestions as this is really helping me to learn a lot of things. \$\endgroup\$ Dec 27, 2020 at 11:14
  • \$\begingroup\$ Yes you can keep transistors etc on the relay board, just move the transistors and traces a little bit to have good distance between high voltage and low voltage. \$\endgroup\$
    – bobflux
    Dec 27, 2020 at 12:13
  • \$\begingroup\$ yes i move them away so both the things are now more seperated. Thank you so much guys for your amazing suggestions this really helped me a lot to understand so many features. \$\endgroup\$ Dec 27, 2020 at 14:36
  • \$\begingroup\$ When you're satisfied with it, you can post the new version of your layout by editing the question. \$\endgroup\$
    – bobflux
    Dec 27, 2020 at 15:57
  • \$\begingroup\$ sure i am going to put the updates in few minutes \$\endgroup\$ Dec 27, 2020 at 18:03

Your Answer

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

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