Pico temperature logger with a probe
Build it step by step
0 of 7 doneWire the probe
Red to 3V3(OUT), black to GND, yellow to GP15.
Add the pull-up
4.7 kilo-ohm from GP15 to 3V3(OUT).
Wire the display
SDA to GP0, SCL to GP1, power at 3.3 V.
Install the ssd1306 module
Using Thonny packages.
Save the program as main.py
On the Pico.
Run it
A temperature appears.
Dip the probe in cold and warm water
Watch the minimum and maximum.
How do you build a pico temperature logger with a probe?
A Pico reads a DS18B20 probe with MicroPython and shows the value and the lowest and highest readings on an OLED. You need Raspberry Pi Pico H, DS18B20 waterproof probe, Resistor 4.7 kΩ, SSD1306 OLED Display and Breadboard 830 Tie Points. It takes 7 steps and about 140 minutes.
- Level
- Intermediate
- Time
- About 140 min
- Parts
- 5
Parts list
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| DS18B20 red | Pico 3V3(OUT) pin 36 | Power at 3.3 V |
| DS18B20 black | Pico GND pin 38 | Ground |
| DS18B20 yellow | Pico GP15 pin 20 | One-wire data |
| 4.7 kilo-ohm resistor | Between GP15 and 3V3(OUT) | Pull-up for the data line |
| OLED VCC and GND | Pico 3V3(OUT) and GND | Power at 3.3 V |
| OLED SDA and SCL | Pico GP0 pin 1 and GP1 pin 2 | I2C data and clock |
Code
The DS18B20 is a digital probe that sends its reading as a number over one data wire, and MicroPython has built-in modules to talk to it. The data line must be pulled up to 3.3 V by a 4.7 kilo-ohm resistor, since the probe only pulls the line low. The program scans the bus for the probe address, then in a loop asks for a conversion, waits 750 milliseconds for it to finish and reads the result. The lowest and highest values since start are kept and shown, which is handy for a fridge, a room overnight or a cup of tea going cold. The values are also printed, so you can copy them from the Thonny shell into a spreadsheet. Readings are indicative only: a probe in air follows the temperature slowly, and its metal tip must touch whatever you are measuring. Do not use it for food safety or medical decisions.
import time
import onewire, ds18x20
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
ds = ds18x20.DS18X20(onewire.OneWire(Pin(15)))
roms = ds.scan()
if not roms:
oled.text("No probe found", 0, 0)
oled.show()
raise SystemExit
lowest, highest = 1000.0, -1000.0
while True:
ds.convert_temp()
time.sleep_ms(750) # 12-bit conversion takes up to 750 ms
t = ds.read_temp(roms[0])
lowest = min(lowest, t)
highest = max(highest, t)
oled.fill(0)
oled.text("DS18B20 logger", 0, 0)
oled.text("Now: {:.1f} C".format(t), 0, 20)
oled.text("Min: {:.1f} C".format(lowest), 0, 36)
oled.text("Max: {:.1f} C".format(highest), 0, 48)
oled.show()
print("{:.2f}".format(t)) # also readable in the Thonny shell
time.sleep(1)Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Probe in air | Room temperature that settles slowly |
| Probe in cold water | Value falls |
| Probe in warm water | Value rises |
| Min and max | Track the lowest and highest values |
| Unplug the probe and restart | No probe found message |
If it does not work
No probe found
Check the yellow wire on GP15 and the 4.7 kilo-ohm pull-up.
Reads 85 degrees
The probe has just powered up, wait for the next reading.
ImportError for ssd1306
Install the micropython-ssd1306 package.
Blank screen
Check the OLED address 0x3C and the GP0 and GP1 wires.
Program does not start on power-up
Save it on the Pico as main.py.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the pico temperature logger with a probe?
Raspberry Pi Pico H, DS18B20 waterproof probe, Resistor 4.7 kΩ, SSD1306 OLED Display and Breadboard 830 Tie Points.
How long does the pico temperature logger with a probe take to build?
About 140 minutes for a intermediate maker, in 7 steps.
How do I know the pico temperature logger with a probe works?
Probe in air: Room temperature that settles slowly. Probe in cold water: Value falls. Probe in warm water: Value rises.
No probe found: what should I check?
Check the yellow wire on GP15 and the 4.7 kilo-ohm pull-up.
Reads 85 degrees: what should I check?
The probe has just powered up, wait for the next reading.
ImportError for ssd1306: what should I check?
Install the micropython-ssd1306 package.
Blank screen: what should I check?
Check the OLED address 0x3C and the GP0 and GP1 wires.
