Skip to content

ESP32 Weather Station

ESP32 Weather Station

Project Overview

This project documents the build of a solar-powered weather station using an ESP32 microcontroller. The station monitors temperature, humidity, barometric pressure, wind speed, and rainfall, then transmits data over WiFi to a local Home Assistant instance.

Components Used

Component Description Cost
ESP32 DevKit V1 Main microcontroller $8.00
BME280 Sensor Temperature, humidity, pressure $5.50
Anemometer Kit Wind speed measurement $22.00
Rain Gauge Tipping bucket style $15.00
6V 2W Solar Panel Power source $12.00
TP4056 Module LiPo charging $1.50
3.7V 3000mAh LiPo Battery backup $8.00

Wiring Diagram

The BME280 connects via I2C on GPIO 21 (SDA) and GPIO 22 (SCL). The anemometer uses a reed switch connected to GPIO 34 with an interrupt-based counting method. The rain gauge tipping bucket connects to GPIO 35.

#include <WiFi.h>
#include <Wire.h>
#include <Adafruit_BME280.h>

Adafruit_BME280 bme;

void setup() {
    Serial.begin(115200);
    Wire.begin(21, 22);

    if (!bme.begin(0x76)) {
        Serial.println("BME280 not found!");
        while (1);
    }

    connectWiFi();
}

void loop() {
    float temp = bme.readTemperature();
    float humidity = bme.readHumidity();
    float pressure = bme.readPressure() / 100.0F;

    sendToHomeAssistant(temp, humidity, pressure);
    delay(60000);  // Read every 60 seconds
}

Enclosure Design

The enclosure was 3D printed using PETG for UV resistance. It features a Stevenson screen design for passive airflow around the sensors while protecting from direct sunlight and rain.

Results

The station has been running reliably for over 6 months now, surviving temperatures from -5C to 38C. Battery life through winter nights averages 14 hours without solar charging.

Power Optimization

Putting the ESP32 into deep sleep between readings extended the battery life from 14 hours to approximately 72 hours during cloudy winter days.

Next Steps

  • Add a UV index sensor (VEML6075)
  • Implement OTA firmware updates
  • Build a web dashboard with historical charting