Skip to content
Tutorials Center
My learning

Topics

Lesson 9 of 37 ยท Setup and OS

Power, Cooling and Safe Shutdown

Power your Raspberry Pi correctly, read its temperature and throttling flags with vcgencmd, add cooling, and shut down safely to protect the SD card.

A Raspberry Pi does not have a power switch on most models, and it has no battery that protects it when the power goes away. Two things decide whether your board is reliable for months: a clean power supply and sensible temperatures. This lesson covers how a Pi draws power, how to read its health from the command line, and how to switch it off without damaging the file system.

Power basics

A Pi is powered with 5 volts. The current it needs depends on the model and on what is attached to it:

Model Recommended supply Typical idle draw
Pi 5 5 V 5 A (27 W) USB-C PD about 3 W
Pi 4 B 5 V 3 A USB-C about 3 W
Pi 3 B+ 5 V 2.5 A micro-USB about 2 W
Zero 2 W 5 V 2.5 A micro-USB about 1 W

Draw rises when the CPU is busy, when Wi-Fi sends data and when you plug in USB devices such as an SSD or a camera. If the voltage drops below about 4.63 V the Pi reports an under-voltage event. Symptoms are random reboots, a lightning-bolt icon on the desktop, a flaky keyboard and a corrupted card. The fix is a better supply and a shorter, thicker cable.

You can also power the board from the GPIO header: pins 2 and 4 take 5 V, and pin 6 is ground. This bypasses the board's protection circuits, so use it only with a regulated supply you trust. For a battery, use a proper UPS HAT or a power bank that supports pass-through charging and 5 V output.

Temperature and throttling

Under heavy load the processor can reach 80 degrees Celsius. To protect itself the firmware throttles: it lowers the clock speed. At around 85 degrees it reduces it even more. You can read the temperature and the throttling flags with vcgencmd, a tool that talks to the firmware (read-only examples):

Terminal
vcgencmd measure_temp        # temp=48.3'C
vcgencmd get_throttled       # throttled=0x0
cat /sys/class/thermal/thermal_zone0/temp   # 48312 (thousandths of a degree)
vcgencmd measure_volts core

get_throttled returns a hexadecimal number where each bit has a meaning. 0x0 is perfect.

Bit Meaning
0 Under-voltage right now
1 Arm frequency capped now
2 Currently throttled
3 Soft temperature limit active
16 Under-voltage has occurred since boot
17 Frequency capping has occurred
18 Throttling has occurred
19 Soft temperature limit has occurred

Keep it cool and powered

Clean power Right amps, short cable
Check the temperature vcgencmd measure_temp
1 / 2

Decoding the throttle flags

This stand-in decodes a get_throttled value into plain English, just like a monitoring script would.

Python Stand-in: decode throttled flags

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Reading a temperature

The kernel reports the temperature in thousandths of a degree. This stand-in converts it and flags a warm board.

Python Stand-in: temperature check

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Cooling

A passive heatsink (a small block of aluminum stuck on the SoC) lowers temperatures by several degrees and costs very little. A fan or the official Pi 5 active cooler lets the board hold its full speed under constant load. Cases with metal bodies can act as big heatsinks. Do not wrap the board in foam or place it in a closed box without airflow. The Pi 5 has a fan connector, and raspi-config (Performance Options) lets you set the temperature at which the fan turns on.

Shutting down safely

Linux keeps recent writes in memory and flushes them to the card later. If you pull the plug while that is happening, the file system can be corrupted. Always shut down first:

Terminal
sudo shutdown -h now      # halt and power down
sudo reboot               # restart
sudo shutdown -h +10      # halt in ten minutes

Wait until the green activity LED stops blinking before you remove power. On the desktop use the Shutdown option in the main menu. The Pi 5 has a small power button: a short press starts it, a press while running triggers a clean shutdown.

For permanent installs where power can fail (a weather station on a shed roof, say), consider a UPS HAT, a read-only root file system, or an SSD, which survives abrupt power loss much better than a card.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a throttled value of 0x0 from vcgencmd get_throttled mean?

    All flag bits are zero: no under-voltage, capping or throttling.
  2. 2. Why shut down with 'sudo shutdown -h now' instead of pulling the plug?

    Pending writes are flushed during a clean shutdown.
  3. 3. Which is the most common sign of a weak power supply?

    Voltage drops below the safe level and cause warnings, reboots and corruption.
  4. 4. What does the firmware do when the CPU gets too hot?

    Throttling reduces the CPU frequency to protect the chip.

Summary

  • Use the recommended supply for your model, with a short, thick cable.
  • vcgencmd measure_temp and get_throttled report temperature and power health.
  • A heatsink or fan keeps the board at full speed.
  • Always shut down with sudo shutdown -h now and wait for the LED to stop.

Next: GPIO Basics and Pin Numbering