OLED clock with temperature and humidity

Shows time from NTP with European/Kyiv time zone and DHT22 readings on a compact OLED. Powered from USB.

Level: Intermediate Board: ESP32 DevKit V1 (WROOM-32) Climate

⚠ Safety

USB powered only.

What you need

Buy the parts kit · Estimated total: $11.00

ESP32 DevKit V1 (30 pin, WROOM-32) × 1
$4.00
Buy at AliExpress Buy at Amazon.com
OLED 0.96" 128x64 I2C SSD1306 × 1
$2.50
Buy at AliExpress Buy at Amazon.com
BME280 I2C module (3.3V) × 1
$3.00
Buy at AliExpress Buy at Amazon.com
Dupont jumper wires (M-F, M-M) × 1
$1.50
Buy at AliExpress Buy at Amazon.com
🇺🇦 Ukraine🌍 Other countries

Other countries: order these parts on AliExpress with the links below.

Some links are affiliate links: we may earn a commission at no extra cost to you.

Wiring

ModuleModule pinESP32 pinNote
OLED + BME280 SDA / SCLI2CGPIO21 / GPIO22
VCC / GND3V3 / GND

Libraries

Arduino IDE → Tools → Manage Libraries, then install:

  • Adafruit SSD1306
  • Adafruit GFX
  • Adafruit BME280

Code

oled-weather-clock.ino
#include <WiFi.h>

const char* WIFI_SSID = "YOUR_WIFI";
const char* WIFI_PASS = "YOUR_PASSWORD";

bool connectWiFi(uint32_t timeoutMs = 20000) {
  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  uint32_t t0 = millis();
  while (WiFi.status() != WL_CONNECTED && millis() - t0 < timeoutMs) {
    delay(250);
    Serial.print(".");
  }
  Serial.println();
  if (WiFi.status() == WL_CONNECTED) {
    Serial.print("IP: ");
    Serial.println(WiFi.localIP());
    return true;
  }
  return false;
}
#include <Wire.h>
#include <time.h>
#include <Adafruit_BME280.h>
#include <Adafruit_SSD1306.h>
Adafruit_BME280 bme;
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
void setup() {
  Serial.begin(115200);
  Wire.begin(21, 22);
  bme.begin(0x76);
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  connectWiFi();
  configTzTime("EET-2EEST,M3.5.0/3,M10.5.0/4", "pool.ntp.org", "time.google.com");   // Kyiv; change the TZ string for your region
}
void loop() {
  struct tm ti; getLocalTime(&ti, 100);
  oled.clearDisplay(); oled.setTextColor(WHITE);
  oled.setTextSize(3); oled.setCursor(0, 0); oled.printf("%02d:%02d", ti.tm_hour, ti.tm_min);
  oled.setTextSize(1); oled.setCursor(0, 32); oled.printf("%02d.%02d.%04d", ti.tm_mday, ti.tm_mon + 1, ti.tm_year + 1900);
  oled.setTextSize(2); oled.setCursor(0, 46); oled.printf("%.1fC %.0f%%", bme.readTemperature(), bme.readHumidity());
  oled.display();
  delay(1000);
}

Flash a ready firmware from the browser Paste your error into the AI Error Doctor

Build tips

  • Change the TZ string for your time zone.
  • Place the DHT22 away from heat sources.

← ← All projects

Related ideas

Outage schedule countdown display

A small screen that loads your own outage schedule and shows the time to the next switch-off or switch-on, so you can plan charging and cooking.

  • Board ESP32 DevKit V1 (WROOM-32)
  • Level ●●○ Intermediate
  • Build time 1–2 h
Pick parts / kit

Temperature & humidity station

BME280 plus an OLED screen: temperature, humidity and pressure on the display, a web page and Home Assistant.

  • Board ESP32 DevKit V1 (WROOM-32)
  • Level ●○○ Beginner
  • Build time 1 h
Pick parts / kit
⚠ Caution

Batteries: watch polarity, use protected cells and a charger with protection, never charge damaged cells unattended.

Power status panel

An ESP32-S3 with a screen that shows battery voltage, load and mains status with a button to switch pages.

  • Board ESP32-S3 DevKitC-1
  • Level ●●○ Intermediate
  • Build time 2–3 h
Pick parts / kit

Comments

No comments yet. Share your experience or ask a question.

Comments are moderated.