The Arduino restarts when the motor, pump or relay switches on

  • Arduino
  • ESP32
  • Motors
  • Pumps
  • Relays

Why it happens

  • The motor shares the Arduino's 5 V.
  • The battery is weak. Small 9 V batteries can't drive motors.
  • No diode across the motor or relay coil.

How to fix it

  1. Give the motor its own battery or adapter.
  2. Join the grounds.
  3. Put a 1N4007 diode across the motor or coil, stripe to the positive side (relay modules have one built in).
  4. Use AA cells or a rechargeable pack, not a 9 V block.

It worked if: Switch the motor ten times: the Arduino doesn't restart.

From how the part works. Explained from how the part works; not tried on a real circuit for this page.

Didn't help? Search another error or ask us.