114532 Views
101685 Views
86270 Views
54891 Views
51137 Views
49962 Views
Level Up your CAD Skills
Operation Pico
Raspberry Pi Home Hub
Hacky Temperature and Humidity Sensor
Robot Makers Almanac
High Five Bot
Using the Raspberry Pi Pico's Built-in Temperature Sensor
Getting Started with SQL
Introduction to the Linux Command Line on Raspberry Pi OS
How to install MicroPython
Wall Drawing Robot Tutorial
BrachioGraph Tutorial
KevsRobots Learning Platform
72% Percent Complete
By Kevin McAleer, 2 Minutes
The Raspberry Pi Pico’s ADC provides raw digital values that correspond to the temperature of the RP2040 chip. To make these readings meaningful, we need to convert them into temperature values in degrees Celsius. In this lesson, you’ll learn how to use a mathematical formula for this conversion.
The built-in temperature sensor measures the voltage output of the chip’s temperature sensing circuit. This voltage is then converted to an ADC value, which can be transformed into a temperature in degrees Celsius using the formula:
temperature = 27 - (voltage - 0.706) / 0.001721
27
0.706
0.001721
Update your script to include the conversion formula:
import machine import time # Initialize the ADC for the temperature sensor sensor_adc = machine.ADC(4) while True: # Read the raw ADC value raw_value = sensor_adc.read_u16() # Convert the ADC value to voltage voltage = raw_value * 3.3 / 65535 # Convert voltage to temperature temperature = 27 - (voltage - 0.706) / 0.001721 # Print the temperature print(f"Temperature: {temperature:.2f}°C") time.sleep(1)
convert_adc_to_temp.py
To ensure the readings are accurate:
Temperature: 26.84°C Temperature: 26.85°C Temperature: 26.87°C
< Previous Next >