Skip to content

Voltage Regulator · Espressif ESP32 guide

Using LM2596 Buck Converter Module with Espressif ESP32

Adjustable buck converter for efficiently stepping down higher voltages to project logic levels.

Updated November 16, 2026 Arduino C++Also forArduino Uno

What is the LM2596?

Most maker projects run on 5 V or 3.3 V, but the power you actually have is often a 9 V or 12 V adapter, a car battery or a multi-cell pack. A linear regulator such as the 7805 or AMS1117 can bring that voltage down, but it does it by turning the difference into heat. Drop 12 V to 5 V at 1 A with a linear regulator and it has to get rid of 7 W, enough to burn a finger and shut the regulator down.

The LM2596 is a switching step-down (buck) regulator from Texas Instruments. Instead of burning off the extra voltage, it switches the input on and off 150,000 times a second and smooths the result with an inductor and capacitors, so most of the input power reaches your circuit. The familiar blue LM2596 module puts the IC, inductor, Schottky diode, capacitors and a multi-turn trimmer on one small board, giving you an adjustable supply you can set to exactly the voltage your project needs.

LM2596 in one paragraph. A 150 kHz buck regulator: 4.5–40 V in, output adjustable from about 1.23 V up to roughly 2 V below the input, rated 3 A by the IC. On a bare module, plan on about 2 A continuous unless you add cooling. Set the output with a multimeter before you connect anything, keep the input below the voltage printed on the module's input capacitor, and never reverse the input wires: most modules have no reverse-polarity protection.

Specifications

Regulator type
Step-down (buck) switching regulator with integrated power switch
Input voltage (IC)
4.5 V to 40 V
Input voltage (module)
Limited by the input capacitor rating printed on it (often 35 V or 50 V)
Output voltage
Adjustable 1.23 V to 37 V (IC); in practice at least ~2 V below the input at full load
Output current
3 A (IC rating); about 2 A continuous is a safe plan on a bare module
Switching frequency
150 kHz fixed (127–173 kHz across temperature)
Feedback reference
1.230 V typical (1.193–1.267 V over line and load)
Output tolerance
±4 % maximum over line and load (adjustable version)
Efficiency (datasheet typicals, 3 A)
73 % at 12 V → 3 V · 80 % at 12 V → 5 V · 90 % at 25 V → 12 V
Switch saturation voltage
1.16 V typical at 3 A
Shutdown current
80 µA typical with the ON/OFF pin pulled high
Protection
Thermal shutdown and current limit
Operating junction temperature
−40 °C to +125 °C

IC figures from the Texas Instruments LM2596 datasheet (SNVS124). Module limits depend on the capacitors and inductor each maker fits, so check the parts on yours.

Pinout

PinNameDescription
IN+Input +Positive input from your adapter or battery, 4.5–40 V (and below the input capacitor rating).
IN−Input −Input ground. Joined to OUT− on the module.
OUT+Output +Regulated, adjustable output. Set it with the trimmer before connecting a load.
OUT−Output −Output ground. Connect to your board's GND.
TrimmerAdjustMulti-turn potentiometer that sets the output voltage through the feedback divider.

IN− and OUT− are the same ground. The LM2596 is a non-isolated converter: the negative input and negative output are connected on the board. That is what you want for most projects, but it means the module cannot be used to "float" one circuit away from another.

LM2596 IC pins (TO-263-5)

PinNameFunction
1VINInput supply. Needs a low-ESR input capacitor close to the pin.
2OUTPUTSwitch output. Drives the inductor and the Schottky catch diode.
3GNDGround.
4FEEDBACKSenses the output through a resistor divider; regulates it to 1.23 V.
5ON/OFFPull low (or to ground) to run, high to shut down. Tied to ground on most modules.

How a buck converter works

Inside the LM2596 is a power transistor that switches the input on and off at a fixed 150 kHz. While the switch is on, current flows from the input through the inductor into the load, and the inductor stores energy in its magnetic field. When the switch turns off, the inductor keeps the current flowing, now through the Schottky diode. The output capacitor smooths the small ripple left behind.

The output voltage depends on how long the switch stays on in each cycle, called the duty cycle. In an ideal buck converter, Vout ≈ Vin × duty cycle. The IC compares a fraction of the output against its internal 1.23 V reference and adjusts the duty cycle continuously, so the output stays steady when the input voltage or the load current changes.

Because the transistor is either fully on or fully off, it wastes very little power compared with a linear regulator, which always sits partly on and drops the whole difference across itself.

Setting the output voltage

The feedback pin regulates to 1.23 V. The module divides the output with a fixed resistor (R1) and the trimmer (R2), so:

Vout = 1.23 V × (1 + R2 / R1)

You never need to calculate this on a module; you turn the trimmer and watch a meter. It does explain two things beginners notice: the output can never go below about 1.23 V, and the trimmer is very sensitive near the top of its range.

Brand-new modules can ship set to any voltage, sometimes close to the input. Connecting a fresh module straight to a 3.3 V board is one of the fastest ways to destroy it.

  1. 1Connect your supply (for example a 12 V adapter) to IN+ and IN−. Leave the output disconnected.
  2. 2Put a multimeter on OUT+ and OUT−, set to DC volts.
  3. 3Turn the brass screw on the trimmer slowly. It is a multi-turn part, so it can take ten or more turns before the reading starts to move. The direction that raises the voltage varies between modules: watch the meter, not the screw.
  4. 4Set the target slightly high: about 5.1 V for a 5 V rail, 3.35 V for a 3.3 V rail. Wires and connectors drop a little under load.
  5. 5Connect a test load (a resistor or the actual circuit without the microcontroller) and check the voltage again.
  6. 6Only now connect your board. A dab of nail varnish on the trimmer stops vibration from moving it later.

Headroom: why 6 V in will not give you 5 V out

A buck converter can only step down, and it needs some headroom. At 3 A the LM2596's internal switch drops about 1.16 V on its own, and the inductor, diode and wiring add more. The datasheet tests its 5 V version with inputs from 7 V upwards at full load. As a rule, keep the input at least 2 V above the output for currents near the limit. At light loads you can get closer, but the output will start to sag as the battery runs down.

This matters for battery projects. Two Li-ion cells (8.4 V full, about 6 V empty) can run a 5 V buck for most of their charge, but the output will droop near the end. Three cells give plenty of margin.

Heat and the real current limit

The IC is rated for 3 A, but a small module has no heatsink and little copper to spread heat. The loss in the converter is:

Power lost = Pout ÷ efficiency − Pout

For 12 V in, 5 V out at 2 A: Pout = 10 W. At about 80 % efficiency the module draws 12.5 W, so 2.5 W is turned into heat on a board the size of a matchbox. A linear regulator doing the same job would waste (12 − 5) × 2 = 14 W.

2.5 W is manageable, but the IC and inductor will run hot. Above about 2 A continuous, add a small heatsink or airflow, and touch-test the IC after ten minutes at full load. If it is too hot to keep a finger on, you are close to thermal shutdown, and the module will start cycling on and off.

Efficiency also falls at low output voltages. At 12 V → 3.3 V, the fixed losses in the diode and switch are a bigger share of the small output, so expect efficiency in the low 70s rather than the 80s.

Ripple and noise

A buck converter's output is not perfectly flat. There is a small ripple at the 150 kHz switching frequency plus fast spikes on every switching edge. Digital circuits such as an Arduino, ESP32 or servo do not care. Sensitive circuits do:

  • Analog sensors and ADC readings may show a few counts of jitter. Average several readings, or add an LC filter (a small inductor plus capacitor) after the module.
  • Audio amplifiers and microphones can pick up a whine. Follow the buck with a low-noise LDO set about 1 V lower, so the LDO wastes very little power but removes the ripple.
  • Long output wires act as antennas. Keep the input and output leads short and twisted together.

LM2596 and its alternatives

PartTypeInputOutput currentBest for
LM2596 moduleBuck, 150 kHz4.5–40 V3 A (IC), ~2 A bare moduleGeneral 12 V → 5 V or 3.3 V rails
LM2596HV (second-source)Buck, 150 kHzUp to 60 V3 A24 V and 36–48 V systems
MP1584 moduleBuck, up to 1.5 MHz4.5–28 VUp to 3 ATiny builds, drones, tight spaces
XL4015 moduleBuck, 180 kHz8–36 VUp to 5 AHigher-current loads, LED drivers (CC/CV versions)
7805 / AMS1117Linear7805: 7–35 V · AMS1117: up to 15 VUnder 1 ALow current, very quiet supply, small voltage drop
MT3608 moduleBoost2–24 VAbout 1 A at 5 VRaising voltage, for example one Li-ion cell to 5 V

Choose by input range, current and noise. Module current ratings assume good cooling; derate for small boards in enclosures.

Ready to build?

  • LM2596 with Arduino Uno: power the Uno from a 12 V adapter through its 5 V pin and monitor the rail with the ADC.
  • LM2596 with ESP32: a clean 5 V supply for an ESP32 project, with a divider to measure the output safely.

Troubleshooting

SymptomLikely causeFix
Output is far too high, close to the inputTrimmer set high from the factory, or input too close to the outputSet the voltage with a meter before connecting; keep the input at least 2 V above the output
Turning the trimmer changes nothingMulti-turn trimmer at the end of its range, or input below the target outputKeep turning (10+ turns); check the input voltage under load
Output collapses when the load startsWeak adapter, thin wires, or a motor inrushUse a supply rated above the load, thicker wires, and a 470–1000 µF capacitor on the output
Module very hot, output cycling on and offRunning near 3 A without cooling (thermal shutdown)Reduce load, add a heatsink or airflow, or use an XL4015-class module
Board resets when a motor or servo movesShared rail sagging, switching noiseSeparate motor and logic supplies, bulk capacitor at the motor, common ground
ADC readings jitter150 kHz ripple on the analog supplyAverage readings, add an LC filter or an LDO after the buck
Module dead after connecting the batteryReverse polarity: most modules have no protectionAdd a series Schottky diode or a P-MOSFET reverse-protection circuit

What to build with it

  • 12 V to 5 V supply for an Arduino or ESP32 project in a car, van or workshop.
  • Battery-powered robot running motors from a 3S Li-ion pack and the logic from a 5 V buck.
  • Adjustable bench supply with a voltmeter display on the output.
  • Raspberry Pi in a vehicle, set to 5.1 V with thick, short output wires (a Pi 4 or 5 needs a supply that can deliver its full current without sagging).
  • Solar sensor node that steps a 12 V panel battery down to 5 V for the electronics.

Frequently asked questions

Can I feed the Arduino Uno's 5V pin from an LM2596? Yes, set it to 5.0–5.1 V first. This bypasses the Uno's own regulator, so nothing protects the board if the output is wrong. Avoid having USB and the external 5 V connected at the same time unless you understand your board's power path.

Is the LM2596 a battery charger? No. The basic module only regulates voltage; it has no current limit you can set. Use a dedicated charger such as a TP4056 for Li-ion cells, or a CC/CV buck module for lead-acid charging.

Why does my module get warm with nothing connected? A little warmth at no load is normal: the controller and switch keep running. Noticeable heat with no load usually means a faulty module or an input above its rating.

LM2596 or MP1584? The LM2596 handles up to 40 V and is easier to cool. The MP1584 is much smaller and switches faster, but its input stops at 28 V and its tiny board heats up quickly near 3 A.

Is the LM2596 still a good choice? It is an old design, but robust, cheap and well understood. Newer synchronous bucks are more efficient, especially at low output voltages, so consider one for battery projects where every percent counts.

Datasheets and references

  • Texas Instruments LM2596 datasheet (SNVS124): input range, feedback reference, efficiency, saturation voltage and switching-frequency figures used on this page.
  • Texas Instruments LM2596 product page: pin functions and application circuit.

Wiring & code

Setting up LM2596 with Espressif ESP32

Wiring

  • IN+ / IN-Higher-voltage source (e.g. 12V adapter, multi-cell pack)

    Note
    Not connected to the ESP32
  • OUT+5V / VIN pin

    Note
    Trim to ~5.0-5.2V under load before connecting
  • OUT-GND

sketch.ino
const int MONITOR_PIN = 34;
const float DIVIDER_RATIO = 2.0;

void setup() {
  Serial.begin(115200);
  analogReadResolution(12);
  analogSetAttenuation(ADC_11db);
}

void loop() {
  int raw = analogRead(MONITOR_PIN);
  float pinVoltage = (raw / 4095.0) * 3.3;
  float outputVoltage = pinVoltage * DIVIDER_RATIO;
  Serial.print("LM2596 output: ");
  Serial.print(outputVoltage, 2);
  Serial.println(" V");
  delay(300);
}
  • Same efficiency argument as the Arduino Uno: dropping 12V+ down to 5V with the LM2596 wastes far less heat than relying on the board's own onboard regulator from VIN.
  • Same calibrate-then-connect workflow as the boost converter — verify with this sketch on a separately-powered ESP32 first.
  • If you'd rather feed 3V3 directly and skip the board's onboard regulator, you can trim to ~3.3V instead — just don't feed both 5V and 3V3 at once, since that puts two regulators fighting each other.

Keep learning

Related guides & projects