PROJECT CASE STUDY · EMBEDDED SYSTEMS
RaspberryPi-PICO
A MicroPython project using a Raspberry Pi Pico to read temperature and humidity from a DHT22 sensor and display the measurements on a 16×2 I²C LCD.
At a glance
- Type
- Microcontroller / sensor project
- Board
- Raspberry Pi Pico · RP2040
- Language
- MicroPython
- Sensor
- DHT22 temperature and humidity
- Display
- 16×2 I²C LCD
- Repository
- View source files
The challenge
This project connects a physical sensor to a microcontroller and makes its readings understandable without needing a computer display. It combines sensor communication, GPIO pin configuration, I²C display output, and a repeating measurement loop.
What the code does
Reads the DHT22
Uses a DHT22 driver to obtain temperature and relative-humidity readings.
Initializes the LCD
Sets up I²C bus 0 with GPIO 0 for SDA and GPIO 1 for SCL, then detects the LCD address.
Connects the sensor
Configures the DHT22 data line on GPIO 15 of the Raspberry Pi Pico.
Displays live values
Refreshes the LCD with temperature and humidity values and also prints readings to the serial console.
Hardware and data flow
The main program initializes the I²C LCD, reads the DHT22 sensor, writes the two measurements to separate LCD rows, prints the values, and repeats after a short delay.
Implementation note
The repository includes a DHT22 driver file that retains its upstream MIT copyright notice. The main program integrates that driver with the Pico pins and LCD output.
Measurement cycle
- Initialize the I²C bus and LCD, then configure the DHT22 data pin.
- Request a temperature and relative-humidity sample from the sensor driver.
- Format the readings for the two-row character display and print them to serial output.
- Wait briefly and repeat, keeping the display refreshed with the latest sample.
Hardware integration notes
The program uses GPIO 15 for the DHT22 data signal and I²C bus 0 on GPIO 0 (SDA) and GPIO 1 (SCL) for the LCD. The LCD address is discovered during initialization, which avoids assuming a single address across compatible modules. The sensor driver is kept as a separate file rather than mixing its low-level protocol with display logic.
Scope and possible extensions
This is a compact local monitoring demonstration. It does not currently provide network telemetry or long-term data logging. Natural next steps include sensor-error handling, configurable sampling intervals, min/max tracking, and exporting readings.
What this project demonstrates
- Using MicroPython to program a Raspberry Pi Pico.
- Reading a digital environmental sensor.
- Configuring GPIO and an I²C peripheral.
- Presenting hardware readings on a character LCD and serial output.