From the workshop: Arduino Uno R3 Development Board (ATmega328P) With USB Cable

View product
All articles
Robotics

🔋Arduino Resets When Motor Starts? Fix Random Resets from Motors and Servos (Wiring Guide)

Arduino or ESP32 resets or acts randomly when motors or servos start? Learn why start-up current, battery sag and motor noise cause it, and fix it with separate supplies, a common ground, capacitors, flyback diodes and proper wire.

TThinking Robot Team 12 min read
Arduino robot car wiring with a separate motor battery, common ground and capacitors to stop resets when the motors start
In this article (17)

Your robot car code works perfectly with the wheels off the ground, but the moment the motors start, the Arduino resets when the motor starts, the servo twitches, or the board starts behaving randomly. This is the most common power problem in student robotics, and it has a clear set of causes and fixes.

Direct answer: an Arduino (or ESP32) resets when a motor or servo starts because the motor's start-up current pulls the supply voltage down, or its electrical noise and spikes disturb the board. The fix is to power the motors from their own battery through a motor driver, connect only the grounds together (one wire), and add 100 nF capacitors across the motors plus a bulk capacitor at the driver. Never run motors or servos from the Arduino's 5V pin.

Quick fix: Arduino resets when motor starts

Ordered from the most common cause to the least.

#Likely causeHow to confirmFix
1Motor or servo powered from the Arduino's 5V pin or USBDriver or servo power wire goes to the ArduinoSeparate battery for motors, common GND
2One weak battery runs everythingResets as motors start; worse as the battery drainsStronger pack, or separate supplies
3Motor noiseResets even with separate supplies100 nF across each motor, twisted wires
4Ground wiringMotor current returns through the Arduino's GNDStar ground: one GND wire to the driver
5No flyback diodeMotor or relay switched by one transistorDiode across the motor or coil
6Thin wires, breadboardMotor current runs through jumpersShort, thick wires straight to the driver
7No bulk capacitorResets at direction changes or full-speed starts100 µF–470 µF across the driver's supply

Flowchart: motor powered from the 5V pin, same battery, still resetting with separate supplies, single transistor switching, then noise and grounding checksAnswer the questions from the top; most robots are fixed by the first two boxes.

Why does an Arduino reset when a motor starts?

Because a stopped motor behaves almost like a short circuit for a moment. A spinning DC motor generates a back-voltage that limits its current, but at the instant it starts there is none, so the current is limited only by the winding resistance:

text
Start-up (stall) current ≈ supply voltage ÷ winding resistance
Example: winding measures 5 Ω on a multimeter, 6 V supply → 6 ÷ 5 = 1.2 A

That surge lasts only a fraction of a second, but it is enough to upset the board in three ways:

What the motor doesWhat the Arduino seesResult
Draws a big start-up currentSupply voltage dips (battery sag)Brown-out reset or random crash
Returns that current through shared GND wiresThe Arduino's "0 V" jumps aroundWrong readings, glitches, resets
Sparks inside its brushes; spikes when switched offElectrical noise on power and signal wiresRandom resets, frozen sketches

On an Arduino Uno, the ATmega328P's brown-out detector is set to reset the chip if its supply falls below about 2.7 V. Between that and about 4.5 V, a 16 MHz ATmega328P is outside the speed range guaranteed in the ATmega328P documentation, so it may crash or freeze without a clean reset. That is why the symptom is sometimes "acts randomly" rather than "restarts". On an ESP32 the same dip prints Brownout detector was triggered (see our ESP32 brownout fix).

Cause 1: motors or servos powered from the Arduino

The Arduino's 5V pin is meant for sensors and small modules, not motors. When a motor driver or servo takes its power from the 5V pin, every start-up surge flows through the Arduino's own regulator or USB connection. An Uno's USB input is protected by a 500 mA resettable fuse, so a 1 A – 2 A motor surge collapses the 5 V rail and the board resets.

Wrong: L298N and servo powered from the Arduino's 5V pin. Right: a 2S Li-ion battery powers the L298N, a 470 µF capacitor sits across the driver supply, and one GND wire links the Arduino to a star point at the driverMotor current should flow only around the battery, driver and motor loop, never through the Arduino.

Fix: power the motor driver's VS (+12V) terminal from a battery, connect the battery negative to the driver's GND, and run one wire from the Arduino's GND to the driver's GND. The Arduino can stay on USB while you test. Our L298N robot car guide shows the full wiring, and the L298N vs TB6612FNG vs DRV8833 comparison helps you pick a driver. For servos, see the power section of our SG90 servo guide.

Cause 2: the battery sags at start-up

Every battery has internal resistance, so its voltage drops while it delivers a big current. If the Arduino runs from the same battery, its supply drops too.

Graph: two motors draw a 2.4 A start-up surge then 0.5 A; a 9 V AA pack dips to 5.4 V, below the 7 V the Uno needs, while a 2S Li-ion pack only dips to 7.16 VSame motors, two batteries. Internal resistance decides how far the voltage falls.

Battery packNominal voltageTypical internal resistance (assumed)Voltage during a 2.4 A surge
9 V PP3 (alkaline)9 Vabout 2 Ω9 − 4.8 = 4.2 V
6 × AA alkaline9 Vabout 1.5 Ω5.4 V
2S Li-ion 18650 pack7.4 Vabout 0.1 Ω7.4 − 0.24 = 7.16 V

Internal resistance rises as cells age, drain or get cold, so a robot that worked on fresh cells often starts resetting as the battery runs down. A 2S Li-ion pack holds its voltage much better (our robot battery guide explains how to choose and charge one safely), but even it gets close to 7 V when nearly empty. The most robust fix is a separate supply for the Arduino, or a 5 V buck-boost converter that holds its output steady while the battery dips. Estimate run time with the battery life calculator.

Should the Arduino and the motor share a ground?

Yes: they must share a ground, but they should not share a supply. The control signals (IN1, ENA, servo signal) are measured relative to GND, so without a common ground the driver or servo cannot read them. But the motor's large current should never flow through the Arduino's GND pins or thin breadboard wires on its way back to the battery.

Use a star ground: battery negative, driver GND and the single Arduino GND wire all meet at one point, usually the driver's GND terminal. The Arduino GND wire then carries only tiny signal currents, so its "0 V" stays steady.

Cause 3: electrical noise and spikes

Brushed DC motors spark inside as they run, and every spark is a burst of electrical noise. That noise travels along the motor wires and can reset the Arduino or confuse sensors, even with separate supplies.

Three fixes: a 100 nF ceramic capacitor across the motor terminals, a flyback diode across a motor switched by a MOSFET, and a 470 µF electrolytic plus 100 nF ceramic at the driver's supply pinsCapacitors and diodes come after the power wiring is right.

PartValueWhere it goesWhat it does
Ceramic capacitor100 nF (code "104"), 50 VAcross each motor's terminals, soldered at the motorShorts out high-frequency brush noise
Electrolytic capacitor100 µF – 470 µF, 16 V or 25 V for a 7.4 V packAcross the driver's VS and GNDSupplies start-up surges locally
Ceramic capacitor100 nFNext to the electrolytic at the driverHandles fast spikes the electrolytic is too slow for
Electrolytic for servos470 µF – 1000 µF, 10 V or moreAcross the servo supply, near the servosStops servo jitter and dips

Also twist each pair of motor wires together and keep sensor wires away from them. Read the "104" code with our capacitor code calculator if you are unsure.

Cause 4: no flyback diode

When you switch a motor or relay off, its coil produces a reverse voltage spike that can damage a transistor and reset the Arduino. If you drive a motor with a single MOSFET or transistor, or switch a relay coil, fit a diode across the motor or coil with its stripe (cathode) to the + supply. A Schottky diode such as the 1N5819 suits PWM; a 1N4007 works for simple on/off switching. H-bridge driver boards such as L298N modules, TB6612FNG and DRV8833 already handle this internally or on the board. Our PWM guide shows the full MOSFET circuit.

Cause 5: thin wires and breadboards

Jumper wires and breadboard contacts are made for signals, not amps. Their resistance turns start-up current into extra voltage drop and heat.

Connector contacts add more on top. Run motor power with short wires of 22 AWG or thicker, screw them into the driver's terminals, and keep motor current off the breadboard. Check your own runs with the wire gauge and voltage drop calculator.

Hands-on: prove whether the board is resetting

This sketch counts every restart in EEPROM, so you can tell a real reset from a code bug even when the robot is not connected to a PC. It uses one motor on an L298N wired as in our L298N guide (ENA on D5, IN1 on D7, IN2 on D8).

cpp
#include <EEPROM.h>

const int ENA = 5, IN1 = 7, IN2 = 8;   // one motor on an L298N

void setup() {
  Serial.begin(9600);
  byte boots = EEPROM.read(0);
  if (boots == 255) boots = 0;         // a fresh EEPROM reads 255
  boots++;
  EEPROM.write(0, boots);
  Serial.print(F("Boot number: "));
  Serial.println(boots);

  pinMode(LED_BUILTIN, OUTPUT);
  for (int i = 0; i < 3; i++) {        // three quick blinks = "I just restarted"
    digitalWrite(LED_BUILTIN, HIGH); delay(150);
    digitalWrite(LED_BUILTIN, LOW);  delay(150);
  }

  pinMode(ENA, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
  digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
}

void loop() {
  analogWrite(ENA, 255);   // full-speed start: the hardest moment for the supply
  delay(1500);
  analogWrite(ENA, 0);
  delay(1500);
}
  1. Upload it, open the Serial Monitor and note the boot number (opening the monitor also resets the board once).
  2. Test A: power the Arduino and the motor from the same battery, the way that fails. Let it run for a minute with the wheels on the floor. Watch for the triple blink when a motor starts.
  3. Test B: give the Arduino its own supply (USB or a separate pack), keep one GND wire to the driver, and repeat.
  4. Test C: add the 100 nF and 470 µF capacitors and repeat Test A.
  5. Reconnect USB and read the boot number again.
What you seeMeaning
Boot number jumps in Test A, not in Test BSupply sag (Cause 2): separate supplies fixed it
Jumps in both testsNoise or ground path (Causes 3–4)
Test C stops the jumpsCapacitors were enough for this battery
Number never jumps, but the robot still misbehavesNot a reset: check your code and sensor wiring

ESP32 and servo notes

The ESP32 is even more sensitive, because it runs at 3.3 V and its Wi-Fi adds its own current bursts. Apply the same rules: separate 5 V – 6 V supply for servos and motors, one common ground, and capacitors. Our ESP32 brownout guide covers the ESP32's power input options.

Where to go next

Frequently asked questions

Why does my Arduino reset when the motor starts?

The motor's start-up current makes the supply voltage dip, or its electrical noise reaches the Arduino. Power the motors from their own battery through a motor driver, connect the grounds with one wire, and add a 100 nF capacitor across each motor.

Can I power a motor from the Arduino's 5V pin?

No. Even a small DC motor can draw over 1 A for a moment when it starts, while an Uno's USB input has a 500 mA fuse. Use a motor driver powered from a separate battery. Only tiny loads such as one unloaded SG90 servo for a quick test are acceptable.

Do the Arduino and motor battery need a common ground?

Yes. Without a common ground the driver cannot read the Arduino's control signals. Connect one wire from the Arduino's GND to the driver's GND, where the battery negative also connects, so the motor current does not flow through the Arduino.

What capacitor should I put across a DC motor?

A 100 nF (marked "104") ceramic capacitor soldered across the motor's terminals. For extra protection add a 100 µF to 470 µF electrolytic across the motor driver's supply, rated well above the battery voltage.

Why does my robot work on USB but reset on batteries?

The battery probably sags when the motors start, especially AA cells or a 9 V PP3 battery, which have high internal resistance. Use a 2S Li-ion pack for the motors and keep the Arduino's supply separate, or feed it through a 5 V buck-boost converter that holds steady through the dips.

T

Thinking Robot Team

Thinking Robot is a team of engineers and educators in Pune who design electronics and robotics kits and run hands-on workshops for students and schools. Spotted a mistake or have a question? Get in touch.

Filed under#Robotics#Arduino#ESP32#Electronics#Tutorial

Keep learning

WhatsApp