Build Project

IoT Projects

ESP32 IoT Weather Station: BME280 Dashboard and Code

Build an ESP32 IoT weather station with BME280 temperature, humidity, pressure readings, I2C wiring, Arduino code, and optional OLED or dashboard output.

BeginnerAges 12+60-90 minUnder $25Parent Safe
Project Mission

Build Your IoT Weather Station

The Story

ESP32 IoT Weather Station turns the ESP32 into a real object that senses something, decides what it means, and reacts in the physical world.

The important lesson is not only the finished weather station. You learn how to separate input, decision logic, and output so a project stays debuggable instead of becoming a pile of wires and guesses.

Explain Like I'm 12

Think of the ESP32 as the brain. The BME280 environmental sensor is how it notices the world. The Serial Monitor and optional OLED display is how it answers back. The code is the rule book that tells the brain what to do when the numbers change.

Safety Standards

  • Unplug USB before changing jumper wires. Recheck 3.3 V, 5 V, and GND before reconnecting power.
  • Do not power motors, pumps, LED strips, or servos from the ESP32 3.3 V pin. Use a suitable external supply and common ground.
  • Breadboards are for low-current prototypes. Move high-current or unattended builds to proper terminals, enclosure, strain relief, and fusing.

What You Will Build

A working ESP32 IoT weather station with BME280 temperature, humidity, and pressure readings, Serial Monitor diagnostics, and optional OLED or dashboard output.

Learning Objectives

  • Wire and test the BME280 environmental sensor before connecting the rest of the circuit.
  • Map each signal to a named ESP32 GPIO and keep the code constants readable.
  • Control Serial Monitor and optional OLED display using a clear threshold or command instead of hidden magic numbers.
  • Use Serial Monitor as an engineering tool, not only as a success message.
  • Identify power, wiring, and timing faults using a repeatable test checklist.

Components List

Bill of Materials

PartQtyEstimated CostNotes
ESP32 DevKit1$6-$10Use a USB-programmable board
BME280 module1$3-$8Prefer I2C breakout
SSD1306 OLED1 optional$3-$6I2C 128x64 display
Breadboard and wires1 set$3-$5Male-to-male jumpers

Wiring

Wire the BME280 environmental sensor first, verify readings, then connect the Serial Monitor and optional OLED display.

ESP32 IoT Weather Station wiring diagram
  1. 1

    Unplug USB before wiring the breadboard.

  2. 2

    Connect BME280 VCC to 3.3 V and GND to GND.

  3. 3

    Connect BME280 SDA to GPIO21 and SCL to GPIO22.

  4. 4

    If using OLED, connect its SDA and SCL to the same GPIO21/GPIO22 I2C bus.

  5. 5

    Reconnect USB and open Serial Monitor at 115200 baud.

GPIO Mapping

SignalESP32 PinDirectionNotes
BME280 SDAGPIO21I2C dataShared I2C bus
BME280 SCLGPIO22I2C clockShared I2C bus
OLED SDAGPIO21I2C dataOptional display
OLED SCLGPIO22I2C clockOptional display

Circuit Explanation

The BME280 and OLED both use I2C, so they share two signal lines. The ESP32 sends clock pulses on SCL and exchanges data on SDA. Pull-up resistors on most modules keep the bus idle HIGH, which is why the modules must use 3.3 V logic.

Engineering Explanation

Environmental readings drift when a sensor is heated by a board, touched by fingers, or placed in direct airflow. A good weather station separates sensing from heat sources, samples slowly, and prints raw values before any smoothing. Pressure is useful because it changes more slowly than temperature and can show weather trends.

Code

Copy into Arduino IDE. Install any libraries noted in the component guides first.

iot-weather-station.ino
#include <Wire.h>
#include <Adafruit_BME280.h>

Adafruit_BME280 bme;

void setup() {
  Serial.begin(115200);
  if (!bme.begin(0x76)) {
    Serial.println("BME280 not found. Try address 0x77 and check wiring.");
    while (true) delay(10);
  }
  Serial.println("ESP32 weather station ready");
}

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

  Serial.print("Temp C: "); Serial.print(tempC, 1);
  Serial.print(" | Humidity %: "); Serial.print(humidity, 1);
  Serial.print(" | Pressure hPa: "); Serial.println(pressure, 1);
  delay(2000);
}

Code Explanation

The sketch starts the I2C bus through the BME280 library, checks that the sensor answers at address 0x76, then reads temperature, humidity, and pressure every two seconds. The address check is important because many BME280 boards use 0x76 while some use 0x77.

Expected Output

Serial Monitor should show temperature in Celsius, humidity in percent, and pressure in hPa every two seconds. Warm the sensor gently with your hand and the temperature should rise slowly; breathe near it and humidity should increase.

Build Photos

  • Breadboard overviewShow the ESP32, module placement, and power rails clearly.
  • Close-up wiringCapture each GPIO wire so beginners can compare their build.
  • Working outputShow the Serial Monitor, display, robot, pump, or lock state after the code runs.

Troubleshooting

  • BME280 not found Try address 0x77, confirm SDA/SCL, and verify the module is powered from 3.3 V.
  • Humidity reads NAN You may have a BMP280 instead of BME280; BMP280 does not measure humidity.
  • Readings jump too much Move the sensor away from fingers, USB regulators, and direct breath.
  • OLED goes blank Check the OLED I2C address and confirm both devices share ground.

Common Mistakes

  • Using a BMP280 board and expecting humidity readings.
  • Powering the sensor from 5 V when the breakout is not 5 V tolerant.
  • Forgetting that BME280 address can be 0x76 or 0x77.
  • Placing the sensor directly above the warm ESP32 module.

Testing Checklist

  • ESP32 appears on the correct port and accepts a basic blink upload.
  • Ground is shared between every module that exchanges signals with the ESP32.
  • Each GPIO in the code matches the wire connected on the breadboard.
  • Serial Monitor prints startup text at 115200 baud.
  • The BME280 environmental sensor value changes when you create a real test condition.
  • The Serial Monitor and optional OLED display changes only when the expected condition is reached.
  • The circuit still behaves correctly after power is removed and restored.

Upgrade Ideas

  • Add OLED display pages for current and trend values.
  • Upload readings to a web dashboard over Wi-Fi.
  • Store pressure history and show rising or falling trend.
  • Add deep sleep for outdoor battery operation.

Real-World Applications

  • Classroom weather station
  • Greenhouse monitoring
  • Desk comfort monitor
  • Pressure trend logger
  • IoT dashboard sensor node

Downloads

  • ESP32 IoT Weather Station Arduino sketchUse the code section as the downloadable source until file downloads are published.
  • Wiring checklistMatch the GPIO table and wiring steps before powering the circuit.
  • Troubleshooting worksheetRecord symptoms, Serial output, voltage checks, and fixes.

FAQs

Why does my BME280 environmental sensor reading look wrong?

Most wrong readings come from reversed power, loose breadboard rows, the wrong GPIO number in code, or reading the sensor before it has settled.

Why is the BME280 not found on I2C?

Check SDA on GPIO21, SCL on GPIO22, 3.3 V power, ground, and whether your breakout uses address 0x76 or 0x77.

Why do readings drift when the board is on the desk?

Heat from the ESP32 or nearby electronics can warm the air around the sensor. Move the BME280 away from the ESP32 module for steadier room readings.

Review, Testing, and References

Author: Abdul Mubeen and the ESP32 Engine editorial team. Last updated: 2026-06-29. Reviewed: wiring logic, Arduino code structure, beginner safety, and learning sequence.

Educational level: Beginner. Estimated completion time: 60-90 min. This project is for learning and prototyping; production or unattended hardware needs additional engineering review.

Project Complete!

You built a real weather station and learned how to connect sensing, decision logic, and output control in one ESP32 project.

  • Wire and test BME280 environmental sensor
  • Control Serial Monitor and optional OLED display from ESP32
  • Debug hardware with Serial Monitor
  • Improve the project safely