When you move beyond basic room-temperature logging and start using the LM35 temperature sensor with Arduino to validate the thermal management of high-power components, the standard tutorial code falls short. The LM35 is a precision centigrade sensor outputting 10mV/°C, but measuring a hot TO-220 voltage regulator or a power MOSFET requires an understanding of thermal resistance networks, derating curves, and ADC reference stability.

This guide bridges the gap between embedded coding and thermal engineering, showing you exactly how to calculate junction temperatures, select a physical heatsink based on real wattage, and write robust Arduino code to verify your thermal design.

Thermal Path Math and Derating Curves

Every semiconductor has a thermal path from its silicon junction to the surrounding air. To use the LM35 effectively, you must understand what it is actually measuring versus what is happening inside the silicon of the target component. The total thermal resistance is the sum of its segments:

  • $R_{\theta JC}$ (Junction-to-Case): Internal resistance of the silicon and package.
  • $R_{\theta CS}$ (Case-to-Sink): Resistance of the thermal interface material (TIM).
  • $R_{\theta SA}$ (Sink-to-Ambient): Resistance of the heatsink and air boundary layer.

The governing equation for junction temperature ($T_J$) is:

T_J = T_A + (P_D × R_θJA)

Derating Curve Reality Check: Datasheets list a maximum power dissipation (e.g., 15W for a TO-220 LM7805), but this is only valid at a 25°C case temperature. The derating curve slopes downward linearly. Above 25°C, you must derate the allowable power by the reciprocal of $R_{\theta JC}$. If your LM35 reads a case temperature of 80°C, your component can no longer safely dissipate its rated maximum wattage.

Worked Example: Arduino Motor Shield LDO

Assume an Arduino shield uses an LM7805 (TO-220) to drop a 12V battery to 5V, supplying 0.5A to the microcontroller and sensors.

  • Voltage Drop: 12V - 5V = 7V
  • Power Dissipation ($P_D$): 7V × 0.5A = 3.5W
  • Bare $R_{\theta JA}$: ~65°C/W (no heatsink, still air)

Without a heatsink, the temperature rise is 3.5W × 65°C/W = 227.5°C. Added to a 25°C ambient, the junction hits 252.5°C. The part will trigger thermal shutdown at ~150°C long before this, but relying on thermal shutdown as a design feature leads to erratic Arduino resets.

Heatsink Selection and LM35 Placement

We need to select a heatsink that keeps the junction safely below the 125°C continuous limit. Let's target a maximum $T_J$ of 100°C to provide a 25°C safety margin, assuming a worst-case enclosure ambient ($T_A$) of 40°C.

Parameter Value Notes
Allowed Temp Rise ($\Delta T$) 60°C 100°C (Target $T_J$) - 40°C ($T_A$)
Required Total $R_{\theta}$ 17.1°C/W 60°C / 3.5W
$R_{\theta JC}$ (LM7805) 5.0°C/W From TI Datasheet
$R_{\theta CS}$ (Thermal Paste) 1.5°C/W Assumes Arctic Silver or equivalent
Required $R_{\theta SA}$ 10.6°C/W 17.1 - 5.0 - 1.5

The Heatsink Pick: Based on the 10.6°C/W requirement, the Aavid Thermalloy 531202B00000G is an ideal choice. It is a solderable, extruded aluminum TO-220 heatsink rated at approximately 10.4°C/W in natural convection, fitting our wattage basis perfectly.

LM35 Placement Strategy: Do not tape the LM35 to the tips of the heatsink fins. The fins exist to transfer heat to the air; they are cooler than the case. Epoxied the flat face of the LM35 directly to the metal tab of the TO-220 (the case) using a thermally conductive epoxy like 3M TC5022. This allows your Arduino to measure $T_C$ (Case Temperature). You can then calculate the real-time junction temperature in software: T_J = T_C + (P_D × R_θJC).

How Hot is Too Hot? Limits and Failure Signatures

When monitoring high-heat environments, you must also consider the thermal limits of the sensor itself. How hot is too hot for the LM35?

The silicon junction of the LM35 is rated up to 150°C. However, the standard TO-92 plastic package begins to suffer mechanical degradation around 125°C. More critically, if you are embedding the LM35 in a potting compound or thermal epoxy, the Coefficient of Thermal Expansion (CTE) mismatch between the epoxy and the TO-92 plastic will induce physical stress on the silicon die, causing calibration drift long before the silicon melts.

Failure Signatures of Thermal Stress

  • Non-linearity at Extremes: The 10mV/°C slope remains accurate in the middle ranges, but as the package approaches 130°C, you will see the ADC readings compress or drift due to bond-wire fatigue.
  • Epoxied Sensor Delamination: If the LM35 is glued to a heatsink that undergoes rapid thermal cycling (e.g., an Arduino controlling a soldering iron or 3D printer hotend), the epoxy will crack, introducing a massive, variable $R_{\theta CS}$ between the target and the sensor.
  • Self-Heating Errors: The LM35 draws roughly 56µA. In still air, this causes ~0.1°C of self-heating. If you pot the LM35 in a low-thermal-conductivity silicone for waterproofing, that self-heating cannot escape, and the sensor will read 0.5°C to 1.0°C higher than the actual ambient fluid temperature.

Airflow, Enclosures, and Buying Thermal Margin

If your LM35 reports that the case temperature is still too high despite the calculated heatsink, you need to alter the convective boundary layer. The $R_{\theta SA}$ value of 10.4°C/W for the Aavid heatsink assumes natural convection (still air).

What Airflow Buys You: Introducing just 1 meter per second (m/s) of forced air across the fins typically drops the $R_{\theta SA}$ of a stamped or extruded TO-220 heatsink by 40% to 50%. Adding a 40mm fan (like a Noctua NF-A4x10 5V PWM) driven by an Arduino MOSFET will drop our heatsink's effective resistance to roughly 5.5°C/W, slashing the case temperature by an additional 17°C.

Enclosure Changes: If your Arduino and power stage are inside a sealed NEMA enclosure, the "ambient" temperature ($T_A$) is not the room temperature; it is the trapped air inside the box. A 3.5W heat source in a small sealed box will easily raise the internal ambient by 20°C. You must either vent the enclosure, add a filtered exhaust fan, or use an external heatsink where the fins protrude outside the enclosure while the TO-220 body remains inside.

Arduino Implementation: Beating ADC Noise

The default Arduino `analogRead()` uses the 5V USB rail as its reference. USB power is notoriously noisy, often fluctuating between 4.8V and 5.2V. Since the LM35 outputs only 10mV per degree, a 50mV fluctuation on the 5V rail translates to a 5°C jitter in your readings.

To fix this, use the Arduino's internal 1.1V reference. This limits your maximum readable temperature to 110°C (1.1V / 10mV), which is perfect for validating standard electronics thermal margins.

// Precision LM35 Reading using 1.1V Internal Reference
const int lm35Pin = A0;
float tempC = 0.0;

void setup() {
  Serial.begin(115200);
  // Switch to internal 1.1V reference for stable ADC readings
  analogReference(INTERNAL);
  // Allow reference voltage to stabilize
  delay(100); 
}

void loop() {
  long sum = 0;
  // Oversample 32 times to reduce noise floor
  for(int i = 0; i < 32; i++) {
    sum += analogRead(lm35Pin);
  }
  float avgReading = sum / 32.0;
  
  // 1.1V ref / 1024 steps = 1.074mV per step
  // LM35 = 10mV / °C
  tempC = (avgReading * 1.074) / 10.0;
  
  Serial.print("Case Temp: ");
  Serial.print(tempC);
  Serial.println(" °C");
  
  delay(1000);
}

Frequently Asked Questions

Why is my LM35 temperature sensor with Arduino reading wrong values?

The most common cause of a 2°C to 5°C offset is ADC reference instability. If you are powering the Arduino via USB and using the default 5V reference, USB voltage droop will skew the math. Switch to the 1.1V internal reference as shown in the code above. A secondary cause is ground loop current; if the LM35 ground wire shares a long return path with a high-current motor, the voltage drop across the wire will artificially raise the sensor's ground reference, making it read high. Always use a star-ground topology or a dedicated shielded cable for precision analog sensors.

What is the max range when using the LM35 temperature sensor with Arduino?

The LM35 silicon is rated from -55°C to +150°C. However, the standard TO-92 plastic package is practically limited to about 125°C before mechanical degradation and epoxy outgassing occur. If you need to measure up to the full 150°C (for example, monitoring an autoclave or a high-temp 3D printer hotend block), you must source the LM35 in a TO-46 (metal can) or TO-220 package. Additionally, remember that using the Arduino's 1.1V internal reference caps your readable maximum at 110°C unless you add a voltage divider or an op-amp gain stage.

How to optimize LM35 temperature sensor with Arduino wiring for noise?

For runs longer than 10 inches, the high-impedance analog output of the LM35 acts as an antenna for EMI generated by PWM signals and switching regulators. Use a twisted-pair shielded cable (like standard microphone cable). Connect the shield to the Arduino ground at one end only to prevent ground loops. Furthermore, place a 0.1µF ceramic bypass capacitor directly across the VCC and GND pins of the LM35, and add a 100nF capacitor at the Arduino A0 pin to ground to filter high-frequency RF interference before it hits the ADC sample-and-hold circuit.