Pico chip temperature logger
Build it step by step
0 of 6 donePlug in the Pico
Open Thonny.
Paste the program
Save it as main.py on the Pico.
Run it
A line prints each second.
Rest a warm fingertip on the chip
The value rises.
Remove your finger
It falls back.
Compare with a room thermometer
Note the difference.
How do you build a pico chip temperature logger?
A Pico reads its own internal temperature sensor with the ADC and prints a line each second, so you can watch the chip warm up under your fingertip. You need Raspberry Pi Pico H and Breadboard 830 Tie Points. It takes 6 steps and about 100 minutes.
- Level
- Beginner
- Time
- About 100 min
- Parts
- 2
Parts list
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Pico USB socket | Computer USB port | Power and the serial printout |
| No other wiring | The sensor is inside the chip | Nothing to connect |
Code
The RP2040 chip has a temperature sensor built in. It is a diode whose voltage falls by about 1.7 millivolts for every degree the chip warms, and it is wired to the fifth ADC input. The program reads that input, averages sixteen reads, turns the count into volts and applies the formula from the chip datasheet: 27 degrees minus the voltage above 0.706 volts divided by 0.001721. The result is the temperature of the chip and not of the room, so it sits above room temperature, and it rises when the processor works hard or when you rest a warm fingertip on it. The sensor is not calibrated, so absolute values can be a few degrees out, and the reading is indicative only. It is useful for watching trends and for learning how an ADC turns a voltage into a number, which is the same job as for any outside sensor.
import time
from machine import ADC
sensor = ADC(4) # channel 4 is the on-chip temperature sensor
CONVERSION = 3.3 / 65535 # 16-bit reading to volts
def read_celsius():
total = 0
for _ in range(16):
total += sensor.read_u16() # average 16 reads to calm the noise
volts = (total / 16) * CONVERSION
return 27 - (volts - 0.706) / 0.001721 # formula from the RP2040 datasheet
while True:
print("Chip temperature: {:.1f} C".format(read_celsius()))
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 |
|---|---|
| Idle at your desk | A few degrees above the room |
| Fingertip on the chip | Reading rises |
| Finger removed | Reading falls over a minute |
| Averaging | Readings change smoothly |
| Output | One line per second |
If it does not work
Nothing prints
Run the program from Thonny and look at the shell.
Reading is far from the room temperature
The chip runs warmer, and the sensor is uncalibrated.
NameError
Check the import line for ADC.
Value jumps about
Keep the Pico away from drafts and use the averaging.
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 chip temperature logger?
Raspberry Pi Pico H and Breadboard 830 Tie Points.
How long does the pico chip temperature logger take to build?
About 100 minutes for a beginner maker, in 6 steps.
How do I know the pico chip temperature logger works?
Idle at your desk: A few degrees above the room. Fingertip on the chip: Reading rises. Finger removed: Reading falls over a minute.
Nothing prints: what should I check?
Run the program from Thonny and look at the shell.
Reading is far from the room temperature: what should I check?
The chip runs warmer, and the sensor is uncalibrated.
NameError: what should I check?
Check the import line for ADC.
Value jumps about: what should I check?
Keep the Pico away from drafts and use the averaging.
