Projects / Mini weather station

Mini weather station

Intermediate1.5 hGuided buildReviewed
ESP32 DevKitGPIO21GPIO22GPIO34VINBME2801009 hPa+2.1 hPa: ImprovingSerial
Serial at 115200 baud

Tap a part to see what it does.

Tap the parts to see what each one does. A teaching simulation, not a circuit simulator.

Build it step by step

0 of 4 done
  1. ESP32BME28022.2°C

    Sensor and LDR

    BME280 on GPIO21/22, LDR divider on GPIO34.

  2. ESP32+TP4056

    Battery power

    18650 through a protected TP4056 module.

  3. ESP32

    Upload

    Watch one reading, then it sleeps for 10 minutes.

  4. ESP32

    Mount outdoors

    In shade with airflow, electronics kept dry.

In short

How do you build a mini weather station?

A battery-powered ESP32 wakes every 10 minutes, reads a BME280 and an LDR, keeps 3 hours of pressure in sleep memory, and prints a simple forecast from the pressure trend. You need ESP32 DevKit V1, BME280 Environmental Sensor, LDR Photoresistor, Resistor 10 kΩ, 18650 Li-ion cell, TP4056 Charging Module and Breadboard 830 Tie Points. It takes 4 steps and about 90 minutes.

Level
Intermediate
Time
About 90 min
Parts
7

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
BME280 SDA / SCLGPIO21 / GPIO22I2C
LDR + 10 kΩ dividerMiddle to GPIO34Daylight
18650 via TP4056 OUTESP32 VIN on a board whose regulator works from 3.7 V, or a 3.3 V LDO to 3V3Battery power
All GNDCommonGround

Code

Library: Adafruit BME280. Forced mode lets the sensor sleep too. The ±1.6 hPa in 3 hours rule is a rough guide used by simple barometers, not a weather service.

Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Adafruit_BME280.h>
Adafruit_BME280 bme;
RTC_DATA_ATTR float hist[18];      // 3 h of 10-min samples, kept in deep sleep
RTC_DATA_ATTR int n = 0;

const char* forecast(float diff) {
  if (diff > 1.6) return "Improving";
  if (diff < -1.6) return "Worsening, rain likely";
  return "Steady";
}

void setup() {
  Serial.begin(115200);
  bme.begin(0x76);
  bme.setSampling(Adafruit_BME280::MODE_FORCED);
  bme.takeForcedMeasurement();
  float p = bme.readPressure() / 100.0;
  for (int i = 17; i > 0; i--) hist[i] = hist[i - 1];
  hist[0] = p; if (n < 18) n++;
  float diff = n == 18 ? p - hist[17] : 0;
  Serial.printf("%.1f C, %.0f %%, %.1f hPa, light %d, 3 h change %+.1f: %s\n", bme.readTemperature(), bme.readHumidity(), p, analogRead(34), diff, n == 18 ? forecast(diff) : "collecting");
  Serial.flush();
  esp_sleep_enable_timer_wakeup(10ULL * 60 * 1000000);
  esp_deep_sleep_start();
}

void loop() {}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual ESP32 Dev Module with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

24.2 C, 52 %, 1008.5 hPa, light 2048, 3 h change +0.0: collecting
[deep sleep for 10 min 0 s]

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
First 3 hoursForecast says "collecting"
After 3 hoursA forecast appears with the pressure change
Current in sleepMuch lower than awake (a bare module reaches microamps; DevKit boards draw more)

If it does not work

Temperature reads high in the sun

Needs a shaded, ventilated cover (a stack of plant saucers works).

Forecast never appears

History resets if power is lost: RTC memory survives sleep, not power cuts.

Battery lasts days, not weeks

DevKit USB chip and LED draw power; use a bare module for long runs.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the mini weather station?

ESP32 DevKit V1, BME280 Environmental Sensor, LDR Photoresistor, Resistor 10 kΩ, 18650 Li-ion cell, TP4056 Charging Module and Breadboard 830 Tie Points.

How long does the mini weather station take to build?

About 90 minutes for a intermediate maker, in 4 steps.

How do I know the mini weather station works?

First 3 hours: Forecast says "collecting". After 3 hours: A forecast appears with the pressure change. Current in sleep: Much lower than awake (a bare module reaches microamps; DevKit boards draw more).

Temperature reads high in the sun: what should I check?

Needs a shaded, ventilated cover (a stack of plant saucers works).

Forecast never appears: what should I check?

History resets if power is lost: RTC memory survives sleep, not power cuts.

Battery lasts days, not weeks: what should I check?

DevKit USB chip and LED draw power; use a bare module for long runs.