logo elektroda
logo elektroda
X
logo elektroda

[Solved] ESP32 Vroom 30pin resets when controlling MC-25M20 relay via GPIO25

nkznkz 231 10
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 21523725
    nkznkz
    Level 9  
    Hey.

    I have more or less the following circuit controlling a relay:

    Relay control circuit diagram using a transistor, diode, and resistor. .
    I've deleted the values because I can't open it up to read the data precisely now, but the circuit works to some extent.

    The control is provided to me by the GPIO25 output on the ESP32 Vroom 30pin chip.
    The RM84-2012-35-1003 relay on the other hand controls the MC-25M/20 single phase contactor.

    In contrast, I have a problem with the ESP32.
    When switching the state on the GPIO25 pin, 4 times out of 5, the relay, and at the same time the contactor, switches on/off. On the other hand, this one time out of five, the ESP32 feels like it reboots, at which point it loses connection to WiFi.

    Screenshot showing ESP32 and Home Assistant logs with network connection loss and ping timeouts when switching a relay. .

    When I have only the relay connected, the ESP32 works stably and does not lose WiFi connection. The trouble starts when I add the aforementioned contactor to the whole thing.

    Should I focus more on the interference from the power supply side of the ESP32, or should I pay attention to the electromagnetic interference though?
    Many thanks for any suggestions.
  • ADVERTISEMENT
  • #2 21523731
    xury
    Automation specialist
    Test on Tasmota. If you have resets it means a problem with the power supply. If none - a problem with your code.
  • #3 21523756
    nkznkz
    Level 9  
    >>21523731 .
    This is ESPHome, so in the code I did not create.
  • ADVERTISEMENT
  • #4 21523857
    jarewa
    Level 32  
    nkznkz wrote:
    Should I focus more on interference from the power supply side of the ESP32, or should I pay attention to electromagnetic interference though?
    .


    One and two, you haven't shown the workmanship of the whole thing and what power supply you don't know if the AC is far from the cables and board. But the problem is with the power supply "peaks" on the esp.
  • #5 21523885
    TvWidget
    Level 38  
    First verify that the EN pin is properly polarised and protected against external interference.
  • #6 21524018
    khoam
    Level 42  
    nkznkz wrote:
    When switching the state on the GPIO25 pin, 4 times out of 5 the relay, and also the contactor, switches on/off. On the other hand, this one time out of five, the ESP32 feels like it reboots, at which point it loses connection to WiFi.
    .
    Add a circuit quencher to the relay contacts, then the ESP32 reboot problem disappears 95% of the time.;)

    nkznkz wrote:
    Should I focus more on the interference from the power supply side of the ESP32, or should I pay attention to the electromagnetic interference though?
    .
    The latter. They are generated due to sparking of the relay contacts.
  • ADVERTISEMENT
  • #7 21524938
    nkznkz
    Level 9  
    >>21523857 .
    I won't draw out the schematic now but I am posting a picture which may be enough for some:

    Interior of an electrical cabinet with relays, contactors, wires, and a YINGJIAO switching power supply.

    The power supply is a Chinese YINGJIAO with voltage regulation (as pictured).
    I should mention that there will eventually be two contactors in the box, with one 3f. So as you can see the environment is somewhat toxic.
    I'm considering a gasifier circuit, but on the other hand I'm thinking of taking the low voltage electronics outside because even the 5% unreliability mentioned by @khoam will annoy me greatly.
    On the other hand I'm thinking of replacing the ESP32 with something else without wifi with ethernet hooked up to the chip, something more resistant to the interference mentioned.
    After testing what I've built for myself, I have quite a bit of confusion.
  • #8 21524989
    TvWidget
    Level 38  
    This 5V relay has a coil with a large number of turns. There are interference-generating components nearby. This coil acts as a very effective antenna. As far as simple solutions are concerned, in addition to the gasifier circuit, you can try connecting the relay to 5V through a diode. Also observe if the problem occurs when the contacts are opened or shorted.
  • #9 21525017
    jarewa
    Level 32  
    TvWidget wrote:
    When it comes to simple solutions, besides the gasifier circuit, you can try connecting a relay to 5V through a diode.



    Or an optoisolator, it will get rid of interference from this side to gopio 100%.
  • ADVERTISEMENT
  • #10 21525032
    TvWidget
    Level 38  
    jarewa wrote:
    Or an opto-isolator, will get rid of interference from this side to gopio 100%.
    .
    This will do nothing. The relay is fed from the same voltage as the ESP.
  • #11 21527875
    nkznkz
    Level 9  
    Yes.
    Supplying the 5V power supply from the same source on which the contactor was standing, generated the problem, as a surge to another supply reduced the effect by 90%.
    Nevertheless, there were still occasional reboots, so I was forced to take the ESP32 out of the box which has already eliminated the problems definitively.
    Thank you all for your comments and feedback.
    Regards

Topic summary

An ESP32 Vroom 30pin module controlling an RM84-2012-35-1003 relay, which in turn operates an MC-25M/20 single-phase contactor, experiences frequent resets and WiFi disconnections when switching GPIO25. The issue does not occur when only the relay is connected, indicating interference related to the contactor. The problem is attributed to power supply disturbances and electromagnetic interference caused by relay contact sparking and the coil acting as an antenna. Suggested solutions include verifying power supply stability, ensuring proper EN pin protection, adding a snubber (quenching) circuit across relay contacts, using a diode in series with the relay coil, and employing optoisolation to eliminate interference on the GPIO line. The environment with multiple contactors and a Chinese YINGJIAO regulated power supply is electrically noisy. Relocating the ESP32 outside the interference-prone enclosure and powering the relay and contactor from separate supplies significantly reduced resets. Ultimately, removing the ESP32 from the box eliminated the reboot problem, confirming that interference and power supply spikes were the root causes.
Summary generated by the language model.
ADVERTISEMENT