Raspberry Pi Pico weather display (MicroPython)
Your first MicroPython project: temperature and humidity on an OLED.
Shop by category
Shop all componentsLost the dice from the Ludo box? The Pico draws a dice face with proper dots, tumbles through a few random faces that slow down like a real throw, and lands on the result. A short program that shows dictionaries, loops and random numbers working together.
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 dice with real dots on an OLED (MicroPython)
from machine import Pin, I2C
import ssd1306, time, random
oled = ssd1306.SSD1306_I2C(128, 64, I2C(0, sda=Pin(4), scl=Pin(5)))
button = Pin(16, Pin.IN, Pin.PULL_UP)
SPOTS = {1: [(1, 1)], 2: [(0, 0), (2, 2)], 3: [(0, 0), (1, 1), (2, 2)],
4: [(0, 0), (2, 0), (0, 2), (2, 2)], 5: [(0, 0), (2, 0), (1, 1), (0, 2), (2, 2)],
6: [(0, 0), (2, 0), (0, 1), (2, 1), (0, 2), (2, 2)]}
def draw(n):
oled.fill(0)
oled.rect(36, 4, 56, 56, 1)
for col, row in SPOTS[n]:
x, y = 44 + col * 18, 12 + row * 18
oled.fill_rect(x, y, 6, 6, 1)
oled.show()
draw(1)
while True:
if button.value() == 0:
for delay in (30, 40, 60, 80, 110, 150, 200): # tumble, slowing down
draw(random.randint(1, 6)); time.sleep_ms(delay)
n = random.randint(1, 6)
draw(n); print("Rolled", n)
while button.value() == 0:
time.sleep_ms(10)
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.
5 parts: 0.96" OLED Display 128x64 (I2C), Tactile Push Button Switch, 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 ₹640 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; Pull-ups and debouncing.
Ideas that reuse this build: Ludo dice ring and Electronic dice with a 555. 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.