deckle studioOpen in the editor

Arduino Uno: weather station (BME280 + OLED)

BME280 measures, OLED displays (I²C).

  • Arduino Uno
  • BME280
  • SSD1306 OLED
Open in the simulatorNo account needed: press Simulate and it runs.
The display while Arduino Uno: weather station (BME280 + OLED) runs
On the simulated display

How it works

The BME280 measures temperature, air pressure and humidity, and the 0.96" OLED (SSD1306) shows the values. Both sit on the Uno's I²C bus (A4 = SDA, A5 = SCL) and use the original Adafruit libraries. You can set the sensor's environment in the inspector, even while the simulation runs; the OLED image appears in the live window.

Wiring

Each line is one connection (net) and the pins it joins.

NetPins
GNDA1 GNDDS1 GNDU2 GNDV1 −
5VA1 5VDS1 VCCR1 1R2 1U2 VINV1 +
SCLA1 A5/SCLDS1 SCLR1 2U2 SCL
SDAA1 A4/SDADS1 SDAR2 2U2 SDA

Parts

Firmware

sketch.ino · 27 lines

// Weather station: the BME280 (0x76) measures, the SSD1306 OLED (0x3C) displays, both on the I²C bus (A4/A5)
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_BME280.h>

Adafruit_SSD1306 oled(128, 64, &Wire, -1);
Adafruit_BME280 bme;

void setup() {
  Serial.begin(115200);
  if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) Serial.println(F("OLED missing"));
  if (!bme.begin(0x76)) Serial.println(F("BME280 missing"));
  oled.setTextColor(SSD1306_WHITE);
}

void loop() {
  float t = bme.readTemperature(), p = bme.readPressure() / 100.0, h = bme.readHumidity();
  oled.clearDisplay();
  oled.setTextSize(1); oled.setCursor(0, 0); oled.print(F("Weather station"));
  oled.setTextSize(2); oled.setCursor(0, 16); oled.print(t, 1); oled.print((char)247); oled.print('C');
  oled.setTextSize(1); oled.setCursor(0, 40); oled.print(p, 1); oled.print(F(" hPa"));
  oled.setCursor(0, 52); oled.print(h, 0); oled.print(F(" % rel. humidity"));
  oled.display();
  Serial.print(t, 2); Serial.print(F(" C  ")); Serial.print(p, 2); Serial.print(F(" hPa  ")); Serial.print(h, 1); Serial.println(F(" %"));
  delay(500);
}
Open in the simulator

More examples: Arduino