Raspberry Pi Pico weather display (MicroPython)
Your first MicroPython project: temperature and humidity on an OLED.
Shop by category
Shop all componentsA small magnet on the shaft makes the Hall sensor pulse once per turn. An interrupt counts every pulse, and each second the program turns the count into revolutions per minute on the OLED. It works for a pedal bike wheel as well as a desk fan.
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 RPM counter with a Hall sensor and 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)
hall = Pin(15, Pin.IN, Pin.PULL_UP)
count = 0
last = time.ticks_ms()
def pulse(pin):
global count
count += 1
hall.irq(trigger=Pin.IRQ_FALLING, handler=pulse) # each magnet pass makes the pin fall
MAGNETS = 1 # magnets glued on the shaft or wheel
while True:
time.sleep_ms(1000)
now = time.ticks_ms()
elapsed = time.ticks_diff(now, last) / 1000
pulses = count
count = 0
last = now
rpm = pulses / MAGNETS / elapsed * 60
oled.fill(0)
oled.text("Speed", 0, 0)
oled.text("%d rpm" % rpm, 0, 24)
oled.text("%d pulses/s" % pulses, 0, 48)
oled.show()
Flip the magnet and adjust the trimmer.
Check SDA/SCL and try address 0x3D. Run an I²C scanner to confirm.
5 parts: Linear Magnetic Hall Sensor Module – LM393, 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 intermediate 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 ₹677 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; Magnetic sensing.
Ideas that reuse this build: Bike speedometer OLED and Tachometer servo dial. 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.