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 temperature sensor with Raspberry Pi Pico — MicroPython ADC wiring

Read an LM35 on a Raspberry Pi Pico: 5 V from VBUS, VOUT straight into ADC0 (GP26) — it is only 10 mV per °C — with averaging and AGND for a steady reading.

MicroPythonVerified — micropython (mpy-cross v1.29.0), 3 Nov 2026Compile-only

Community draft — report a mistake

The LM35 gives a voltage proportional to temperature — 10 mV per degree Celsius — with no calibration and no library. It needs 5 V, which the Pico has on VBUS when it runs from USB, but its output stays far below 3.3 V, so it goes straight into GP26 (ADC0).

The script averages 64 readings for a steady value and prints it next to the RP2040’s built-in temperature sensor.

Wiring

Raspberry Pi PicoOnly the pins used are shown · 3.3 V logicLM35 temperature sensor (TO-92)VBUSAGNDGP26+VSVOUTGND
Every connection
Raspberry Pi PicoLM35 temperature sensor (TO-92)WireNotes
VBUS+VSredVBUS (pin 40), 5 V. The LM35 needs at least 4 V — 3V3 is not enough.
GP26VOUTgreenGP26 = ADC0, physical pin 31. VOUT is 0.25 V at 25 °C and 1.5 V at 150 °C — no divider needed.
AGNDGNDblackAGND (pin 33) is the analog ground beside the ADC pins.

4–30 V (use 5 V) part, 3.3 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

  • This is the one 5 V-powered sensor you can wire straight to a Pico ADC pin: its output is only 10 mV per °C, far below 3.3 V.
  • One ADC step is about 0.8 mV, i.e. 0.08 °C, but the RP2040 ADC is noisy — the script averages 64 readings. Using AGND rather than a digital GND helps too.
  • Hold it by the flat face towards you, legs down: +VS, VOUT, GND from left to right. Wired backwards it gets hot within seconds.
  • The script also prints the RP2040’s own temperature sensor (ADC(4)) — expect it a few degrees higher, since it measures the chip.

Code

main.pyMicroPython
# LM35 analog temperature sensor on a Raspberry Pi Pico (MicroPython).
# Wiring: +VS -> VBUS (pin 40, 5 V - the LM35 needs at least 4 V), VOUT -> GP26 / ADC0 (pin 31),
# GND -> AGND (pin 33). VOUT is only 10 mV per C (0.25 V at 25 C), so it is safe for the ADC.
from machine import ADC, Pin
import time

lm35 = ADC(26)
chip = ADC(4)           # RP2040 internal sensor, for comparison
led = Pin(25, Pin.OUT)


def lm35_c(n=64):
    raw = sum(lm35.read_u16() for _ in range(n)) / n  # heavy averaging: each ADC step is ~0.08 C
    return raw * 3.3 / 65535 * 100                    # 10 mV per C


def chip_c():
    return 27 - (chip.read_u16() * 3.3 / 65535 - 0.706) / 0.001721


print("LM35 on GP26")
while True:
    t = lm35_c()
    led.value(t > 40)  # LED on above 40 C
    print("LM35 {:.1f} C   (RP2040 chip {:.1f} C)".format(t, chip_c()))
    time.sleep(1)

Expected serial output

REPL / Thonny shellOutput
LM35 on GP26
LM35 28.4 C   (RP2040 chip 31.2 C)
LM35 28.5 C   (RP2040 chip 31.2 C)

Common errors

Reads a few degrees too high or too low

The RP2040 ADC has an offset error at low voltages. Compare with a known thermometer once and add a fixed correction in code.

Sensor gets hot, reading nonsense

It is in back to front. Unplug it at once and check the pin order (flat face towards you: +VS, VOUT, GND).

↑↓ to move · Enter to open