Guide no. 17
There are two ways to bring a voltage down: burn off the difference as heat, or “chop it up” with a fast switch. How they work, how hot they get, how much is lost, with the calculations already done.
By Ada Intelisano · informaticait.it technical team
- A linear regulator (7805, AMS1117, LDO) lets through the same current that goes out and turns the extra voltage into heat: simple and quiet, but it wastes a lot when the difference is large.
- A switching regulator (buck, step-down) turns a switch on and off thousands of times per second: it loses little (often 80–90 % efficiency) but leaves a small ripple on the output.
- Rule of thumb: heat in a linear regulator = (Vin − Vout) × current. If it goes above a few tenths of a watt, consider a switching one.
- Every regulator needs a minimum margin between input and output (dropout): a 3.3 V AMS1117 wants at least about 4.6 V.
How a linear regulator works
Inside there is a transistor that acts as an adjustable resistor: it opens or closes as much as needed to hold the output steady. The current going out is (almost) the same as the current coming in, so the “leftover” voltage stays across the regulator and becomes heat. The advantage is a very clean output: the noise of a 7805 is a few tens of microvolts.
How a switching regulator works
Here the transistor is used as a switch: fully on or fully off, so it gets only slightly warm. The ratio between the on time and the period (duty cycle) sets the voltage: to go from 12 to 5 V it stays on about 42 % of the time. The inductor and the capacitor turn the pulses into a DC voltage; the diode (or a second transistor) closes the circuit while the switch is open.
How much is lost: the calculation
For a linear regulator the heat is P = (Vin − Vout) × I + Vin × Iq, where Iq is the current the regulator uses for itself; efficiency is about Vout ÷ Vin. For a switching regulator you start from the stated efficiency: the losses are Pout × (1 ÷ η − 1).
How hot it really gets
The chip temperature is TJ = Tambient + P × θJA, where θJA (in °C/W) is the thermal resistance from the package to the air, given in the datasheet. The limit for the AMS1117 is 125 °C.
Where the heat goes. The TI 7805 datasheet gives input, ground and output on pins 1, 2, 3; the AMS1117 in SOT-223 has its tab connected to the output and gets rid of the heat through the copper on the board.
Linear and switching compared
| Linear (7805, AMS1117, LDO) | Switching (buck) | |
|---|---|---|
| Efficiency | about Vout ÷ Vin: good only with a small difference | usually 80–90 % or more |
| Heat | (Vin − Vout) × I | little: the losses are a small part of the power |
| Output noise | tens of µV (7805: 40 µV; AP2112: 50 µV) | ripple of 0.5–3 % of Vout (LM2596), that is 25–150 mV at 5 V |
| Output higher than input | impossible | possible with step-up converters |
| Components | the regulator and two capacitors | inductor, diode, capacitors, more critical layout |
| No-load current | from 1.6 µA (MCP1700) to 5 mA (AMS1117) | from a few tens of µA to a few mA (LM2596: 5–10 mA) |
Some common regulators (datasheet figures)
| Regulator | Type | Input | Current | Typical dropout | Quiescent current |
|---|---|---|---|---|---|
| AMS1117 | linear | up to 15 V | 1 A | 1.1 V (1.3 V max) at 0.8 A | 5 mA |
| LM7805 | linear | from 7.5 to 35 V | 1.5 A | 2 V at 1 A | 8 mA max |
| MCP1700 | LDO | 2.3–6 V | 250 mA | 178 mV at 250 mA | 1.6 µA |
| AP2112 | LDO | 2.5–6 V | 600 mA | 250 mV at 600 mA | 55 µA |
| LM2596 | buck | up to 40 V | 3 A | ≈1.3 V at 3 A | 5–10 mA |
| XL4015 | buck | 8–36 V | 5 A | — | 2.1 mA |
Which one to choose
- Linear: small difference (5 → 3.3 V), low current (up to a few hundred mA), or when you need a clean output for analog sensors, ADCs and audio.
- LDO with low dropout and low quiescent current (MCP1700, AP2112): from a lithium battery (3.0–4.2 V) to 3.3 V, where the AMS1117 can't cope.
- Switching: from 12 or 24 V down to 5 or 3.3 V, currents of an amp and up, battery projects where every watt counts.
- Both together: a switching regulator that brings the voltage close to the final value, followed by an LDO that cleans up the ripple (this is the solution TI describes for noise-sensitive circuits).
Common mistakes
| What happens | Why | Fix |
|---|---|---|
| The 3.3 V from a lithium battery sags or “wobbles” | AMS1117 powered at 3.7–4.2 V: it needs about 1.1–1.3 V of margin | low-dropout LDO (MCP1700, AP2112) or a buck-boost |
| The 7805 gets very hot and then shuts down | 12 → 5 V at 1 A = 7 W: the thermal protection kicks in | a suitable heat sink, or a switching regulator |
| Unstable analog readings | switching ripple on the supply of the ADC or the sensor | filter or LDO after the switching regulator |
| The battery drains even when idle | regulator with high quiescent current (the AMS1117's 5 mA add up to 120 mAh a day) | low-power LDO |
| Unstable output with almost no load | the AMS1117 needs a minimum load of 10 mA for the stated regulation | minimum load resistor or a different regulator |
| The switching regulator doesn't regulate | input too close to the output (below its dropout) or below the chip's minimum voltage | check the minimum Vin in the module's datasheet |
Useful products
Other guides
- Resistor colour code and tolerances
- N-channel and P-channel MOSFETs
- Bipolar transistor (BJT) or MOSFET?
- Relays: how to drive them and how much current they draw
- THT and SMD/SMT components
- XIAO board pinouts
- LEDs: forward voltage and series resistor
- The multimeter: measuring voltage and current
- Wemos D1 mini: first steps
- MOSFET module with Arduino and ESP32
- Relay module with Arduino and ESP32
- 3D printing filaments: PLA, PETG and fibre-filled versions
- Analog and digital: the differences
- ADS1115: 16-bit converter with Arduino and ESP32
- From bits to real values: converting sensor readings
- DS3231 RTC clock with Arduino and ESP32
- Step-down, step-up and buck-boost: choosing the right module
- Voltage divider: reading voltages higher than 5 V or 3.3 V
- Pull-up, pull-down and bounce: wiring a button properly
- 3.3 V and 5 V logic levels: getting an ESP32 and an Arduino to talk
- The I²C bus: addresses, pull-ups and the scanner
- Lithium batteries: voltages, charging and protection
- ESP32 power consumption and deep sleep: how long the battery lasts
- Temperature sensors compared
- ESP32: which pins to use and which to avoid
- Getting started with the ESP32 in Arduino IDE 2 and PlatformIO
- SSD1306 OLED display and 16×2 I²C LCD with Arduino and ESP32
- PIR motion sensor and HC-SR04 ultrasonic sensor
- Date and time from the Internet with the ESP32: NTP, Italian time zone and daylight saving time
- MicroSD data logger: saving measurements to CSV
- Solar-powered ESP32: panel, charger and the numbers for Italy
- Web server on the ESP32: control a relay from your phone
- Your first LED: wire it up and make it blink
- The button: let Arduino decide
- The potentiometer: turn a knob and read its value
- Soft light: adjusting the brightness of an LED
- The buzzer: playing notes and melodies
- The traffic light: three LEDs in sequence
- The thermometer: reading the temperature with the TMP36
- The servo motor: moving an arm with Arduino
- The night light: the photoresistor and your first decision
- The relay: switching on a light bulb with Arduino
- The LCD display: making Arduino write
- The electronic dice: your first complete project
- The RGB LED: every color from three lights
- The joystick: two-axis control with a shield
- The LED ring: twelve colors from a single pin
- The DC motor: driving it with a MOSFET
- Soil moisture: the plant that asks for water
- The stepper motor: turn exactly as far as you want
- The parking sensor: faster and faster beeps
- The 7-segment display: big, bright numbers
- Automatic watering: the plant that waters itself
- The keypad: a lock with a secret code
- Networked weather station: values and chart on your phone
- A Telegram bot on the ESP32: your home from your phone
- MQTT with the ESP32: the language of connected devices
- Updating the ESP32 over Wi-Fi (OTA)
- ESP-NOW: two ESP32 boards talking without a router
- WebSocket with the ESP32: the LED that follows the slider
- Readings on a Google sheet, with deep sleep
- WiFiManager: choose the Wi-Fi from your phone
- Bluetooth LE with the ESP32: the phone without a network
- The camera in your browser with the ESP32-S3
- A portable Bluetooth speaker you build yourself
- Bluetooth desktop speakers, 2 × 20 W
- Stereo MP3 player with two buttons
- The shelf that plays music: a Visaton exciter
- How to solder well
- How much does it draw? Current and power with the INA219
- Load-cell scale with the HX711
- CO2 traffic light: when to open the windows
- RFID card door opener
- GPS: track logger on microSD
- LoRa: how far does it go? A range test with two boards
- Battery weather sign with an e-paper display
- Web radio with an ESP32 and an I2S amplifier
- Getting started with the Raspberry Pi Pico 2 in MicroPython
- Your first amplifier: the LM386 and a speaker
- Talking Arduino: the DFR0760 speech synthesis module
- The spectrum of your music on an LED matrix
- Drawing with 64 LEDs: the 8×8 matrix with the MAX7219
- A real voltage: the 12-bit MCP4725 DAC
- The heartbeat on Arduino: an ECG with the AD8232