Build a Raspberry Pi weather station
ActivitiesProjects
Wire outdoor sensors to a Raspberry Pi and collect timestamped measurements you can graph.
Turning a Raspberry Pi into a backyard weather station combines hardware wiring, mechanical outdoor instruments, and code to track temperature, humidity, atmospheric pressure, wind speed and direction, and rainfall. The full from-scratch version is an advanced project in both electronics and programming; it took shape as a build-your-own alternative after Raspberry Pi distributed nearly 1,000 Oracle weather station kits to schools in 2016. Depending on how much circuit work you want to take on, you can wire individual sensors onto a breadboard or use a dedicated sensor HAT that handles most of the indoor connections for you.
Breadboard build or weather HAT
The first major choice is how you connect the instruments to the Pi. A discrete component build pairs a wirelessly connected Raspberry Pi with a breadboard, jumper wires, two 4.7 kΩ resistors, a BME280 environmental sensor, a DS18B20 temperature probe, and an MCP3008 analogue-to-digital converter, along with weatherproof enclosures and optional RJ11 breakout boards for the outdoor cables.
If you would rather skip breadboard wiring, a plug-in board such as the Pimoroni Weather HAT stacks directly onto the Pi. It integrates an onboard BME280 environmental sensor, an LTR-559 light sensor, a 12-bit analogue-to-digital converter, a small colour LCD, and RJ11 ports for plugging in external wind and rain instruments without a breadboard or separate converter.
How the sensors work and how to test them indoors
Before mounting anything outside, get each sensor responding on your desk. When wiring a BME280 directly, check your specific breakout board's pinout and I²C address rather than assuming every board matches. On an Adafruit BME280, physical Pi header pins 17 (3V3), 6 (GND), 3 (SDA), and 5 (SCL) connect to Vin, GND, SDA, and SCL, and the board uses I²C address `0x77`, whereas other BME280 breakouts commonly use `0x76`. Once the sensor script is running, exhale directly onto the chip: humidity should climb right away, and temperature may tick upward as well.
The outdoor instruments turn physical motion into electrical signals the Pi can count:
- Anemometer: Wind spins the cups past a magnet that operates a reed switch, and your code counts those pulses over a fixed time interval. One common anemometer generates two signals per rotation, though you should verify the pulse count for your own model before calculating wind speed.
- Wind vane: Tracks the direction the wind is coming from.
- Rain gauge: Collects rain in an internal tipping bucket that empties itself as it fills, triggering a GPIO input on the Pi with each tip.
On a mast kit paired with a weather HAT, mount the anemometer and wind vane on a top cross-arm and place the rain gauge on a lower arm clear of the other instruments. Plug the anemometer into the wind vane, run the vane's combined cable to the HAT's Wind port, and connect the rain gauge to the Rain port. Run your test program and trigger every instrument by hand—spin the cups, rotate the vane, and tip the bucket—watching the display confirm each reading before taking the mast outdoors.
Siting the mast and protecting the electronics
Where you put the station shapes every number it records. Keep the mast away from trees and other obstructions that block wind or shield the rain gauge, and verify that the rain gauge sits level so the bucket tips consistently. Before tightening the mast in place, find north with a compass and rotate the assembly until the wind vane's indicated north matches the compass bearing.
Outdoor electronics need weatherproof enclosures, yet sensor exposure and ventilation affect accuracy just as much as keeping water out. Keeping the Raspberry Pi and its onboard sensor inside a garage with sensor cables run through a window protects the computer, for example, but leads to inflated temperature readings on hot days.
Displaying and logging your weather data
Once the sensors report reliably, you can view and store the data locally or online. A HAT with an onboard colour LCD shows live conditions right on the Pi, and you can log and chart readings locally on your own machine. For remote monitoring, you can push sensor feeds to a web dashboard such as Adafruit IO and arrange them into line charts, gauges, and a live data stream. Because installation commands, service interfaces, and boot configuration change with newer hardware and software releases, check current documentation for your chosen board before running older setup scripts.
