Raspberry Pi Pico weather display (MicroPython)
Your first MicroPython project: temperature and humidity on an OLED.
Shop by category
Shop all componentsA kitchen timer and a study timer in one. One button adds a minute, the other starts and stops the count. The OLED shows minutes and seconds, and when the time runs out the piezo beeps ten times unless you press the start button to silence it.
Tick anything you already have and the total updates.
Follow the colours: red is power, dark grey is ground, blue is a signal.
main.py# Pico countdown timer with OLED and alarm (MicroPython)
from machine import Pin, PWM, I2C
import ssd1306, time
oled = ssd1306.SSD1306_I2C(128, 64, I2C(0, sda=Pin(4), scl=Pin(5)))
plus = Pin(16, Pin.IN, Pin.PULL_UP) # add a minute
start = Pin(17, Pin.IN, Pin.PULL_UP) # start / stop / clear
buzzer = PWM(Pin(15))
seconds = 0
running = False
last = time.ticks_ms()
def show(msg=""):
oled.fill(0)
oled.text(msg or ("RUNNING" if running else "SET TIME"), 0, 0)
oled.text("{:02d}:{:02d}".format(seconds // 60, seconds % 60), 36, 28)
oled.show()
def pressed(pin):
if pin.value() == 0:
time.sleep_ms(30)
while pin.value() == 0:
time.sleep_ms(10)
return True
return False
def alarm():
for _ in range(10):
buzzer.freq(1500); buzzer.duty_u16(30000); time.sleep_ms(250)
buzzer.duty_u16(0); time.sleep_ms(250)
if start.value() == 0:
break
show()
while True:
if not running and pressed(plus):
seconds = min(99 * 60, seconds + 60); show()
if pressed(start):
running = not running and seconds > 0
last = time.ticks_ms(); show()
if running and time.ticks_diff(time.ticks_ms(), last) >= 1000:
last = time.ticks_add(last, 1000)
seconds -= 1
show()
if seconds <= 0:
running = False; seconds = 0
show("TIME UP")
alarm()
show()
time.sleep_ms(20)
Check SDA/SCL and try address 0x3D. Run an I²C scanner to confirm.
The button is rotated 90°; legs on the same side are already connected. Turn it.
Normal for a bare piezo; mount it on a small box to resonate.
6 parts: 0.96" OLED Display 128x64 (I2C), Tactile Push Button Switch, Piezo Buzzer (passive), 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 4 steps.
No. This page has the complete, tested code (main.py). Install this library first: ssd1306 (micropython-lib).
About ₹654 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.
Drawing text on an I²C display; Generating musical notes with tone(); Pull-ups and debouncing.
Ideas that reuse this build: Keypad countdown timer and Pomodoro ring timer. 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.