Hardware Project

ESP32 WiFi Temperature Monitor with OLED Display

May 20, 2026 5 min read
ESP32 Project

The Problem

I needed a reliable way to monitor ambient temperature in my server rack and get an immediate visual reading without logging into a dashboard. The device also needed to push data to Home Assistant over MQTT for historical logging.

Hardware

System Architecture

graph TD A[ESP32 MCU] -->|I2C| B[SSD1306 OLED] A -->|One-Wire| C[DHT22 Sensor] A -->|WiFi/MQTT| D[Home Assistant] D -->|Persistence| E[InfluxDB] D -->|Visualization| F[Grafana Dashboard]

Wiring Logic

graph LR subgraph ESP32_Pins GND[GND] V33[3.3V] D21[D21 - SDA] D22[D22 - SCL] D4[D4 - DATA] end subgraph DHT22 D_VCC[VCC] D_GND[GND] D_DATA[DATA] end subgraph OLED_SSD1306 O_VCC[VCC] O_GND[GND] O_SDA[SDA] O_SCL[SCL] end V33 --> D_VCC GND --> D_GND D4 --> D_DATA V33 --> O_VCC GND --> O_GND D21 --> O_SDA D22 --> O_SCL

The Code

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "DHT.h"

#define DHTPIN 4
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);
Adafruit_SSD1306 display(128, 64, &Wire, -1);

void setup() {
  Serial.begin(115200);
  dht.begin();
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}

Result

The build works perfectly. The OLED refreshes every 2 seconds and the Serial Monitor shows clean output. The device successfully integrated into my Home Assistant instance via MQTT.

> SYSTEM_LOG.EXE

[2026-05-20 14:32:01] SUCCESS: MQTT Connection established with HA_BROKER
[2026-05-20 14:32:05] SUCCESS: DHT22 Sensor calibration complete
[2026-05-20 14:32:10] INFO: Initial temperature reading: 24.5C / 42% RH
[2026-05-20 14:32:15] SUCCESS: System status: OPERATIONAL