Build a Raspberry Pi Weather Station with Web Dashboard
Free Daily Electronics Newsletter
Tutorials, news, and one component explained simply — every day.
Difficulty: Intermediate

Ever wondered what the temperature and humidity actually are in your backyard versus what the weather app claims? Professional weather stations cost hundreds of dollars, but you can build your own internet-connected version for under $50. This Raspberry Pi weather station logs temperature, humidity, and barometric pressure every minute, then displays it all on a sleek web dashboard you can check from anywhere.
Unlike those plastic weather stations from big-box stores that stop working after six months, this build gives you complete control over your data. You’ll learn how I2C sensors communicate, how to build a simple Python web server, and how to create live-updating charts that would make any meteorology hobbyist jealous.

Why Build Your Own Weather Station?
Commercial weather stations either lock you into proprietary cloud services that disappear when the company loses interest, or they’re absurdly expensive. Building your own means you control the data, you can add any sensors you want, and you learn a ton about environmental sensing along the way.
This project combines several crucial electronics skills: reading sensor datasheets (a skill we covered in depth at Reading a datasheet: the skill that unlocks every component), working with I2C communication protocols, Python programming, and building web interfaces. Plus, once you’ve built this, you can easily expand it with rainfall sensors, wind speed anemometers, or even air quality monitors.
The web dashboard approach means you’re not tied to a tiny LCD screen — you can view your weather data on your phone, tablet, or computer. The data logs to a SQLite database, so you can analyze trends over weeks or months. Want to know if your apartment’s humidity is really contributing to that mold problem? Now you’ll have the data to prove it.
Understanding the I2C Sensor Bus
Before we start wiring, let’s talk about I2C (Inter-Integrated Circuit, pronounced “I-squared-C”). This two-wire protocol lets multiple sensors share the same communication lines, which is perfect for a weather station with several sensors.
I2C uses just two wires: SDA (data) and SCL (clock). Each sensor has a unique address, so the Raspberry Pi can talk to specific sensors without confusion. Most environmental sensors use I2C because it’s simple and reliable — you’ll see it everywhere in professional equipment.
The Raspberry Pi’s GPIO pins 2 and 3 are dedicated I2C pins with built-in pull-up resistors (those resistors ensure the lines stay at a known voltage when idle). This makes our wiring incredibly simple — we just connect all sensors in parallel to the same two pins.

Choosing Your Sensors
For this build, we’re using three sensors that cover the essential weather measurements:
BME280: This Bosch sensor (datasheet) measures temperature, humidity, and barometric pressure in one tiny package. It’s accurate, low-power, and has become the go-to environmental sensor for hobbyists. The I2C address is typically 0x76 or 0x77 depending on the breakout board.
Optional: DS18B20 temperature probe: If you want to measure outdoor temperature while keeping your Raspberry Pi indoors, this waterproof probe (datasheet) uses the 1-Wire protocol. You can run it on a long cable — I’ve successfully used 10-meter cables without signal degradation.
The BME280 alone gives you everything for a functional weather station. The beauty of I2C is that you can always add more sensors later without rewiring — just connect them to the same SDA and SCL lines.
Wiring the Hardware
This is where the project gets satisfyingly simple. The Raspberry Pi does most of the heavy lifting, so our circuit is minimal.

Connect your BME280 breakout board to the Raspberry Pi:
- VCC (or VIN) to Pin 1 (3.3V) — never use 5V for the BME280, you’ll damage it
- GND to Pin 6 (Ground)
- SDA to Pin 3 (GPIO 2, SDA)
- SCL to Pin 5 (GPIO 3, SCL)
If your breakout board has a CSB pin, connect it to 3.3V to enable I2C mode. Some boards do this internally, so check your board’s documentation — this is exactly why learning to read datasheets matters.
That’s it for wiring. No resistors, no level shifters, no complexity. The Raspberry Pi’s I2C implementation handles everything. If you’re adding the optional DS18B20 probe, that requires one 4.7kΩ pull-up resistor between data and VCC, connected to GPIO 4.

Setting Up the Raspberry Pi Software
I’m assuming you’re starting with a fresh Raspberry Pi OS installation. If you’re experienced with Linux, this will feel familiar. If you’re new to Raspberry Pi, don’t worry — I’ll walk through every command.
First, enable I2C on your Pi. Open a terminal and run:
sudo raspi-config
Navigate to “Interface Options,” then “I2C,” and enable it. Reboot your Pi.
After rebooting, install the required Python libraries:
sudo apt-get update
sudo apt-get install -y python3-pip python3-smbus i2c-tools
pip3 install Flask RPi.GPIO adafruit-circuitpython-bme280
The i2c-tools package gives you a crucial debugging command. Run this to see if your Pi detects the BME280:
sudo i2cdetect -y 1
You should see a grid with either 76 or 77 highlighted. That’s your sensor’s address. If you see nothing, double-check your wiring — the most common mistake is swapping SDA and SCL.
