Projects / Pico two-sensor thermometer comparison

Pico two-sensor thermometer comparison

Beginner2.2 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. PICO

    Identify the pins

    Flat face towards you, legs down: +Vs, Vout, GND from the left.

  2. PICOLM3525.5°C

    Wire the LM35

    +Vs to VBUS, Vout to GP26, GND to GND.

  3. PICOTMP3625.5°C

    Wire the TMP36

    +Vs to 3V3(OUT), Vout to GP27, GND to GND.

  4. PICO14.0 mASSD1306

    Wire the OLED

    3V3(OUT), GND, SDA to GP0, SCL to GP1.

  5. PICO14.1 mASSD1306

    Install the ssd1306 module

    Using Thonny packages.

  6. PICOLM35TMP3625.6°C

    Run the program

    Both temperatures and the difference appear.

  7. PICO

    Pinch both sensors together

    Both rise by a few degrees.

In short

How do you build a pico two-sensor thermometer comparison?

A Pico reads an LM35 and a TMP36 side by side and shows both temperatures and the difference on an OLED, to learn about sensor accuracy. You need Raspberry Pi Pico H, LM35 temperature sensor, TMP36 temperature sensor, SSD1306 OLED Display and Breadboard 830 Tie Points. It takes 7 steps and about 130 minutes.

Level
Beginner
Time
About 130 min
Parts
5

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
LM35 pin 1 (+Vs)Pico VBUS pin 40The LM35 needs at least 4 V, so it uses the 5 V pin
LM35 pin 2 (Vout)Pico GP26 pin 31ADC0, 10 millivolts per degree
LM35 pin 3 (GND)Pico GND pin 38Common ground
TMP36 pin 1 (+Vs)Pico 3V3(OUT) pin 36Power at 3.3 V
TMP36 pin 2 (Vout)Pico GP27 pin 32ADC1, 500 millivolt offset
TMP36 pin 3 (GND)Pico GND pin 38Common ground
OLED VCC and GNDPico 3V3(OUT) pin 36 and GND pin 3Power at 3.3 V
OLED SDA and SCLPico GP0 pin 1 and GP1 pin 2I2C data and clock

Code

Both of these chips turn temperature into a voltage that rises by 10 millivolts for every degree Celsius. The LM35 gives 0 volts at 0 degrees, so at 25 degrees it gives 250 millivolts. The TMP36 adds an offset of 500 millivolts so that it can also report below zero, which means it gives 750 millivolts at 25 degrees. The program reads each voltage with the Pico's analog converter, averages 64 readings to calm the noise, and applies the right formula for each chip. The LM35 needs a supply of at least 4 volts, so it is powered from the 5 volt pin, while the TMP36 works from 3.3 volts. Neither is exact: each has a stated accuracy of about half a degree or a degree, and the Pico's converter adds a little error of its own, especially at the low voltage of the LM35. Hold both sensors together between your fingers and watch how they differ, and try ice water as a check at 0 degrees.

import time
from machine import Pin, I2C, ADC
from ssd1306 import SSD1306_I2C

i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
lm35 = ADC(26)
tmp36 = ADC(27)

def millivolts(adc):
    total = 0
    for _ in range(64):
        total += adc.read_u16()
    return (total / 64) * 3300 / 65535              # average to reduce noise

while True:
    t_lm = millivolts(lm35) / 10.0                  # 10 mV per degree, zero at 0 C
    t_tmp = (millivolts(tmp36) - 500) / 10.0        # 10 mV per degree, 500 mV at 0 C
    oled.fill(0)
    oled.text("LM35  %.1f C" % t_lm, 0, 4)
    oled.text("TMP36 %.1f C" % t_tmp, 0, 22)
    oled.text("Diff  %.1f C" % (t_lm - t_tmp), 0, 40)
    oled.show()
    time.sleep_ms(500)

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Both in room airWithin about 2 degrees of each other
Pinched between fingersBoth rise together
Held in ice water, sealed in a bagBoth fall towards 0 degrees
Blow on themBoth fall a little
DifferenceStays within a degree or two

If it does not work

Reads very hot or very cold

Check the chips are the right way round, a reversed sensor gets hot.

LM35 reads wrong

Check it has 5 V on VBUS, not 3.3 V.

Both read low

Check the pin order and the wire to the ADC pin.

Difference is large

Let both settle for a minute and keep them together.

Nothing on the display

Check the I2C wires and the address 0x3C.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the pico two-sensor thermometer comparison?

Raspberry Pi Pico H, LM35 temperature sensor, TMP36 temperature sensor, SSD1306 OLED Display and Breadboard 830 Tie Points.

How long does the pico two-sensor thermometer comparison take to build?

About 130 minutes for a beginner maker, in 7 steps.

How do I know the pico two-sensor thermometer comparison works?

Both in room air: Within about 2 degrees of each other. Pinched between fingers: Both rise together. Held in ice water, sealed in a bag: Both fall towards 0 degrees.

Reads very hot or very cold: what should I check?

Check the chips are the right way round, a reversed sensor gets hot.

LM35 reads wrong: what should I check?

Check it has 5 V on VBUS, not 3.3 V.

Both read low: what should I check?

Check the pin order and the wire to the ADC pin.

Difference is large: what should I check?

Let both settle for a minute and keep them together.