Education › Robotics › Stage 2: Sense and move

Power and batteries, safely

LiPo vs NiMH vs power banks, voltage regulation, current budgets and not starting a fire.

Beginner→Intermediate ~32 min read Module 8 of 16

Power is the quiet cause of most first-robot failures — the board that resets randomly, the motors that stall, the robot that dies in ten minutes. This lesson demystifies it: how to read a battery's voltage and capacity, why logic and motors want separate supplies, how a regulator gives you a clean voltage, and the wiring rules that keep the smoke inside the chips. None of it is hard once you see the picture, and getting it right turns a flaky robot into a reliable one.

After this module you can
  • Read a battery's voltage, capacity (mAh) and C-rating and estimate run time
  • Explain why motors and logic should draw from separate supplies
  • Use a regulator to turn a battery voltage into a clean logic voltage
  • Apply the grounding and wiring rules that prevent resets and damage

Reading a battery

Three numbers describe a battery. Voltage (like 3.7 V for one lithium cell, 7.4 V for two in series) must match what your motors and regulator expect. Capacity in milliamp-hours (mAh) is how much charge it holds: a 2000 mAh pack can in theory supply 2000 mA for one hour, or 1000 mA for two — so run time is roughly capacity divided by average current draw. C-rating is how fast it can safely deliver that charge; a motor that briefly pulls several amps needs a battery whose C-rating allows it, or the voltage sags. For a first robot, a common choice is a rechargeable lithium pack or a holder of AA cells; know the three numbers and you can predict whether it will run your robot and for how long.

Note

Quick run-time estimate: run_time_hours ≈ capacity_mAh ÷ average_current_mA. Motors dominate the current, so a robot that draws 500 mA average on a 2000 mAh pack runs roughly four hours — less under heavy driving.

Two supplies: logic and motors

The most important power idea in robotics: separate the motor power from the logic power. Motors are electrically noisy — when they start, stall, or change direction they yank current and inject voltage spikes. If your microcontroller shares that same rail, those spikes and dips make it reset or behave randomly, which is the number-one cause of 'my robot keeps rebooting.' The fix is to power the motors from one source (through the driver) and the logic from a clean source, and to join their grounds so the control signals have a common reference. Two supplies, one shared ground — that is the pattern behind a stable robot.

In practice this can be two separate batteries, or one battery feeding the motor driver directly and also feeding a regulator that produces a clean voltage for the board. The point is that the logic never sees the raw, spiky motor rail.

Regulators: making a clean voltage

Your battery rarely sits at exactly the voltage your board wants, and it droops as it discharges. A voltage regulator takes a varying higher input and produces a steady lower output — for example turning a 7.4 V pack into a rock-steady 5 V for logic. There are two kinds worth knowing. A linear regulator is simple and cheap but wastes the difference as heat, so it is fine for small loads only. A switching regulator (a buck converter) is far more efficient and the right choice when current is significant, which is most robots. Many microcontroller boards have an onboard regulator for the board itself, but it is weak — never use it to power motors or several servos.

Watch out

Do not power motors or multiple servos through the microcontroller board's onboard regulator or its 5V pin. It is sized for the chip, not for actuators, and will overheat or brown out. Feed actuators from the battery or a dedicated buck converter.

Wiring rules that prevent smoke

A handful of habits prevent almost all electrical damage. Check polarity before connecting — reversing plus and minus can instantly kill a board; many modules have no reverse protection. Match voltages — a 5 V sensor on a 3.3 V board's line, or the reverse, can damage one of them; know your board's logic level. Size your wires and connectors for the current — thin wires to a motor get hot and drop voltage. Add a fuse or a switch on the main battery lead so you can cut power fast and protect against a short. And never hot-plug the motor supply while everything is live. These are boring rules, and they are exactly what separates a robot that works from one that releases smoke.

  • Confirm plus and minus before every connection; reverse polarity kills boards.
  • Know your logic level (3.3 V vs 5 V) and match sensors to it.
  • Use thick enough wire to motors; thin wire heats up and drops voltage.
  • Put a switch or fuse on the main battery lead to cut power fast.
  • Join all grounds — battery, driver, board — to one common ground.

Knowing when power is the problem

When a robot misbehaves, suspect power early. The tell-tale signs are specific: the board resets or the lights flicker exactly when a motor starts (the supply is sagging under the motor's inrush); the robot slows down over minutes (the battery is discharging); a servo jitters only under load (its current is dipping the rail). A cheap multimeter is your friend here — measure the battery under load, not at rest, because a battery that reads fine idle can collapse the moment motors pull current. Learning to reach for the multimeter instead of rewriting code will save you hours.

cpp
// Read approximate battery voltage through a divider on an analog pin.
// Two equal resistors halve the battery voltage so it fits 0-5V.
const int VBAT = A0;

void setup() { Serial.begin(9600); }

void loop() {
  int raw = analogRead(VBAT);           // 0-1023
  float pinV = raw * (5.0 / 1023.0);    // volts at the pin
  float battV = pinV * 2.0;             // undo the /2 divider
  Serial.println(battV);                // watch it sag under load
  delay(500);
}
Hands-on practice

Power your robot properly

  1. Write down your battery's voltage, capacity in mAh, and estimate the run time for a 500 mA average draw.
  2. Wire the motors to draw from the battery through the driver, and the board from a regulator or separate source.
  3. Join every ground — battery, driver, and board — to one common ground point.
  4. Add a switch on the main battery lead and confirm it cuts all power.
  5. Measure the battery voltage with a multimeter while the motors run, and watch how much it sags compared to at rest.
Cheat sheet

Power and batteries, safely — at a glance

Main things to focus on

  • A battery has a voltage, a capacity (mAh), and a C-rating; run time ≈ mAh ÷ average mA.
  • Keep motor power and logic power separate, but join their grounds.
  • A regulator turns a varying battery voltage into a clean logic voltage.
  • Never power motors or multiple servos from the board's onboard 5V.
  • Check polarity and match logic levels before connecting anything.
  • Measure the battery under load — resets when a motor starts mean the supply is sagging.

Battery numbers

Voltage (V)must match motors and regulator input
Capacity (mAh)charge held; sets run time with current
C-ratinghow fast it can safely deliver current
mAh ÷ avg mArough run time in hours

Clean power

Separate railsmotors on one supply, logic on another
Common groundjoin all grounds for a shared reference
Linear regulatorsimple, wastes extra as heat; small loads
Buck converterefficient switching regulator for real loads

Wiring safety

Check polarityreverse plus/minus can kill a board
Match logic level3.3V vs 5V — protect sensors and pins
Switch / fuseon the main lead to cut power fast
Wire gaugethick enough for motor current

Diagnosing

Reset on motor startsupply sagging under inrush current
Slows over minutesbattery discharging
Measure under loadtest voltage while motors run, not at rest

Common pitfalls

  • Sharing one noisy rail between motors and the microcontroller, causing random resets.
  • Powering motors or several servos through the board's onboard 5V regulator.
  • Reversing battery polarity on a module with no reverse protection.
  • Judging a battery by its resting voltage instead of its voltage under load.
  • Forgetting to join grounds, so control signals have no common reference.
Quiz

Check your understanding

5 questions · 4 to pass · answers are explained as you go. Your best score is saved on this device only.

Progress and quiz scores are saved in this browser only. Back up or restore on the hub.

Was this lesson useful? Tell me what to improve →