4 Questions about making an ESP32 relay switch with snubber circuit

Project description:
I want to make a PCB to switch 4 relays powering things like TV/Soundbar, PC, lights and so on.

Issues so far and solutions(?)
1. Relay not switching
Previously my issue was that the relay did not switch off anymore. Seems like that high capacitive or inductive loads cause a spark when turning the relay off, basically welding the contacts together.
Solution so far: The current spike is supposed to be reduces using a snubber circuit. After connecting the snubber circuit parallel to the wires going into the relay, the relay did work fine (turning on and off).
2. Leakage current
However, now another issue occured: My LED strip started lightly flashing every 3 seconds. After googling, it seems like there was a small current passing the snubber, charging the capacitor of the LED's power supply, causing it to light up sometimes.
Solution so far: I changed the wiring, so that I removed the connection between COM and the snubber and connected it to the blue return path cable of the AC cable going into the wall.

Question #1: Snubber connection
About the solution of the second issue, I am very uncertain if this is a long term solution. In all the guides I found online, the connection of the snubber is like I did it before. Is it okay to do it like I have it now? So the snubber is on one side connected to the NO of the relay and the other side to the return path (blue AC cable)?

Question #2: Snubber components and values
All the snubbers working with AC I have seen use through hole components although all other components are SMD. I dont understand this and I am wondering if I can use the following SMD components:
Resistor: Power Metal FIlm 3W 100Ohms 500V rated
Capacitor: 630V 100nF X7R ±10% 1812 Multilayer Ceramic Capacitors MLCC
Varistor: 300V AC, Varistor Voltage 423V~517V, Peak Current 1.2kA

Question #3: Using a MOSFET instead of transistor?
The coils of the relays should be powered by 5V USB C, that also poweres the ESP32 S3 Wroom. Current is about 70-100mA. This is in all the guides done with transistors. I have never used a transistor and always used mosfets, is there any disadvantage using a mosfet to turn on/off the relay?

Question #4: Using a Darlington Transistor Array?
Alternatively, I thought about using a Darlington Transistor Arrays, which would save a lot of space and soldering. Yet, I am not sure about the need of resistors for this. As seen in the schematic of the mosfets, I always use 220ohms to protect the MCU pin and 10kohms to prevent a floating pin. In the schematics I have seen from the Darlington Transistor Arrays, I have not seen any resistors so far. Do those need to be used?

As long as you don't exceed their maximum ratings, you can use and just fine.

Note that your trace spacing on the high voltage traces is absolutely insufficient by any stretch of the imagination. What you've got there is pretty hazardous.

No, a suitable MOSFET is fine.

No, unneeded here. Stick with a MOSFET or if it needs to be a BJT (I wouldn't know why it would) just use a plain old bc847, 2n2222 etc.

I've not looked very closely at your snubber circuit, in part because the schematic is drawn somewhat oddly in that area.

Maybe that relay isn't rated for the voltages and currents you are trying to switch.
If so, a snubber won't do any good.

What relay are you using, post a link to its technical information. Also what are each of the loads. It appears to me your problems are are with several different loads on several different relays.

Thanks for mentioning!
I increased the spacing to 1.5mm and put some traces to the bottom side, do you think it is better now?

Why do you think it is not needed? It would be a only one component to solder instead of 4x mosfets and 8x resistors

Is it better to read like this? Or how can I improve it that it is easier?

The rating is for 250V AC 10A, while the load is only 100W maybe. I read that it is a common problem when switching inductive or capacitive loads that a voltage spike occurs once the metal moves away from a closed stage to an open one

Here is a datasheet: https://www.handsontec.com/dataspecs/4Ch-relay.pdf
Its an ELEGOO 5V Relay Module with 4 relays, two of them being used.
The load on one relay is an energy socket strip which is connected to a 50 inch smart TV and a sound system, consuming about 100W of power.
The other one is connected to some LED strips and a lamp, consuming about 50W of power (this one had no issues with switching off).

Those relays are absolute junk. You are not the first person on this forum complaing about burnt relays and fused contacts.

I agree, thats what this whole Project ist about. In the schematic i am using a relay from Finder which should be much better.

But obviously not since you are melting contacts.

Better, but still marginal. 2.5mm space is the bare minimum. Keep in mind that the PCB is typically only 1.6mm thick - but tends to offer better insulation than moist air. You generally end up with a compromise one way or the other (e.g. component contacts); try to err to the side of safety as much as possible.

Because a single MOSFET also gets the job done. In an application like this, a Darlington used to be the alternative to a MOSFET before those were readily available.

O, you mean a Darlington array. Well, you can also get MOSFET or NPN arrays.

I'd be inclined to keep the snubber circuit and the relay together, and then put the connector next to it, showing the connections with net labels instead of traces.

But you're now redesigning for bare relays, or not? If you're still using/continue to use a relay module, no need to fuss with transistors etc. since the relay coil drivers will already be on the module.

The problems occured with the old relays. Many posts and guides however mention that those voltage spikes are normal when an inductive loads is being switched by relays.
In the PCB that I want to do myself I will use relays from Finder which are supposed to be better, but the voltage spikes, in my understanding, are unrelated to which relay is being used.
So the snubber circuit is important for my setup and I wanted to talk about the 4 questions before I finish the PCB and order it, so it hopefully functions fine

the issue I'm having here is that the physical pins of the relays and thus the though hole metal do not allow a spacing of 2.5mm. Would it help futher if I soldered 1.5mm wires to the backside of the PCB/relay pins to take a little load of the cooper traces of the PCB?

Okay, I have tried my best, can you read it better like this?

Yes, exactly, for bare relays. I bough four Finder Relay 40.51.9.005.0000 IP20 and those I want to use on the PCB I'm designing. It should have "all in one": An ESP32S3 Wroom to control the relays via wifi, the relays itsself, the snubber circuit to protect the relays, the 5V USB C input to switch on/off the relays via MOSFETs and power the ESP32 with an LDO, and the diode on the bottom the relay to protect the mosfet/esp32.

Currently I have the cheap elegoo module, the snubbers, the power supply of the MCU, the power supply of the relays and so on all externally... looking terrible. My goal is to have all on one PCB and with better components.

Yeah, that's why I said that bit about the compromise. No, I wouldn't break out the pins etc. Just space the traces as wide as possible apart, within the limits of the components. You can take inspiration from existing power supplies etc although be careful with Chinese designs which often skirt disaster in exchange for compactness and low cost.

Yeah, it helps as far as I'm concerned. It's now also clear that the snubber doesn't span just the relay contacts, but included the switched load in its loop. Is this intentional?

Are they rated for the voltages and currents you want to switch. If you want to switch 10A you should give yourself a little margin and maybe use a 15A relay. A snubber won't help if the relay can't handle the load.
Plus there is no such thing as a universal snubber that will work with any AC or DC load.

Yes, it is because my LEDs were flashing otherwise, i eplained ot in the first post:

Since then the led strip is not flashing anymore

I think the general solution to that is to select R and C for higher impedance.

Yes, I only want to switch 100 watts. That's about 0.5A. the relay is rated for 10A

The relay you are using is not rated for 3.3V logic, the data sheet clearly states this: This is a LOW Level 5V 4-channel relay interface board, and each channel needs a 15-20mA driver current ( a lot for a micro). Why? They put the indicator LED in series with the opto coupler, that can drop several volts depending on the color. Then there is the current limiting resistor again designed for a 5V application not a 3V3 application.

This is telling me the relays are not being properly energized and although the contacts close they are not closed properly to meet the relay's rating. Because of the lack of force the contacts will bounce a lot making lots of arcs and of course making lots of EMI noise. This would also explain the burnt/welded contacts for starters.

Snubber circuits are nice but require additional parts and are partially tuned to the particular application. Zero cross basically eliminates the arc as it turns on when the AC voltage crosses zero so no current. It also turns off at zero volts.

Solid state relays have no arcs or welding , there is nothing to weld. and they are completely contained in there package.

Hopefully this explains why I recommended appropriate solid state relays.

If you are talking about the old module I used, it was powered externally with 5V and the relay was switched on with a mosfet (opening up ground).
The new one, where this thread is about, will have 5V from USB-C and again, the ground will be switched by a MOSFET. The 3.3V only turns on or off the mosfet, not the actual realy. The coil of the relay is not powered from a MCUs pin.

There was no bouncing. I was able to draw more than 100mA from the connections to the coil without any issue with an external load
https://www.youtube.com/watch?v=OAmXypXwkeg here the spark is shown very cleary and it is explained how and why it is happening

Yes, but if I design a PCN from scratch, like I do here, I only solder 3 more components to the board, which is really not a big deal.

Unfortunately, I am not able to find suitable SSR on the shop lcsc. Can you recommend one that allowes to switch 240V 10A with a input of 3.3V or 5V? So far, I have not really looked into those

So far I have used a snubber "package" which had 0.1uF and 220Ohms soldered on it. The 0.1uF gets recommended a lot while the resistor recommendation for 220V 10A varies between 80Ohms and 220Ohms. That would lead to two questions:

  1. Would it be better to have the snubber connected to the COM and NO connetion instead of the NO and return path? And if yes, why?
  2. Since now I dont buy a package but design the PCB myself, I can chose different values. I could use 100Ohms 0.1uF if that would make it better? Or do you think a higher value would be better like 1k resistor?
    But still, I dont fully understand why the snubber needs to be conneted parallel to the switch and not to the load

If you are switching AC, I would forget about the relay and use a snubberless TRIAC.
If you are switching DC I would use a MOSFET with TVS diode
No need to worry about melted contacts and will last forever

1 Like

I would expect that, they generally use a triac (AC) and in the voltage and current range you asking you will find that many available both domestic and china manufacturers. Just search for solid state AC relay you will probably find hundreds. Just look at the specifications and be sure it is AC or DC, you have not stated which. The relays may look similar but are different internally.