Home Automation DISCUSSION

ESP8266 relay board resets or glitches when the relay switches a mains load: how do I fix it?

Started by chakreshjoshi relay interferenceESP8266 resetsRC snubberinductive load switchingrelay module wiring
5 replies 248 views 6 participants
Latest activity · 30 Sep 2026

ESP8266 relay board resets or glitches when the relay switches a mains load: how do I fix it?

chakreshjoshi Home Automation Forum
#1

My ESP8266 controls a pump and a fluorescent lamp through a two-channel 5 V relay module. With no load connected everything is stable. With the mains loads connected, the ESP sometimes reboots or loses Wi-Fi, or the second relay chatters, at the moment a relay opens. The board is powered from a 5 V phone charger and the relay module shares that supply.

What causes this, and what is the correct way to suppress it without compromising mains safety?

Community replies 5

Re: ESP8266 relay board resets or glitches when the relay switches a mains load: how do I fix it?

#2

Because it only happens with the load connected, the cause is interference from the switched circuit, not the relay coil. A pump motor and a fluorescent lamp with a magnetic ballast are inductive. When the contacts open, the inductance keeps the current flowing, the voltage across the opening gap rises to hundreds or thousands of volts, and an arc forms and re-strikes several times. That produces a burst of fast transients that radiate from the mains wiring and couple capacitively into every nearby conductor, including your logic supply and the ESP's reset and GPIO lines.

The result is exactly what you describe: resets, Wi-Fi dropouts and false triggering.

Re: ESP8266 relay board resets or glitches when the relay switches a mains load: how do I fix it?

#3

Treat it at the source. Fit a suppression network across the load, or across the relay contacts, so the inductive energy has somewhere to go. The standard part is an RC snubber, typically around 100 Ω in series with 100 nF, and the capacitor must be a safety-rated X2 type for mains voltage; ready-made encapsulated snubbers exist for this. A metal-oxide varistor rated for your mains voltage across the load is another common measure and can be combined with the snubber.

Be aware that a snubber across the contacts passes a small current when the relay is open: 100 nF at 50 Hz has a reactance of 1 / (2π × 50 × 100 nF), about 32 kΩ, so roughly 7 mA flows at 230 V. The load is then never fully isolated when the relay is off. Fitted across the load instead, that problem does not arise.

Re: ESP8266 relay board resets or glitches when the relay switches a mains load: how do I fix it?

#4

Then harden the low-voltage side. Put a bulk capacitor of 470 µF or more and a 100 nF ceramic at the ESP module's 3.3 V pins, since the ESP8266 draws transmit peaks well above its average current and is sensitive to supply dips. Each relay coil on these modules takes about 70 to 90 mA at 5 V, so check that the charger and the 3.3 V regulator have margin with both relays on and Wi-Fi transmitting.

If the module has an optocoupler per channel and a separate JD-VCC jumper, use it: power the relay coils from their own 5 V supply and the optocoupler inputs from the ESP side, so coil current and contact noise do not share the logic ground. Add a 10 kΩ pull-up and 100 nF on the reset and enable pins if your board lacks them.

Re: ESP8266 relay board resets or glitches when the relay switches a mains load: how do I fix it?

#5

Layout and wiring matter as much as parts. Keep the mains wires short, twisted together where possible, and physically away from the ESP, its antenna and the signal wires to the relay board; do not run them in parallel in the same bundle. Maintain the separation between mains and low-voltage parts: several millimetres of creepage on the board, no low-voltage wire able to touch a mains terminal, and everything in an insulated or earthed enclosure with strain relief and a fuse sized for the load.

Work on it only with the mains plug removed. If any of this is unfamiliar, use a certified relay product or have the mains side checked by someone qualified.

Re: ESP8266 relay board resets or glitches when the relay switches a mains load: how do I fix it?

#6

For motor and ballast loads, consider whether a small relay is the right switch at all. Its contacts are rated much lower for inductive loads than the 10 A printed on the case, and a pump's starting current is several times its running current, so contacts pit or weld over time. A contactor or a relay with an explicit motor rating, driven by the small relay or a transistor, is the robust solution.

A zero-crossing solid-state relay switches without an arc, which removes most of the interference, but it has its own rules: it drops about a volt and needs a heatsink at higher currents, it leaks a little when off, and it must be rated for inductive loads. Whatever you fit, verify the fix by switching the load a few hundred times while logging the ESP's reset reason and uptime.

TEP COMMUNITY