Stop Your Raspberry Pi from Overheating in a Closed Case

🏠 Part of: Home Repair & Maintenance
Stop Your Raspberry Pi from Overheating in a Closed Case

A Raspberry Pi inside a sealed 3D-printed box will happily hit 85 °C under load, throttle itself to 600 MHz, and feel "slow" without ever crashing. The fix is not a bigger heatsink — it is understanding airflow, thermal mass and the throttle flags the Pi already reports.

How to know you are throttling

Before touching the hardware, read the two values every Pi exposes:

vcgencmd measure_temp
vcgencmd get_throttled

The temperature is in °C. The throttle value is a bitmask:

  • 0x0 — no throttling, no undervoltage.
  • 0x1 — currently undervolted.
  • 0x2 — currently ARM frequency capped.
  • 0x4 — currently throttled.
  • 0x10000 — undervoltage has occurred since boot.
  • 0x40000 — throttling has occurred since boot.

If you see 0x50005 or similar, the Pi is being limited by both heat and power. Fix the power supply first, then the cooling.

Why sealed cases fail

Air inside a closed box heats up within minutes and then has nowhere to go. The heatsink inside is surrounded by hot air, so it cannot shed heat. The result is a thermal equilibrium that is 15–25 °C above ambient. A plastic case with no vents will always lose to a bare board on a desk.

Passive cooling that actually works

If you cannot or do not want a fan, use these three rules:

  • Vent low and high. Hot air rises. Put intake slots at the bottom edge and exhaust slots at the top edge so convection can move air through the case.
  • Metal case, not plastic. An aluminium case acts as a large heatsink. A plastic case acts as an insulator.
  • Thermal pad on the SoC, RAM and (on Pi 5) the PMIC. A single pad over one chip leaves the neighbours hot.

A well-vented aluminium case with a thermal pad will hold a Pi 4 under 70 °C at idle and around 78 °C under sustained CPU load — good enough for most home servers.

Adding a fan with a proper curve

A 5 V fan wired straight to the GPIO header runs at full speed all the time and is noisy. Wire it through a transistor or use a PWM fan, then control it from a small script:

#!/usr/bin/env python3
import subprocess, time, re

FAN_PIN = 14  # BCM
TEMP_ON  = 55
TEMP_OFF = 45

def temp():
    out = subprocess.check_output(["vcgencmd", "measure_temp"]).decode()
    return float(re.search(r"(\d+\.\d+)", out).group(1))

# configure PWM once (using pigpio or sysfs)
import os
os.system("sudo pigpiod")
import pigpio
pi = pigpio.pi()

state = False
while True:
    t = temp()
    if t >= TEMP_ON and not state:
        pi.set_PWM_dutycycle(FAN_PIN, 255)  # full speed
        state = True
    elif t <= TEMP_OFF and state:
        pi.set_PWM_dutycycle(FAN_PIN, 0)
        state = False
    time.sleep(5)

This keeps the fan off below 45 °C and running below 55 °C, so it is silent most of the time. A 40 mm fan at 30% PWM is inaudible from one metre.

Undervoltage looks like overheating

Many users replace the heatsink when the real problem is the power supply. A phone charger rated 5 V / 2 A may sag to 4.6 V under load, and the Pi will throttle to protect itself. Check with:

vcgencmd get_throttled

If the undervoltage bit is set, switch to the official 5.1 V 3 A (Pi 4) or 5.1 V 5 A (Pi 5) supply, or use a good quality USB-C PD supply with a 5 V profile. Cheap cables with thin wires are also a common cause — look for 20 AWG or thicker.

Where to place the case

  • Never on top of a router, NAS or amplifier — those radiate heat.
  • Never inside a closed cabinet with other electronics.
  • Keep at least 5 cm of free space on all sides for airflow.
  • Vertical orientation helps convection if the vents are on the top and bottom.

Real temperature comparison

  • Bare board, 25 °C room: 62 °C under load.
  • Sealed plastic case: 84 °C, throttling.
  • Vented plastic case: 76 °C.
  • Aluminium case with pad: 70 °C.
  • Aluminium case + 40 mm fan at 30%: 52 °C.

That last configuration costs less than €15 and turns a throttling Pi into a silent, cool one.

Summary

Read get_throttled before you buy anything. Vent the case low and high, use an aluminium body and a proper thermal pad, and add a PWM fan with a 45–55 °C curve if you need sustained performance. Fix undervoltage before chasing temperatures — they often share the same root cause.

Comments