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
40% Percent Complete
By Kevin McAleer, 2 Minutes
In this lesson, you’ll write your first script to interact with the Raspberry Pi Pico’s temperature sensor. You’ll read raw ADC values and display them in the Thonny console.
The Pico’s ADC provides a digital representation of the temperature sensor’s reading. In Python, you can use the machine module to access the ADC.
machine
Type the following code:
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() print("Raw ADC Value:", raw_value) time.sleep(1)
The raw ADC value will change depending on the temperature of the Pico’s chip. In the next lesson, you’ll learn to convert these values into meaningful temperature readings.
< Previous Next >