When you define temperature sensor thresholds in your firmware, you aren't just picking arbitrary numbers out of thin air. You are mapping software limits to the physical thermal resistance of your silicon. A sensor reading of 85°C might trigger a panic in your code, but whether that actually destroys your microcontroller depends entirely on the thermal path from the silicon junction to the ambient air. Understanding this path is the difference between a robust embedded design and a board that randomly resets on a hot summer afternoon.
The Physics of Heat: Junction-to-Ambient Thermal Math
To properly manage heat, we must quantify it using thermal resistance ($R_{\theta}$), measured in °C/W. This metric tells you how many degrees the temperature will rise for every watt of power dissipated. The fundamental equation for junction temperature ($T_J$) is:
$T_J = T_A + (P_D \times R_{\theta JA})$
Where $T_A$ is ambient temperature, $P_D$ is power dissipated, and $R_{\theta JA}$ is the junction-to-ambient thermal resistance.
Let’s look at a common embedded bottleneck: an AMS1117-3.3 linear regulator on a custom carrier board dropping a 12V input to 3.3V to feed an ESP32-WROOM-32 and a few peripherals drawing a combined 500mA.
- Power Dissipated ($P_D$): $(12V - 3.3V) \times 0.5A = 4.35W$
- Max Junction Temp ($T_{J(max)}$): 125°C (per the Texas Instruments Application Note SNVA404 on LDO thermal limits)
- Target $T_J$: 100°C (leaving a 25°C safety margin)
- Max Ambient ($T_A$): 50°C (inside a sealed NEMA enclosure in direct sunlight)
Working backward, the maximum allowable thermal resistance for the entire system is:
$R_{\theta JA(max)} = (100°C - 50°C) / 4.35W = 11.49 °C/W$
A standard SOT-223 package without a thermal pad on a 2-layer FR4 board has an $R_{\theta JA}$ of roughly 50 °C/W. At 4.35W, the junction would hit 267°C and literally desolder itself. You must use a PCB copper pour as a heatsink or attach a physical heatsink to survive.
Interpreting the Derating Curve
Every datasheet includes a power derating curve. For the AMS1117, the curve stays flat at 100% max power up to an ambient temperature of 25°C. Beyond 25°C, the allowable power drops linearly, hitting zero watts at 125°C ambient. If your enclosure ambient hits 85°C, the regulator can only safely dissipate about 40% of its nominal max power. If you ignore this curve and define temperature sensor limits based solely on the 125°C absolute max rating, your part will fail long before the silicon melts due to internal bond wire limitations.
Heatsink Selection and Airflow: Sizing for Real-World Loads
When the PCB copper isn't enough, you add a physical heatsink. The total thermal resistance is the sum of three interfaces:
$R_{\theta JA} = R_{\theta JC} + R_{\theta CS} + R_{\theta SA}$
Let's scale up to a TO-220 package LDO (like an LM7805) dissipating 7W (dropping 12V to 5V at 1A). We need an $R_{\theta JA}$ of 8.57 °C/W (assuming 100°C target $T_J$ and 40°C $T_A$).
| Interface | Symbol | Typical Value (°C/W) | Notes |
|---|---|---|---|
| Junction-to-Case | $R_{\theta JC}$ | 2.0 | Fixed by the silicon and package mold compound. |
| Case-to-Sink | $R_{\theta CS}$ | 1.0 | Using a 0.5mm Bergquist Sil-Pad and thermal paste. |
| Sink-to-Ambient | $R_{\theta SA}$ | 5.57 | The maximum rating your heatsink must beat. |
You need a heatsink with an $R_{\theta SA}$ of 5.57 °C/W or lower. A real-world part that fits this bill is the Aavid Thermalloy 577102B03300G, a staggered-fin TO-220 heatsink rated at roughly 4.8 °C/W in natural convection.
Reading the Signs: Thermal Stress Failure Signatures
How hot is too hot for the microcontroller itself? The Espressif ESP32 Hardware Design Guidelines specify an operating ambient range of -40°C to +85°C. But ambient is not junction. When the ESP32 is blasting WiFi at 20dBm, the internal junction can easily sit 20°C to 30°C above ambient.
If you push the thermal envelope, the hardware will tell you it's dying before you ever smell melting plastic. Look for these failure signatures:
- ADC Drift and Sensor Ghosting: The ESP32’s internal SAR ADC is notoriously temperature-sensitive. If your external I2C temperature sensor (like a BME280) reads 45°C, but the ESP32's internal hall/temperature sensor reads 85°C, your PCB layout is trapping heat under the RF shield.
- Brownout Detector (BOD) Resets: As silicon heats up, leakage current increases, causing voltage sag on the 3.3V rail. The ESP32's BOD triggers a reset if the rail dips below ~2.4V. If your serial monitor shows
rst:0xc (SW_CPU_RESET)paired withbrownout detector was triggered, check your regulator's thermal throttle, not just your power supply. - Physical Degradation: Discoloration of the FR4 substrate directly under the SoC, a dull/chalky appearance on the solder mask, or the antenna shield lifting off its pads due to differential thermal expansion.
FAQ: Defining Temperature Sensor Limits in Embedded Systems
How do you define temperature sensor accuracy vs. resolution in embedded code?
Resolution is the smallest step the sensor can report (e.g., a 12-bit ADC over a 3.3V range gives ~0.8mV steps, which might map to 0.08°C on an LM35). Accuracy is how close that reading is to reality (e.g., ±0.5°C). When defining thresholds in your C++ or MicroPython code, never write conditional logic based on the sensor's resolution. If a digital sensor like the TMP102 has a 0.0625°C resolution but a ±2°C accuracy, defining a hard shutdown at exactly 80.00°C is dangerous. Always define your threshold with a hysteresis band that exceeds the sensor's absolute accuracy error (e.g., trigger at 78°C, reset at 74°C).
What is the best way to define temperature sensor thresholds for thermal throttling?
Implement a proportional-integral (PI) control loop rather than a simple bang-bang (on/off) switch. If you define temperature sensor limits as a single tripwire (e.g., "drop CPU clock to 80MHz if temp > 85°C"), the system will rapidly oscillate across that threshold, causing WiFi disconnects and I2C bus lockups. Instead, define a curve: at 70°C, reduce WiFi TX power by 2dB; at 80°C, disable the secondary core; at 90°C, drop the CPU to 80MHz and initiate a graceful peripheral shutdown. This smooths the thermal load and prevents thermal shock to the silicon.
How do I define temperature sensor calibration offsets for PCB self-heating?
If you place an NTC thermistor or a digital sensor (like an SHT31) on the same PCB as a microcontroller or a buck converter, the board's self-heating will skew the ambient reading. To define an accurate offset, run the board in a thermally stable environment (like an insulated box) at room temperature. Log the sensor's reading over 30 minutes until it plateaus. Compare this to a known-good reference thermometer suspended in the air away from the PCB. The difference is your static offset. For dynamic loads, you must define a transfer function in your firmware that subtracts a percentage of the MCU's active power state from the sensor's raw reading.






