Raspberry Pi Pico weather display (MicroPython)
Your first MicroPython project: temperature and humidity on an OLED.
Shop by category
Shop all componentsThe AHT10 gives a small, accurate reading over I2C. The program turns the two numbers into a word, because "28 °C and 75 %" means little to most people but "hot and sticky" tells you to switch on the fan.
Tick anything you already have and the total updates.
Small digital sensor for air temperature (±0.3 °C) and humidity (±2 %) over I²C, more accurate than the common DHT11.
Follow the colours: red is power, dark grey is ground, blue is a signal.
main.py# Pico room comfort display: AHT10 temperature and humidity on an OLED (MicroPython)
from machine import Pin, I2C
import ssd1306, time
i2c = I2C(0, sda=Pin(4), scl=Pin(5), freq=400000)
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
AHT10 = 0x38
i2c.writeto(AHT10, b"\xE1\x08\x00") # start-up calibration
time.sleep_ms(50)
def read():
i2c.writeto(AHT10, b"\xAC\x33\x00") # start a measurement
time.sleep_ms(80)
d = i2c.readfrom(AHT10, 6)
hum = ((d[1] << 12) | (d[2] << 4) | (d[3] >> 4)) / 1048576 * 100
temp = (((d[3] & 0x0F) << 16) | (d[4] << 8) | d[5]) / 1048576 * 200 - 50
return temp, hum
while True:
t, h = read()
if t > 30 and h > 70:
comfort = "Hot and sticky"
elif t > 30:
comfort = "Hot"
elif h > 70:
comfort = "Damp"
elif t < 18:
comfort = "Cool"
else:
comfort = "Comfortable"
oled.fill(0)
oled.text("%.1f C %d %%" % (t, h), 0, 0)
oled.text(comfort, 0, 32)
oled.show()
time.sleep(2)
Check SDA and SCL are not swapped and that the module has 3.3 V or 5 V. An I²C scanner should show 0x38.
Moisture has condensed on the sensor. Dry it in warm air for an hour and keep it out of direct spray.
Check SDA/SCL and try address 0x3D. Run an I²C scanner to confirm.
5 parts: AHT10 High Precision Digital Temperature & Humidity Sensor Module – I2C Interface, 0.96" OLED Display 128x64 (I2C), Raspberry Pi Pico, Solderless Breadboard (830 points) and Dupont Jumper Wires (40 pcs). Tools: Digital Multimeter and Wire Stripper and Cutter. On this page you can tick the parts you already have and add only the rest to your cart.
It is a beginner project and takes about 45 minutes. The build on this page has 5 steps.
No. This page has the complete, tested code (main.py). Install this library first: ssd1306 (micropython-lib).
About ₹717 for the parts at the prices on this page, plus tools if you do not have them. Quantity price breaks lower the cost when you build several.
Digital sensors and accuracy versus price; Drawing text on an I²C display.
Ideas that reuse this build: AHT10 room climate monitor and Pico room climate OLED. They are listed under Take it further on this page.
Your first MicroPython project: temperature and humidity on an OLED.
A web page with ON and OFF buttons that switches a relay over Wi-Fi.
A warm ring light that fades up at dusk and down at dawn.
Turn a Pi and a touchscreen into a home command centre with a clock and to-do list.
Learning project. Check every circuit and the datasheet of each part before you power it up.