blog · 26 November 2026
Build an Arduino weather station with a BMP280, a DHT22 and an OLED display
Four new parts join de:volt: the SSD1306 OLED, the BMP280 and the DHT22 and DHT11. Wire three of them to an Arduino Uno and build a weather station using the real Adafruit libraries.
This release adds four parts that show up in countless Arduino projects:
- SSD1306 OLED: the little 128x64 pixel display, on I2C.
- BMP280: a temperature and air pressure sensor, also on I2C.
- DHT22 and DHT11: humidity and temperature sensors on a single data pin.

All four are drawn at their real size, so the OLED board is about 27 mm square and the DHT22 is the tall white sensor you would recognise from any starter kit. They behave like the real modules, down to the details in their datasheets, and they work with the same Adafruit libraries you would use on your desk. Let's put three of them together into a weather station.
The circuit
Drag in an Arduino UNO R3, an SSD1306 OLED, a BMP280 and a DHT22. You can wire straight from the Uno's headers to each module, or go through a breadboard if you prefer. Then wire:
Power, for all three modules
- each module's VCC (or +) to the Uno's 5V,
- each module's GND (or −) to GND.
I2C, shared by the OLED and the BMP280
- both SDA pins to the Uno's A4,
- both SCL pins to the Uno's A5.
DHT22
- OUT to digital pin 2. The module already has its pull-up resistor on board.
Two parts on the same I2C wires is fine: each has its own address (0x3C for the OLED, 0x77 for the BMP280), exactly like real hardware.
The sketch
Select the Uno, open the Sketch tab and paste:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_BMP280.h>
#include <DHT.h>
Adafruit_SSD1306 display(128, 64, &Wire, -1);
Adafruit_BMP280 bmp;
DHT dht(2, DHT22);
void setup() {
Serial.begin(9600);
bmp.begin(0x77);
dht.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}
void loop() {
float temp = bmp.readTemperature();
float pressure = bmp.readPressure() / 100.0;
float humidity = dht.readHumidity();
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.print(F("Temp: "));
display.print(temp, 1);
display.println(F(" C"));
display.print(F("Pres: "));
display.print(pressure, 1);
display.println(F(" hPa"));
display.print(F("Hum: "));
display.print(humidity, 0);
display.println(F(" %"));
display.display();
Serial.print(temp);
Serial.print(F(" C, "));
Serial.print(pressure);
Serial.print(F(" hPa, "));
Serial.print(humidity);
Serial.println(F(" %"));
delay(2000);
}Press Upload. All of these libraries come built in, so there is nothing to install.
Two small habits in this sketch are worth knowing about. The Uno has only 2 KB of memory for variables, and the OLED library takes half of it for its picture of the screen. So the sketch starts the sensors first and the display last, and wraps its text in F("..."), which keeps those words in the chip's larger flash memory instead. The status under the editor shows how much memory the sketch uses. If readings in a bigger sketch ever turn to nonsense, running out of memory is the first thing to check, on real hardware too.
Watch it work
After a moment the OLED lights up with the three readings, drawn pixel for pixel from what your sketch sent it. The Serial Monitor below the editor prints the same numbers every two seconds:
21.50 C, 1008.40 hPa, 62.00 %
Now change the weather. Select the BMP280 or the DHT22 and set a different temperature, pressure or humidity in the Inspector. The next reading on the display follows.
Details that match the real parts
These parts are modelled from their datasheets, so the quirks you would meet on real hardware are here too:
- The DHT22 can only be read every 2 seconds (the DHT11 every second). Read it sooner and it hands back its last measurement, which is why the sketch waits 2 seconds per loop.
- The BMP280 applies its own factory calibration to every reading, and its sampling settings work as documented.
- The OLED shows exactly what is in its memory. Forget
display.display()and nothing appears, just like on your bench. (Hardware scrolling commands are accepted, but not animated yet.)
Look at the conversation
Curious what the Uno and the sensors are actually saying to each other? Open the oscilloscope and press Decode. You will see every I2C message, with addresses, data bytes and acknowledgements, laid out under the waveform. Our protocol decoding guide walks through it.
Ideas to extend it
- Swap the DHT22 for a DHT11 and compare the readings.
- Draw a small bar graph of pressure on the OLED with
display.fillRect(). - Light a warning LED when the humidity climbs past 70 %.
New to Arduino in de:volt? Start with your first sketch.