Learn

LM2596 buck converter: power an Arduino from 12 V

Beginner

Or see every lesson.

  • 465parts on the bench
  • 43boards running now
  • 1.00xreal time, on every board
Arduino Uno on 12 V with an LM2596live0.000 s 0.00x
Click to open it in the editor
A 12 V adapter into an LM2596 set to 5 V, its output on the Uno’s 5V pin, and A0 reading the adapter. Press Run, then set the adapter to 9 V.

The LM2596 module is the small blue board with a brass trimmer that turns 12 V, 24 V or anything up to 40 V into a lower voltage you pick. It is a buck converter, a step-down switching regulator, and it is the usual way to run an Arduino, a servo or an LED strip from a 12 V wall adapter or a battery pack without a regulator that runs hot.

The circuit above is an Arduino Uno on a 12 V adapter: the adapter into the module, the module set to 5 V into the Uno’s 5V pin, and A0 reading the adapter through a 10k and 4.7k divider. Press Run and the serial monitor prints "A0 785, adapter 12.0 V". Swap the adapter for 9 V and it prints "A0 589, adapter 9.0 V" while the 5V pin stays at 5.0 V.

What you need

  • An Arduino Uno (or any 5 V board)
  • An LM2596 buck converter module
  • A 12 V wall adapter and a DC barrel jack
  • A 10k and a 4.7k resistor, for reading the adapter on A0
  • A multimeter, to set the module before anything is on its output

Wiring

Part and pinGoes toNote
Adapter +LM2596 IN+4.5 V to 40 V in
Adapter -LM2596 IN-
LM2596 OUT+Uno 5VOnly after the trimmer is set to 5 V
LM2596 OUT-Uno GNDIN- and OUT- are the same copper on the board
Adapter + through 10kA04.7k from A0 to GND

Set the trimmer before anything is connected

A module comes set to whatever the factory left it at, often well over 5 V. The Uno’s 5V pin goes straight to the chip with no regulator in front of it, so a module set to 12 V on that pin kills the board. Put the adapter on IN+ and IN-, a meter on OUT+ and OUT-, and turn the brass screw until the meter reads 5.0 V. The trimmer is multiturn, so expect a lot of turns before the reading moves much.

In Mokxi the trimmer is the module’s volts property, from 1.23 V to 37 V. Before Run the module’s label shows the setting; while it runs, the volts on OUT+.

Why a buck converter and not a 7805

A 7805 or the Uno’s own regulator gets to 5 V by burning the difference. At 200 mA from 12 V that is (12 - 5) x 0.2 = 1.4 W of heat, and the 200 mA all comes out of the adapter. The LM2596 switches its input on and off 150,000 times a second and an inductor smooths it, so it trades volts for amps instead: 5 V at 200 mA is 1 W, and at about 85 % that is under 100 mA from 12 V.

On the engine, 12 V in and 5 V out into a 1 A load takes about half an amp from the adapter, about 86 % efficient. At 3 A it is about 82 %; TI’s datasheet gives 80 % for the fixed 5 V part. The rest is lost in the switch, the diode and the inductor.

The 5V pin or the barrel jack?

Set to 5 V, the module goes on the 5V pin, which skips the Uno’s regulator altogether. Set to 7 to 9 V, it could go into the barrel jack or VIN instead, and the Uno’s regulator would make the last step to 5 V. On a real board that wastes some of what the buck saved, since the regulator burns the last 2 to 4 V as heat.

Mokxi’s Uno is always powered by its USB and ignores VIN, so the circuit here shows the 5V pin route only. A buck set to 5 V and a 5 V adapter on its input is not enough: the LM2596 needs about a volt across itself, which the next section shows.

Reading the adapter on A0

12 V on A0 would wreck the pin, so the 10k and 4.7k bring it down to 4.7 / 14.7 of the adapter: 3.84 V from 12 V, which analogRead gives as 785 of 1023. The sketch undoes the divider and prints the adapter’s volts, so a battery running down shows up in the serial monitor long before the module drops out.

Read the adapter through the divider
const int SENSE_PIN = A0;
const float DIVIDER = (10000.0 + 4700.0) / 4700.0;  // the 10k and 4.7k

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
  Serial.println("Arduino on 12 V through an LM2596");
}

void loop() {
  int raw = analogRead(SENSE_PIN);  // 0 to 1023 for 0 to 5 V
  float pin = raw * 5.0 / 1023.0;
  float adapter = pin * DIVIDER;

  Serial.print("A0 ");
  Serial.print(raw);
  Serial.print(", adapter ");
  Serial.print(adapter, 1);
  Serial.println(" V");

  digitalWrite(LED_BUILTIN, HIGH);
  delay(500);
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);
}

Its limits: headroom, current and the input range

Headroom. The LM2596 can hold its switch on all the time, so near its input the output follows the input down. Set to 5 V from 5.5 V, it gives about 4.5 V at an amp. For 5 V out, give it 6.5 V or more.

Current. The switch limits at 4.5 A peak, about 4.2 A of average output. Ask for more and the output falls instead: half an ohm on a module set to 12 V from 24 V sits at about 2 V. The board is sold as a 3 A converter, and past 3 A a real one runs hot.

Input. Under 4.5 V in it is off, and the datasheet’s top is 40 V. Most modules have no reverse protection, so the adapter backwards or into OUT+ kills the chip.

What the simulator leaves out: the 150 kHz ripple (the output here is its average, where a real one carries 30 to 60 mV), heat and thermal shutdown, the soft start and the module’s light-load efficiency.

Questions

How do I adjust the LM2596 output voltage?

Turn the brass multiturn trimmer with a meter on OUT+ and OUT-, with the input powered and nothing on the output. Set it before connecting a board. In Mokxi it is the module’s volts property.

Can I power an Arduino with an LM2596?

Yes. Set the module to 5 V and wire OUT+ to the 5V pin and OUT- to GND, or set it to 7 to 9 V and use the barrel jack or VIN. Give the module at least 6.5 V in for 5 V out.

What is the LM2596 current limit?

The switch limits at 4.5 A peak, about 4.2 A of average output. The module is sold as 3 A, and past that a real one needs cooling.

Is an LM2596 better than a 7805?

For a big step it is. From 12 V to 5 V at 1 A it takes about half an amp from the adapter, where a 7805 takes the full amp and turns 7 W into heat. A 7805 is quieter and simpler for small loads.

What input voltage does the LM2596 need?

4.5 V to 40 V, and about a volt more than the output you set. Below 4.5 V it is off.

Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.