When you push high currents through custom Arduino or ESP32 shields—like motor drivers, high-power LED arrays, or 5V linear regulators dropping from a 12V battery—thermal management can no longer be an afterthought. Silicon survives heat, but performance and lifespan do not. To properly size a heatsink for a power component, you must calculate the thermal resistance from junction to ambient, then use an Arduino and temperature sensor setup to log the real-world thermal curve and verify your math on the bench.

This guide walks through the exact thermal path math, component failure signatures, and heatsink selection process, culminating in a complete data-logging script to validate your design before you seal it inside an enclosure.

The Thermal Path: Calculating Junction-to-Ambient Math

Heat flows from the silicon junction inside a chip, through the package case, into a heatsink, and finally into the surrounding air. Each interface resists heat flow, measured in degrees Celsius per Watt (°C/W), denoted as Rθ (R-theta). The fundamental equation for junction temperature (TJ) is:

TJ = TA + PD × (RθJC + RθCS + RθSA)

  • TA: Ambient air temperature (°C)
  • PD: Power dissipated as heat (Watts)
  • RθJC: Junction-to-Case resistance (fixed by the manufacturer)
  • RθCS: Case-to-Sink resistance (depends on thermal paste and mounting pressure)
  • RθSA: Sink-to-Ambient resistance (the heatsink's rating)

Worked Example: Sizing a Heatsink for an L7805CV

Assume you are using an STMicroelectronics L7805CV (TO-220 package) to drop a 12V solar battery down to 5V to power an ESP32 and a few sensors. The ESP32 draws roughly 160mA, and the sensors draw 40mA, totaling 200mA (0.2A). Wait, let's look at a heavier load: a relay board and an LCD drawing 1A total.

Power Dissipated (PD): (12V - 5V) × 1A = 7W.
Ambient (TA): 25°C.
Target TJ: The absolute max is 150°C, but for reliability, we want to keep it under 125°C.

From the datasheet and component catalogs, the TO-220 RθJC is roughly 5°C/W. Using a standard silicone thermal pad or paste, RθCS is about 0.5°C/W. Plugging these into the formula to solve for the required heatsink (RθSA):

125 = 25 + 7 × (5 + 0.5 + RθSA)
100 = 7 × (5.5 + RθSA)
14.28 = 5.5 + RθSA
RθSA ≈ 8.78°C/W

You need a heatsink with a thermal resistance of 8.78°C/W or lower. If you look at the datasheet's Power Dissipation vs. Ambient Temperature derating curve, you'll see a straight line sloping downward. That slope is exactly 1 / RθJA. As your enclosure's ambient temperature rises, the maximum allowable wattage drops linearly. If your box hits 50°C inside, your 7W dissipation will push the junction straight into thermal shutdown.

Component Limits and Failure Signatures of Thermal Stress

How hot is too hot? Silicon physically survives up to 150°C–175°C, but the Arrhenius equation dictates that the operational lifespan of electronics halves for every 10°C increase above 85°C. As a bench rule: if a component case is too hot to keep your finger on (roughly 60°C), it is running at ~80°C internally and needs better airflow or a larger heatsink.

Below is a reference table of common embedded power components, their bare-package thermal limits, and how they actually fail when pushed past their thermal envelope.

Component Type Common Package Max TJ (°C) Typical RθJA (No Heatsink) Thermal Failure Signature
Linear Regulator (L7805) TO-220 150°C 65°C/W Internal thermal shutdown cycling (output drops to 0V, recovers when cool, causing brownouts).
Power MOSFET (IRLZ44N) TO-220 175°C 62°C/W Increased RDS(on) generates more heat, leading to thermal runaway and catastrophic short (magic smoke).
Microcontroller (ESP32-WROOM-32) QFN/SMD 125°C (Silicon) ~30°C/W (Board dependent) WiFi brownouts, severe ADC noise, CPU clock throttling, and flash read errors.
Motor Driver (L298N) Multiwatt15 150°C 35°C/W H-bridge shoot-through, erratic PWM response, and permanent logic-latch failure.

Heatsink Selection and Airflow: What Actually Buys You Headroom

Returning to our 7W L7805 example, we need an RθSA of 8.78°C/W. A bare TO-220 package in free air has an RθJA of 65°C/W, which would result in a junction temperature of 25 + 7(65) = 480°C—instantly destroying the part.

Selecting the Hardware

For natural convection (no fan), a standard extruded aluminum heatsink like the Aavid Thermalloy 577202B03900 (rated at ~7.2°C/W in free air) fits the bill perfectly and costs around $2.50. Apply a thin layer of Arctic Silver thermal compound to keep RθCS under 0.5°C/W, and torque the mounting tab to the datasheet spec (usually around 0.5 Nm) to ensure the air gap is eliminated.

Airflow and Enclosure Changes

If your project requires a sealed IP65 plastic enclosure for outdoor use, you have a problem. The plastic traps heat. If the total power dissipated inside the box is 10W, the internal ambient temperature (TA) will rise until the box's outer surface can shed that heat. In a sealed plastic box, internal ambient can easily reach 45°C to 55°C on a sunny day.

Warning: The IP65 Enclosure Trap
Never calculate heatsink requirements using a 25°C room-temperature ambient if the board is going inside a sealed outdoor box. Recalculate your math using TA = 50°C. To fix this, either bolt the TO-220 directly to the exterior metal chassis using a thermal pad (turning the whole box into a heatsink), or add passive ventilation louvers at the bottom and top of the enclosure to allow chimney-effect airflow.

If you add forced convection—say, a 40mm Noctua NF-A4x10 fan pushing 5 CFM over the Aavid heatsink—the effective RθSA drops by roughly 40% to 50%. That 7.2°C/W heatsink suddenly behaves like a 3.6°C/W heatsink, buying you massive thermal headroom for transient current spikes.

Validating the Math with an Arduino and Temperature Sensor

Math is only as good as your assumptions. Thermal paste application, PCB copper pour, and exact ambient conditions all introduce variables. The most reliable way to verify your thermal design is to wire up an Arduino and temperature sensor to log the heatsink's temperature over time until it reaches thermal equilibrium.

For this, a digital DS18B20 sensor is ideal. It is highly accurate (±0.5°C), immune to analog noise from switching regulators, and its stainless-steel probe can be securely taped directly to the side of the TO-220 case or the heatsink fins using Kapton tape.

Wiring and Validation Code

Wire the DS18B20 VCC to the Arduino's 5V pin, GND to GND, and the Data pin to Digital Pin 2. You must include a 4.7kΩ pull-up resistor between VCC and the Data pin.

The following complete sketch uses the OneWire and DallasTemperature libraries to poll the sensor, handle disconnect faults, and output CSV-formatted data to the serial monitor for easy plotting in Excel or Python.

#include <OneWire.h>
#include <DallasTemperature.h>

// Pin definitions
#define ONE_WIRE_BUS 2
#define STATUS_LED 13

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

unsigned long startTime;

void setup() {
  Serial.begin(115200);
  pinMode(STATUS_LED, OUTPUT);
  sensors.begin();
  
  // Error handling: Verify sensor presence
  if (sensors.getDeviceCount() == 0) {
    Serial.println("FATAL: No DS18B20 sensor found. Check wiring and 4.7k pull-up.");
    while(1) {
      digitalWrite(STATUS_LED, HIGH); delay(100);
      digitalWrite(STATUS_LED, LOW); delay(100);
    }
  }
  
  Serial.println("Time(s),Heatsink_Temp(C)");
  startTime = millis();
}

void loop() {
  sensors.requestTemperatures();
  float tempC = sensors.getTempCByIndex(0);
  
  if (tempC == DEVICE_DISCONNECTED_C) {
    Serial.println("ERROR: Sensor disconnected or read fault.");
  } else {
    float elapsedSec = (millis() - startTime) / 1000.0;
    Serial.print(elapsedSec, 1);
    Serial.print(",");
    Serial.println(tempC);
  }
  
  // Log every 5 seconds to capture the thermal asymptote
  delay(5000);
}

Interpreting the Thermal Curve

Apply your maximum continuous load to the circuit and start the serial plotter. The temperature will rise exponentially and eventually flatten out (asymptote) when the heatsink's heat rejection matches the component's power dissipation.

If your math predicted a case temperature of 70°C, but the Arduino logs show it leveling out at 95°C, your RθCS is likely higher than assumed (too much thermal paste acting as an insulator, or insufficient mounting torque), or the ambient air inside your test enclosure is stagnating. Use this logged data to iterate on your mechanical design before committing to a final PCB layout or production run.