Community project

ESP32 Environmental Dashboard

Photo of ESP32 Environmental Dashboard
Generated with AI

Thaleo

Published November 29, 2026

Build a real-time environmental monitoring display that reads temperature, humidity, and distance on a compact OLED screen. This ESP32 project combines a DHT11 sensor for climate data and an HC-SR04 ultrasonic sensor for proximity detection, with a status LED that confirms all readings are valid.

The guide includes a complete wiring diagram, parts list, and step-by-step assembly instructions for breadboard construction. Upload the provided firmware to get a live dashboard that samples temperature and humidity every 2 seconds and distance every 500 milliseconds, with serial output for debugging.

Wiring diagram

Wiring diagram for ESP32 Environmental Dashboard
Loading diagram…

Gather all the parts

QtyComponent
1

SSD1306 OLED

0.96-inch 128 x 64 white monochrome OLED display module driven by an SSD1306 controller over I2C (address 0x3C). It runs from 3 V to 5 V and connects through a 4-pin 2.54 mm header (GND, VCC, SCL, SDA); the self-emitting pixels need no backlight.

1

DHT11

Digital temperature and humidity sensor (lower accuracy than DHT22)

1

HC-SR04

HC-SR04 ultrasonic distance sensor module with separate 40 kHz transmitter and receiver transducers, measuring 2 to 400 cm. A 10 us pulse on TRIG starts a measurement and ECHO stays high for the echo's round-trip time. This HC-SR04+ board runs from 3.3 V or 5 V.

1

Resistor

2.2 kohm, 1/4 W, 5%

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

3.3 kohm, 1/4 W, 5%

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

10 kohm, 1/4 W

Through-hole resistor (current-limiting in series with an LED)

1

LED

green

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

Resistor

330 ohm, 1/4 W

Through-hole resistor (current-limiting in series with an LED)

Assemble it in 6 steps

1. Prepare the breadboard without power

Unplug USB. Use the board's printed GPIO labels, not physical pin positions. Place modules on the breadboard with jumper wires; keep the ultrasonic transducers unobstructed. Make separate 3.3 V, 5 V and ground rails. Join split rail sections where needed.

  • Never join the 3.3 V and 5 V rails. Use USB power only; do not attach another power supply.

2. Connect the OLED

OLED VCC to 3V3, GND to ground, SDA to GPIO8 (data), SCL to GPIO9 (clock). Check printed VCC/GND labels because their order varies.

  • Use 3.3 V so the screen's I2C pull-ups cannot put 5 V onto the ESP32 pins.

3. Connect temperature and humidity

DHT11 VCC to 3V3, GND to ground, DATA to GPIO4. Add the 10 kohm resistor between DATA and 3V3; it keeps the data line high between messages. For a bare four-leg DHT11, viewed from its perforated front with legs down: VCC, DATA, unused, GND. On a module, follow the printed labels instead. Keep it away from the warm ESP32.

4. Protect the ultrasonic echo input

HC-SR04 VCC to USB-powered 5V, GND to ground, TRIG to GPIO5. ECHO goes to one end of the 2.2 kohm resistor. Its other end is the junction connected to GPIO6 and one end of the 3.3 kohm resistor. The remaining 3.3 kohm end goes to ground. This divider reduces a 5 V echo to 3.0 V. TRIG sends the measurement pulse; ECHO reports its travel time.

  • Never connect ECHO directly to GPIO6. Reversing the divider resistors raises the voltage. Use the specified values, preferably measured before powering.

5. Add the green status light

GPIO7 to the 330 ohm resistor, resistor to LED anode (usually long leg), LED cathode (short leg/flat edge) to ground. The resistor limits LED current. The LED lights when the screen and all latest sensor readings are valid.

6. Check before powering

Verify all ground connections share one rail and no power rails are shorted. Confirm OLED and DHT power is 3.3 V, sonar power is 5 V, and GPIO6 connects only to the divider junction. Aim the sonar at a broad flat object 10 to 100 cm away for the first test.

  • DHT11 is a basic indoor sensor, not a precision instrument. A missing or out-of-range echo is displayed as --, not zero.

Review all connections

1. Connections between "oled" and "ESP32"

FunctionoledESP32
powerVCC3V3
groundGNDGND
i2cSDAGPIO 8
i2cSCLGPIO 9

2. Connections between "climate" and "ESP32"

FunctionclimateESP32
powerVCC3V3
groundGNDGND
dataDATAGPIO 4

3. Connections between "dht_pullup" and "ESP32"

Functiondht_pullupESP32
powerP13V3
digitalP2 → DHT11 DATAEXT

4. Connections between "sonar" and "ESP32"

FunctionsonarESP32
powerVCC5V
groundGNDGND
digitalTRIGGPIO 5
digitalECHO → Resistor P1EXT

5. Connections between "echo_top" and "ESP32"

Functionecho_topESP32
digitalP2GPIO 6

6. Connections between "echo_bottom" and "ESP32"

Functionecho_bottomESP32
digitalP1 → Resistor P2EXT
groundP2GND

7. Connections between "led_limit" and "ESP32"

Functionled_limitESP32
digitalP1GPIO 7
digitalP2 → LED ANODEEXT

8. Connections between "status" and "ESP32"

FunctionstatusESP32
groundGNDGND

Deploy the firmware

#include <Arduino.h>
#include "Station.h"
ClimateSensor climate(Pins::DHT_PIN);
DistanceSensor sonar(Pins::TRIG_PIN,Pins::ECHO_PIN);
Dashboard dashboard;
Readings readings;
uint32_t lastClimate=0,lastDistance=0;
bool displayOK=false;
void setup() {
  Serial.begin(115200);
  pinMode(Pins::LED_PIN,OUTPUT); digitalWrite(Pins::LED_PIN,LOW);
  climate.begin(); sonar.begin();
  displayOK=dashboard.begin();
  Serial.println(displayOK ? "OLED ready" : "OLED missing: check power/SDA/SCL");
  dashboard.update(readings);
}
void loop() {
  uint32_t now=millis();
  bool changed=false;
  if (now-lastClimate>=2000) {
    lastClimate=now; climate.sample(readings); changed=true;
    Serial.printf("Temperature %.1f C, RH %.1f %%\n",readings.temperature,readings.humidity);
  }
  if (now-lastDistance>=500) {
    lastDistance=now; readings.distance=sonar.sample(); changed=true;
    Serial.printf("Distance %.1f cm\n",readings.distance);
  }
  if (changed) {
    dashboard.update(readings);
    digitalWrite(Pins::LED_PIN,displayOK && !isnan(readings.temperature) && !isnan(readings.humidity) && !isnan(readings.distance));
  }
  delay(1);
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik