011 – Raspberry Pi Pico and Pico 2 Internal Temperature Sensor

Raspberry Pi Pico 2W - Internal Temperature Sensor

Raspberry Pi Pico and Pico 2 Built In Temperature Sensor 

The Raspberry Pi Pico 2 W has a small temperature sensor built into its main chip. It measures the chip’s own temperature, which you can read in your program and convert to degrees Celsius. It is not meant for accurate room temperature readings, but it is useful for checking how warm the board is or spotting big changes in temperature.

Video Instructions: Upgrade Proxmox Version 8 to Version 9

Raspberry Pi Pico 2W Temperature Sensor Code

import machine # import machine to make use of pins
import utime # import to allow python to sleep

tempsensor = machine.ADC(4) # set sensor to pin 4 analogue to digital
conversion_factor = 3.3 / (65535) # divide the 3.3v by 16-bits

while True: # while loop to run forever
reading = tempsensor.read_u16() * conversion_factor # read value from sensor 16-bits
print(“\nReading:”,reading)
temperature = 27 – (reading – 0.706)/0.001721 # convert value read to normal celcius
print(“Temperature:”,temperature) # show the value
utime.sleep(0.5) # pause for 0.5 seconds


# 27 degrees Celsius delivers a voltage of 0.706V
# convert the temp we get to volts
# fahrenheit_degrees = celsius_degrees * 9 / 5 + 32

Leave a Comment

Your email address will not be published. Required fields are marked *