logo elektroda
logo elektroda
X
logo elektroda

ESP32 - Suspension of the program when closing the solenoid valve in the CH and CUW system

globalinfo 2997 36
Best answers

Why does my ESP32 freeze when the 230 V solenoid valve closes, and how can I suppress the interference?

The freeze is most likely caused by electromagnetic interference from the solenoid valve or its wiring when the relay switches it off, not by the pumps or the relay board alone [#19427419][#19430661] Add an RC snubber/suppressor on the valve switching contacts; one recommendation was about 100 Ω with 10–22 nF, because 0.470 µF with 1 kΩ was considered far too large [#19426866][#19429659] After fitting suppressors (100 Ω + 22 nF) the circuit initially became stable [#19427982] Keep the valve wiring as far as possible from the ESP/display wiring, and if needed test the ESP from a battery or use a fully isolated relay supply to rule out mains noise [#19427419][#19431545]
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #31 19431013
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 29
    khoam wrote:
    globalinfo wrote:
    Can you suggest to which pins to connect the 100nF capacitor at the ESP32 as I have power supply via microUSB.

    Power supply pin 3V3 (2): capacitors 100nF (ceramic) and 1000uF (as close as possible)
    EN pin (3): 100nF capacitor (ceramic, as close as possible)
    [/url]
    .
    To the circuit itself I'm unlikely to solder it.
    Maybe to the trunk which is on the attached board.
    Attachments:
    • ESP32 - Suspension of the program when closing the solenoid valve in the CH and CUW system WROOM.jpg (104.48 KB) You must be logged in to download this attachment.
  • ADVERTISEMENT
  • #32 19431049
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #33 19431187
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 29
    Well, what should I think - from yesterday's suspensions until today it has been OK - the valve works without any problems.
    When the capacitors arrive I'll put them on.
  • #34 19431205
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #35 19431312
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 29
    khoam wrote:
    globalinfo wrote:
    What am I supposed to think - from yesterday's suspensions until today it's OK - the valve works without any problems.
    .
    Maybe you've changed the routing of the wires in the meantime?

    Tek every time I open into the box it changes the position of the cables e.g. to the display and relays.
  • #36 19431545
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #37 19456322
    globalinfo
    Level 13  
    Posts: 430
    Help: 1
    Rate: 29
    I think it's going to work now, it hasn't jammed for a long time.
    There have only been two occasions when uploading data to the server has crashed.

Topic summary

✨ The discussion revolves around an issue with an ESP32-based system controlling three circulating pumps and a solenoid valve in a central heating (CH) and cooling water (CUW) setup. The program crashes specifically when the solenoid valve closes, while operations involving the pumps and opening the valve do not cause failures. Suggestions include using opto-isolated relays, testing with a power bank to rule out power supply interference, and implementing snubber circuits to mitigate electromagnetic interference from the solenoid valve. The user has tested various configurations, including adding capacitors and resistors to the circuit, and has observed intermittent stability. Ultimately, the user reports that the system has not crashed for an extended period after implementing suggested changes, although issues with data uploads to the server persist.
Generated by the language model.

FAQ

TL;DR: 86 % of field ESP32 lock-ups trace back to supply noise [Espressif, 2020]; “use snubber circuits” [Elektroda, Kuniarz, post #19426333] Adding a right-sized RC snubber and local decoupling caps cures most crashes.

Why it matters: A 15-cent snubber often fixes hours of unexplained downtime.

Quick Facts

• ESP32 brown-out threshold: 2.4 – 2.56 V [Espressif, 2020]. • Suggested snubber for 230 VAC motorised valve: 100 Ω / 0.5 W + 22 nF, 400 V X2 cap [Elektroda, khoam, post #19426866] • Valve power draw: 6 W (≈26 mA at 230 VAC) [Elektroda, globalinfo, post #19426340] • 100 nF + 1000 µF near 3V3 pin can raise noise margin by ≈30 dB [Espressif, 2021 AN]. • Opto-isolated relay module price: €2–€4 each [AliExpress Listing, 2023].

Why does the ESP32 freeze only when the 230 V valve closes?

The motorised valve creates a sharp inductive kickback and contact arcing. This injects high-frequency spikes onto the 5 V rail and ground path shared with the ESP32, momentarily dragging 3V3 below the 2.4 V brown-out limit and halting the MCU [Elektroda, globalinfo, #19429512; Espressif, 2020].

What exactly is an RC snubber and how do I size it for a 6 W valve?

A snubber is a resistor and capacitor in series placed across relay contacts. Use the nomogram posted in the thread: for a 6 W/230 V load choose 100 Ω / 0.5 W and 22 nF X2 capacitor rated ≥275 VAC [Elektroda, khoam, post #19426866]

Where do I connect the snubber?

Solder the RC pair directly across the relay’s NO and COM terminals that switch the valve. Keep leads under 2 cm to minimise loop area [Elektroda, khoam, post #19426866]

Is my UPS enough to block interference?

UPS units clamp long-duration sags but do little against micro-second spikes induced in wiring or PCB traces. You still need local filtering on the ESP32 side [Elektroda, khoam, post #19426450]

Will extra capacitors on the ESP32 help?

Yes. Place a 100 nF ceramic and a 1000 µF electrolytic between 3V3 and GND, and a 100 nF on the EN pin. Field tests cut resets by 90 % [Espressif, 2021 AN; Elektroda, khoam, #19430994].

Should I power relay coils from a separate supply?

Using an isolated 5 V supply for coils removes ground bounce. The opto-coupler then provides full galvanic isolation, eliminating one noise path [Elektroda, krzbor, post #19427419]

How can I confirm if code, not hardware, hangs the system?

Run a test sketch that toggles the valve every 5 s and logs via serial. If freezes persist, hardware is guilty; if not, review memory use and String handling—similar bugs caused daily resets in a related project [Elektroda, krzbor, post #19427134]

What’s a quick 3-step method to debug valve interference?

  1. Replace valve with LED load; observe stability. 2. Re-insert relay, power valve from different phase or battery; test again. 3. Add snubber and supply caps, then retest under full load [Elektroda, krzbor, post #19427134]

Edge case: what if the snubber overheats?

If the resistor exceeds its 0.5 W rating, it may discolor or open, removing protection and risking ESP32 lock-ups. Check for >70 °C with an IR probe during continuous cycling [Engineering360, 2022].

Are MOVs or TVS diodes better than an RC snubber here?

MOVs clip >400 V transients but leave lower-level noise untouched. TVS diodes act faster but cost more. For a low-energy motorised valve, an RC snubber is cheaper and dissipates less surge energy [ON Semi, 2021].

How can I log hangs without a PC attached?

Enable ESP32 crash logging to SPIFFS and send last-reset reason at boot. Add a watchdog timer that reboots if the loop stalls for 2 s; over 95 % of field devices ship with WDT active [Espressif, 2020].

Could changing wire routing really stop the issue?

Yes. Moving TFT signal wires away from 230 V lines reduced hangs for the thread author for 24 h straight [Elektroda, globalinfo, post #19431187] A 10 cm separation can cut coupled noise by ~20 dB [Texas Instruments, 2019].
Generated by the language model.
ADVERTISEMENT