Build a Raspberry Pi Weather Station that Emails Daily Weather Data
Turn your Raspberry Pi into a reliable personal weather station that sends you real‑time temperature, humidity, and rainfall updates via email. This guide walks you through the required hardware, wiring, housing, and coding steps to get your station up and running in just a few hours.
1. Supplies
- Raspberry Pi B (or newer model) with power supply
- Ethernet cable (or Wi‑Fi adapter for wireless setups)
- Prototyping breadboard and jumper wires
- Humidity & temperature sensor – DHT11 (or the more accurate DHT22)
- Analog rain gauge (e.g., a simple tipping bucket)
- Weather‑proof enclosure (polycarbonate or acrylic)
- Hot glue gun & glue sticks
- Drill with a selection of bits (for mounting the gauge and wiring)
- Optional: BME280 or BMP280 barometric pressure sensor (for future rain‑chance calculations)
2. Assemble the Circuit
Connect the components as follows:
- Power: Attach the sensor’s VCC pin and the rain gauge’s power input to the Pi’s 3.3V pin.
- Ground: Connect the sensor’s GND to a Pi ground pin.
- Data Lines: Wire the DHT11 data pin to GPIO 16 (or any free GPIO). Hook the rain gauge’s data output to additional GPIO pins (e.g., GPIO 7, 13, 15, 18).
3. Build the Housing
1. Drill mounting holes in the rain gauge at 1", 1.5", 2", 2.5", and a bottom hole for drainage. 2. Carve out slots in the enclosure for the Ethernet and power cables, as well as the sensor leads. 3. Secure the gauge to the back of the housing with hot glue, ensuring the drainage holes remain open. 4. Route the sensor and gauge wires through the housing, sealing all penetrations with hot glue to keep moisture out. 5. Place the Raspberry Pi and the breadboard inside the enclosure, connect the Ethernet and power cables, and power on.
4. Program the Humidity Sensor
Install the Adafruit DHT library:
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo apt-get install build-essential python-dev
sudo python setup.py install
Test the sensor with a simple script:
import Adafruit_DHT as dht
sensor = dht.DHT11
pin = 16
humidity, temperature = dht.read_retry(sensor, pin)
print(f"Humidity={humidity:.1f}% Temp={temperature:.1f}°C")
If the output shows valid values, the sensor is wired correctly.
5. Automate Email Reports
Install mailx (or msmtp) to send emails from the Pi. Create a cron job that runs the sensor script every 30 minutes and pipes the output to an email address:
*/30 * * * * /usr/bin/python /home/pi/weather.py | mailx -s "Pi Weather Update" you@example.com
Adjust the cron schedule to suit your reporting frequency.
6. Future Enhancements
When you’re ready, add a BME280 or BMP280 sensor for barometric pressure. With the pressure trend, you can calculate the probability of rainfall and include it in your email alerts.
Happy building and enjoy the daily weather data straight to your inbox!
Manufacturing process
- DIY Solar‑Powered Weather Station with Raspberry Pi
- Building an Outdoor Weather Station with Raspberry Pi 2 and ADS‑WS1
- Control an LED with a PIR Motion Sensor on Raspberry Pi
- Build a Low‑Cost Raspberry Pi Soil Moisture Sensor for Smart Irrigation
- Build an Automated Aeroponics System with Raspberry Pi and Humidity Sensor
- Build a Raspberry Pi Home Temperature Monitor with MCP9808, InfluxDB & Grafana
- Advanced Weather Station v2.0: Real‑Time Temperature, Pressure, Humidity & Altitude Monitoring
- Arduino Nano Weather Station: Sensor Kit & OLED Display
- Build a Reliable Arduino Weather Station with DHT Sensors
- TensorFlow-Powered IoT Weather Station Accurately Predicts Rainfall Intensity