How to Power an Arduino or ESP32 from 12V, 24V or Batteries

You can run an Arduino Nano or ESP32 board from the 12V system in a car, boat or caravan. A solar battery bank, a 12V plug pack and lithium cells all work too. The board itself only wants a steady 5V, so the job is getting from your supply to 5V without cooking anything. This guide covers which pin to feed on the common Nano and ESP32 boards, which converter suits your supply, how much current to allow, and how to wire it so you can still plug in USB to upload.

  • 5VWhat every board here wants
  • 8 to 40VIP67 buck converter input
  • 3A or 5AIP67 buck converter output
  • 2 to 16VTPS63070 buck-boost input
In this guide
  1. The short answer
  2. Which pin to feed on each board
  3. Why 12V on VIN cooks the regulator
  4. Buck, buck-boost or linear
  5. How much current to allow
  6. Cars, boats, caravans and solar
  7. Wire a buck converter to an ESP32
  8. Run it from lithium cells
  9. Uploading with the 5V supply connected
  10. Check it works
  11. Troubleshooting
  12. Questions

The short answer

Turn your 12V or 24V supply into a regulated 5V with a buck converter, then wire that 5V to the board's 5V pin (called VIN on the 30-pin ESP32) and its GND. Any regulated 5V buck converter with a high enough current rating does this job, so if yours is a different one, go by its own label for wire colours and input range. Servos, relays and LEDs take their 5V from the converter too, not from the board. For a battery that sits close to 5V, such as one 18650 cell, use a buck-boost module instead, because the cell runs from 4.2V full down to about 3V flat.

Which pin to feed on each board

Each ESP32 board in the table below runs its chip at 3.3V from a small onboard regulator, and that regulator is fed from the USB-C socket or the 5V pin. That pin is a 5V input on all of them, even where it is labelled VIN. These are the pins and ranges for the common boards, wherever you bought yours. If your board's own documentation gives a different range, go by that.

Board 5V goes to Range
ESP32-WROOM-32 30-pin VIN and GND 4.75 to 5.25V
ESP32 38-pin 5V and GND 4.75 to 5.25V
ESP32-C3 SuperMini, C3 Zero and S3 Zero 5V and GND 4.5 to 5.5V
ESP32-C6 SuperMini and H2 SuperMini 5V and GND, or one lithium cell on the B+ and B- pads 4.5 to 5.5V
ESP32-S3 SuperMini 5V and GND, or one lithium cell on the B+ and B- pads 3.3 to 6V
ESP32-S2 Mini VBUS and GND 4.75 to 5.25V
Nano V3 5V and GND Regulated 5V, or 7 to 9V on VIN
Nano SuperMini 5V and GND pads Regulated 5V

The Nano is the one board here where VIN is a genuine higher-voltage input. It feeds the Nano's own 5V regulator, and 7 to 9V there is fine for the Nano plus a few LEDs. From 12V or more, a buck converter into the 5V pin runs much cooler.

The 3V3 pin can also take power, but only a steady 3.3V from a regulator, and only while USB and the 5V pin are both unpowered. The ESP32 chip's absolute limit is 3.6V, so a lithium cell at 4.2V on 3V3 will damage it.

If you are still choosing a board, our ESP32 buying guide compares them side by side.

Why 12V on VIN cooks the regulator

The regulator on these boards is a linear type. It takes in whatever voltage you give it and turns the difference into heat, so the higher the supply, the hotter it runs.

On the 30-pin ESP32-WROOM-32 board the regulator is an AMS1117-3.3. Fed from 12V, it has to drop 8.7V. With WiFi on, the board draws around 150mA on average, so that tiny part turns about 1.3W into heat. That's enough to push it more than 100°C above room temperature, and it shuts down or fails. The AMS1117 is also only rated to 15V on its input, and a car with the engine running sits at about 14.4V.

The Nano shows the same thing more slowly. From 12V on VIN, its 5V regulator drops 7V. The Nano alone draws little, so it stays warm. Add a relay drawing 190mA and the regulator has to lose about 1.7W, which is more than a part that size can shed.

A buck converter does the same job by switching, not by burning off the difference. Our IP67 buck converter runs at over 93% efficiency, so a full 15W at 5V takes about 1.3A from a 12V supply and the case only gets warm.

Buck, buck-boost or linear

Type What it does Use it for
Buck (step-down) Makes a lower voltage from a higher one, at over 90% efficiency 12V and 24V systems: car, boat, caravan, solar bank, 12V plug pack. Our IP67 buck converter takes 8 to 40V and gives 5V at 3A or 5A.
Buck-boost Holds its output whether the input is above or below it Batteries that cross the voltage you need, such as one 18650 cell for a 5V board. Our TPS63070 module takes 2 to 16V and comes in 3.3V, 5V or 9V versions.
Linear regulator Drops voltage and turns the difference into heat Small drops only, such as the regulator already on your board taking 5V down to 3.3V.

A 12V or 24V DC to DC module like the IP67 buck converter is the usual answer for anything running off a vehicle or a 12V plug pack (also called an AC adapter). The TPS63070 is the answer for battery builds. Its 16V input limit is too close to a running car's 14.4V, so keep it for batteries.

How much current to allow

Add up what everything on the 5V side can draw at its worst, then pick a converter with room to spare. These are the figures we use:

Part Allow
ESP32 board with WiFi on 500mA. It averages much less, but WiFi transmits in bursts of 240 to 355mA depending on the chip.
SG90 servo 700mA each. It runs at 100 to 250mA but draws up to 700mA when it stalls or starts under load.
5V relay board 190mA for each relay that is switched on.
Standard 5mm LED 20mA each.

As an example, an ESP32 with two SG90 servos and two relays comes to 0.5 + 1.4 + 0.38, about 2.3A. The 3A buck converter covers it. Five or more servos, or a long run of addressable LEDs, is the point to step up to the 5A version. To run more servos than your board has spare pins, our PCA9685 servo driver guide covers up to 16 and sizes the supply for each count.

Check the supply side as well. The 3A converter at full load takes about 1.3A from 12V, so a 12V plug pack rated at 2A has room for it. From 24V it takes about 0.7A.

Cars, boats, caravans and solar

A 12V system is rarely at 12V. A rested battery sits around 12.6V. With the engine, a charger or the solar panels running, it climbs to 13.8 to 14.4V. Some solar controllers push a lead-acid battery past 15V during an equalise charge. Starting the engine can drag it down to about 6V for a moment, and switching off big loads such as a winch, a starter motor or an inverter throws short spikes well above normal.

That's why the input range matters more than the number on the label. The IP67 buck converter's 8 to 40V range leaves more than 25V of headroom above a 12V system's charging voltage, and it also covers 24V trucks and solar banks, which run at about 28V while charging. A jump start from a 24V unit is inside its range too.

A few habits keep a vehicle install reliable:

  • Fuse the positive lead close to the battery. We use 3A for the 3A converter and 5A for the 5A version on a 12V supply. On 24V, use 2A and 3A. An inline blade fuse holder from any auto parts shop does the job.
  • Check polarity before you connect. The converter's input isn't protected against being wired backwards, so red goes to positive and black to negative.
  • Seal the joints. The converter itself is potted and rated IP67, so the joints are the weak point. Solder seal connectors keep water out, and our crimp terminal guide covers crimped joints.
  • Think about standby drain. The converter draws about 30mA with nothing attached, and an ESP32 with WiFi on adds roughly 70mA at 12V. That's about 2.4Ah a day, or 17Ah a week from a caravan battery left parked. Run it from a switched accessory feed, or fit a switch, if the project doesn't need to run all the time.

If you want the ESP32 to keep an eye on the battery itself, our 0-25V voltage sensor guide shows how to read it.

Wire a buck converter to an ESP32

Wiring diagram: 12V plug pack into a DC barrel socket screw terminal adapter, then through a 3A inline fuse to a 5V buck converter. The yellow 5V lead goes to ESP32 VIN and the servo red lead, the black lead to ESP32 GND and the servo brown lead, and the servo orange lead to D13.
The buck converter's red and black leads take the 12V or 24V supply. Its yellow lead is 5V out and its black output lead is ground. Not to scale.
  1. Bring the supply in. For a 12V plug pack, a DC barrel socket screw terminal adapter takes the plug and gives you two screw terminals, marked + and -. A 5.5 x 2.1mm DC pigtail does the same with leads already fitted. If you're not sure of your plug pack's plug size or polarity, our DC barrel jack guide explains both. For a battery, run the wires straight to the fuse.
  2. Fit the fuse in the positive lead, then connect positive to the converter's red input lead and negative to its black input lead.
  3. Measure before you connect the board. Power up and check the yellow output lead against the black output lead with a multimeter. It should read close to 5V, between 4.75 and 5.25V.
  4. Power off, then wire the board. Yellow goes to VIN on the 30-pin ESP32 (5V on the other boards), and black goes to GND.
  5. Take servo and relay power from the converter. Join their 5V and GND leads to the converter's yellow and black leads, not to the board's pins. Only the signal wire goes to the board. WAGO 221-413 lever connectors make tidy 5V and GND junctions with no soldering. A 5V sensor such as the HC-SR04 can share the same 5V and GND, and our HC-SR04 guide shows how to bring its 5V Echo signal down for the ESP32.

All the grounds must be joined: the converter's output ground, the board's GND and every servo or relay ground. Input and output share a ground inside the converter, so one ground runs through the whole build.

Run it from lithium cells

Wiring diagram: an 18650 cell in a one-slot holder wired to the B+ and B- pads of a TP4056 charger board. The charger OUT+ and OUT- pads go to VIN and GND of a TPS63070 5V module, and its VOUT and GND go to the Nano 5V and GND pins.
The charger board protects the cell and charges it over USB-C. The TPS63070 holds 5V as the cell runs from 4.2V down to 3V. Not to scale.

One 18650 cell gives 4.2V when full and about 3V when flat. That's too low for a 5V pin, and too high for a 3.3V pin, so it needs a converter that can step up and down.

  1. Charge and protect the cell. Put it in an 18650 holder and wire it to the B+ and B- pads of a TP4056 charger board. The board charges the cell over USB-C and cuts the output if the cell runs too low.
  2. Feed the buck-boost. Wire the charger's OUT+ and OUT- pads to VIN and GND on the TPS63070 5V version.
  3. Feed the board. Wire the module's VOUT to the Nano's 5V pin and its GND to GND. On an ESP32, VOUT goes to the 5V pin, or VIN on the 30-pin board.

From one cell we suggest keeping the 5V load to about 1A, which covers any of the boards above with a couple of sensors and a small display. Servos on a single cell are better on their own supply. With two cells in series (6 to 8.4V) the module is stepping down, and we suggest up to about 1.5A.

The TPS63070 limits its input current while its output starts up. If the output doesn't come up with a heavy load attached, connect the load after power-up.

The ESP32-C6, H2 and S3 SuperMini boards have a lithium charger built in. A single protected cell solders straight to the B+ and B- pads underneath and charges whenever USB-C is plugged in, so those boards need no converter at all for a one-cell build.

Uploading with the 5V supply connected

On these ESP32 boards the USB-C socket and the 5V pin share one supply line. With the converter on the 5V pin and a USB cable plugged in, your computer's USB port and the converter end up pushing against each other. Use one source at a time, and treat the Nano the same way.

The easy habit is to disconnect the converter's yellow 5V lead before you plug in USB, and leave the grounds joined. If you upload often, put a WAGO 221-412 in the yellow lead so it's one lever to open. Unplugging the 12V side isn't enough on its own, because USB would then feed backwards into the converter and anything else on the 5V side, servos included.

If you'd rather test on the bench with USB only, unplug the converter's 5V lead and run the board from your computer as normal. Our ESP32-WROOM-32 getting started guide covers the first upload.

Check it works

  1. Converter only. With nothing on the output, power up and measure yellow to black. You should see 4.75 to 5.25V.
  2. Add the board. Power off, connect the board's 5V (or VIN) and GND, then power up. The board's power LED lights, and the 3V3 pin reads about 3.3V to GND.
  3. Add the load. Connect the servos or relays, upload a sketch that moves them, and measure yellow to black while they work. It should stay above 4.75V and the board should keep running without restarting. The sweep sketch in our MG90S servo guide is a good test.

Troubleshooting

What you see What to do
The board got very hot, then stopped working 12V reached the 5V or VIN pin and the regulator has likely failed. Try the board on USB alone. Next time feed it 5V from a buck converter.
ESP32 restarts when a servo moves, or prints Brownout detector was triggered The 5V dips under load. Power the servos from the converter's 5V, not the board's 5V pin. Keep the 5V leads short, and add a 470µF capacitor across the servo supply from our capacitor kit, stripe to GND.
Relays click and the board resets Same cause. Give the relay board its 5V straight from the converter and check the converter's rating against the current table.
Converter output reads 0V Check the fuse and the input polarity. Red must go to positive. If the input was ever reversed, the converter may be damaged.
TPS63070 output doesn't come up Disconnect the load, power up, then reconnect it. Check the cell is above about 3V.
Runs from 12V but not from the battery pack A flat cell. Charge it through the TP4056's USB-C until its blue light comes on.
Computer warns about a USB port power problem USB and the converter are both feeding 5V. Disconnect the converter's yellow lead before you plug in USB.
Vehicle battery goes flat over a few days The project draws about 100mA around the clock. Feed it from a switched accessory supply or fit a power switch.

Questions

Can I just use a USB car charger?

Yes, for the board on its own. A USB car charger is a small buck converter, so plugging the board's USB-C into one is a tidy way to run a dashboard sensor. Keep servos and relays on a separate 5V converter, such as the IP67 buck, so their current doesn't run through the board.

Can I use two 18650 cells in series?

Yes, with the TPS63070. Two cells give 6 to 8.4V, which suits its 2 to 16V input and runs it as a plain step-down. The IP67 buck converter needs at least 8V, so two cells would drop out of its range as they discharge. Charge series cells with a charger made for two cells, not the single-cell TP4056.

Can I run an ESP32 straight from one lithium cell?

On the ESP32-C6, H2 and S3 SuperMini, yes, because they take one cell on their B+ and B- pads and charge it too. On the other boards, a cell on the 5V pin is too low to run reliably, and on the 3V3 pin it's high enough to damage the chip, so put a TPS63070 in between.

Not sure which converter suits your supply?

Message us with your supply voltage and what you're powering, and we'll help you pick.

Practical help from New Zealand

Still stuck? Send us a photo.

Tell us what you’re building and what the circuit is doing. Our small NZ team knows these parts and can help you spot a wiring problem or choose what you need next.

Ask NZN for help Browse more guides