Skip to content
Advanced 5 hours

ESP32 WiFi Weather Station with OLED and Web Dashboard

By Amit1379
July 13, 2026

This advanced weather station project goes beyond a simple sensor display. The ESP32 hosts a full web dashboard that shows live readings and 24-hour trend charts drawn with Chart.js (embedded in SPIFFS). Historical data is stored in a SPIFFS JSON file on the ESP32’s flash, so charts persist across reboots without any external server. Readings update every 60 seconds via AJAX without page reload.

What You’ll Need

  • ESP32 DevKit
  • BME280 sensor (temperature, humidity, barometric pressure via I2C)
  • BH1750 ambient light sensor (lux, I2C)
  • Tipping bucket rain gauge (pulse output) or FC-37 rain sensor
  • SSD1306 0.96″ OLED (I2C, for local display)
  • Weatherproof enclosure for outdoor sensors
  • 5 V / 2 A power supply

Step-by-Step Instructions

  1. Install tools: In Arduino IDE, add ESP32 board support. Install: Adafruit BME280, BH1750, ESPAsyncWebServer, ArduinoJson, and SPIFFS libraries.
  2. Wire all sensors: BME280 and BH1750 share I2C (SDA=21, SCL=22). OLED same I2C bus. Rain gauge pulse wire to GPIO 34 (input with pullup).
  3. Set up SPIFFS: Create a /data folder in your sketch folder. Add index.html with embedded Chart.js (downloaded, not CDN — the ESP32 serves it). Upload with ESP32 Sketch Data Upload plugin.
  4. Data storage: Every 10 minutes, read all sensors. Append a JSON object {time, temp, hum, pres, lux, rain} to /history.json in SPIFFS. Keep only the last 144 entries (24 hours × 6 per hour). Overwrite the file each time.
  5. Web server routes: GET / → serve index.html. GET /data → return current readings as JSON. GET /history → return the historical array as JSON. The HTML’s JavaScript fetches /data every 60 s for live updates and /history once on load to populate charts.
  6. OLED local display: Rotate through: screen 1 (temperature + humidity), screen 2 (pressure + lux), screen 3 (WiFi IP address) every 5 seconds.
  7. Deploy outdoors: Mount BME280 and BH1750 in a Stevenson screen style housing (louvred, white, shaded). Run wires to indoor ESP32 or use a weatherproof box with conformal coating on the ESP32 PCB.

Safety Notes

  • Outdoor electronics must be protected from moisture — use proper weatherproof connectors and conformal coating.
  • Lightning strikes near weather stations can induce damaging voltage surges — add TVS diodes on all sensor lines.

Tips & Troubleshooting

  • SPIFFS writes have limited endurance (~100,000 cycles). Writing every 10 minutes = ~52,560 writes/year — well within limits. Writing every 1 minute would approach limits in 2 years.
  • If the web page loads but charts are empty, check the /history endpoint returns valid JSON using curl http://[IP]/history.
  • Add a DS18B20 waterproof probe to measure outdoor ground temperature separately from the aspirated air temperature.

Leave a Comment

Your email address will not be published. Required fields are marked *