← All Projects

ESP32 Weather Station with OLED Display

55 viewsMarch 1, 2026
ESP32BME280OLEDI2CWeather

Build a compact weather station using an ESP32, a BME280 sensor for temperature/humidity/pressure, and a 0.96" OLED display. The station reads live environmental data and displays it on screen with auto-refreshing intervals.

Components & Supplies

×1ESP32 Dev Module
×1BME280 Sensor
×10.96" OLED Display (SSD1306)
×1Breadboard
×6Jumper Wires (M-M)

Circuit Connections

ComponentPinPinComponent
ESP32GPIO 21 (SDA)SDABME280
ESP32GPIO 22 (SCL)SCLBME280
ESP323.3VVINBME280
ESP32GNDGNDBME280
ESP32GPIO 21 (SDA)SDAOLED
ESP32GPIO 22 (SCL)SCKOLED
ESP323.3VVCCOLED
ESP32GNDGNDOLED

Overview

This project demonstrates how to wire an ESP32 to a BME280 environmental sensor and a 128×64 OLED display using the I2C protocol. The firmware reads temperature (°C), humidity (%), and barometric pressure (hPa) every 2 seconds and renders them on the OLED in a clean, formatted layout.

The BME280 is a low-power sensor by Bosch, commonly used in IoT weather projects. Combined with the ESP32's WiFi capabilities, this project can be extended to push readings to a cloud dashboard or MQTT broker.

Setup Instructions

Before uploading, install the following libraries via the Arduino Library Manager:

  • Adafruit BME280 — Sensor driver
  • Adafruit SSD1306 — OLED display driver
  • Adafruit GFX — Graphics primitives

Select ESP32 Dev Module as your board and set the baud rate to 115200.

arduinoMain Sketch
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_BME280 bme;

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

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

  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println("OLED not found!");
    while (1);
  }

  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.display();
}

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

  display.clearDisplay();
  display.setCursor(0, 0);
  display.println("== Weather Station ==");
  display.println();
  display.print("Temp:  ");
  display.print(temp, 1);
  display.println(" C");
  display.print("Humid: ");
  display.print(hum, 1);
  display.println(" %");
  display.print("Press: ");
  display.print(pres, 1);
  display.println(" hPa");
  display.display();

  delay(2000);
}