Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

LM35 with Arduino Uno — 0.1 °C resolution with the 1.1 V reference

Wire an LM35 to an Arduino Uno R3 on A0 and use the internal 1.1 V analog reference for 0.1 °C steps instead of 0.5 °C, with averaging.

Arduino C++Verified — core avr 1.8.8, 3 Nov 2026Compile-only

Community draft — report a mistake

The LM35 is a three-legged analog temperature sensor whose output is simply 10 mV per °C: 285 mV means 28.5 °C. There is no library and no protocol, which makes it a classic first analog sensor in Indian college labs.

On the Uno there is one trick that matters. The ADC divides its reference voltage into 1024 steps. With the default 5 V reference, each step is 4.9 mV — about half a degree, so the reading jumps in 0.5 °C steps. The ATmega328P has an internal 1.1 V reference. Switch to it, and each step becomes about 1 mV, or 0.1 °C, while still covering 0–110 °C.

The sketch switches the reference, throws away the first few readings while it settles, and averages 32 readings for a steady result.

Wiring

Arduino Uno R3Only the pins used are shown · 5 V logicLM35 temperature sensor (TO-92)5VGNDA0+VSVOUTGND
Every connection
Arduino Uno R3LM35 temperature sensor (TO-92)WireNotes
5V+VSredLeft leg, flat face towards you.
A0VOUTyellowMiddle leg. 10 mV per °C.
GNDGNDblackRight leg. Reversing +VS and GND makes the LM35 hot within seconds.

4–30 V (use 5 V) part, 5 V board. The LM35 needs at least 4 V, so power it from 5 V even on ESP32 and Pico. That’s safe: VOUT is only 10 mV/°C (1.5 V at 150 °C), well inside a 3.3 V ADC. Never feed it from 3.3 V.

Board quirks

  • With the default 5 V reference one ADC step is 4.9 mV, or about 0.5 °C. analogReference(INTERNAL) switches the Uno to its 1.1 V reference: about 1.07 mV, or 0.1 °C per step, up to 110 °C.
  • The internal reference is only 1.0–1.2 V from chip to chip. Measure the AREF pin with a multimeter while the sketch runs and put the value in VREF_MV.
  • With the internal reference active, never connect anything to AREF, and remember it applies to every analog pin — a 5 V sensor on A1 will now read 1023.
  • The basic LM35 (LM35DZ) only reads 0 °C and above on a single supply. Fakes are common: if it reads 10 °C off, try another one before blaming the code.
  • On a long cable the LM35 can oscillate. A 75 Ω resistor in series with VOUT and a 1 µF capacitor to GND at the Uno end stops it.

Code

lm35-uno.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// LM35 temperature sensor on an Arduino Uno R3.
// +VS → 5V, VOUT → A0, GND → GND (flat face towards you: +VS, VOUT, GND from left).
// Uses the Uno's internal 1.1 V reference: 1.1 V / 1024 = about 1.07 mV per step,
// so each step is about 0.1 °C instead of 0.5 °C with the 5 V reference.
const uint8_t LM35_PIN = A0;
const float VREF_MV = 1100.0;  // measure your Uno's AREF pin with a meter and put the value here

void setup() {
  analogReference(INTERNAL);  // 1.1 V full scale = up to 110 °C
  Serial.begin(9600);
  for (uint8_t i = 0; i < 5; i++) analogRead(LM35_PIN);  // first readings after a reference change are off
  Serial.println(F("LM35 on A0, 1.1 V reference"));
}

void loop() {
  long sum = 0;
  for (uint8_t i = 0; i < 32; i++) sum += analogRead(LM35_PIN);
  float mv = (sum / 32.0) * VREF_MV / 1024.0;
  float c = mv / 10.0;  // 10 mV per °C
  Serial.print(F("VOUT "));
  Serial.print(mv, 1);
  Serial.print(F(" mV  Temp "));
  Serial.print(c, 1);
  Serial.println(F(" C"));
  delay(1000);
}

Expected serial output

Serial Monitor · 9600Output
LM35 on A0, 1.1 V reference
VOUT 284.6 mV  Temp 28.5 C
VOUT 285.1 mV  Temp 28.5 C

Common errors

Reads about 5× too high or always near 110 °C

The math assumes 1.1 V but the reference is still 5 V (or the other way round). Keep analogReference(INTERNAL) and VREF_MV = 1100 together.

The sensor is too hot to touch

Wired backwards. Unplug at once. With the flat face towards you: +VS, VOUT, GND from left.

Value jumps by a degree

Noise on the wire. Keep the averaging, add 100 nF from VOUT to GND, and keep the wire away from motor and relay wiring.

↑↓ to move · Enter to open