Raspberry Pi Pico weather display (MicroPython)
Your first MicroPython project: temperature and humidity on an OLED.
Shop by category
Shop all componentsCron is the Pi's built-in scheduler. A short Python script reads a BME280 over I2C and appends one line to a CSV file; cron runs it every ten minutes. This is simpler and more robust than a script that runs forever, because the Pi starts each run fresh, and it keeps going after power cuts. After a week you have a weather history you can chart in a spreadsheet.
Tick anything you already have and the total updates.
microSD card for the operating system
Temperature, humidity and pressure sensor
Follow the colours: red is power, dark grey is ground, blue is a signal.
Official Pi 4 power supply.
log_weather.pyimport csv, datetime, os
import board, busio
from adafruit_bme280 import basic as adafruit_bme280
i2c = busio.I2C(board.SCL, board.SDA)
bme = adafruit_bme280.Adafruit_BME280_I2C(i2c, address=0x76) # use 0x77 if needed
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "weather.csv")
new = not os.path.exists(path)
with open(path, "a", newline="") as f:
w = csv.writer(f)
if new:
w.writerow(["time", "temp_c", "humidity_pct", "pressure_hpa"])
w.writerow([datetime.datetime.now().isoformat(timespec="seconds"),
round(bme.temperature, 1), round(bme.relative_humidity, 1), round(bme.pressure, 1)])
Try 0x77, and check with i2cdetect -y 1.
Use full paths in the cron line, and check with grep CRON /var/log/syslog.
The Pi has no clock battery; connect it to the network so it can set the time.
About 10 KB per day, so years of data fit easily.
Yes. Open the CSV in a spreadsheet and insert a line chart.
Yes, see the Flask DHT22 project for that sensor.
6 parts: Raspberry Pi 4 Model B 2GB RAM Single Board Computer, Official Raspberry Pi 4 USB-C Power Supply – 15.3W, Official Raspberry Pi 32GB A2 Class Micro SD Card, Generic ZY-BME280 Pressure Temperature Humidity Sensor Module – I2C Interface, Solderless Breadboard and Dupont Jumper Wires (40 pcs). 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 1 hour. The build on this page has 6 steps.
No. This page has the complete, tested code (log_weather.py).
About ₹8,853 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Enabling I2C and reading a BME280; Appending to a CSV file; Scheduling a job with cron.
Ideas that reuse this build: Raspberry Pi BMP280 weather station. 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.