ESP32 Temperature Weather Display for ESP32-S3
An ESP32 display project for ESP32-S3 involving OLED display, DHT22.
Parts and sourceBefore you start
Check the exact OLED display, DHT22 configuration against the upstream wiring or parts list.
Upstream README
ESP32 Temperature Weather Display
ESP32 weather dashboard for a 128x64 OLED display. The firmware connects to Wi-Fi, syncs time with NTP, fetches current weather data from OpenWeatherMap, and also shows local temperature and humidity from a DHT22 sensor.

Features
- Shows date and time on a 128x64 OLED display
- Fetches current weather conditions from OpenWeatherMap over Wi-Fi
- Displays weather icon, description, temperature, humidity, pressure, wind, sunrise, and sunset
- Reads local temperature and humidity from a DHT22 sensor
- Rotates through multiple information pages automatically
- Prints connection and weather debug information to the serial monitor at
115200 - Uses PlatformIO with the Arduino framework
Hardware
- Generic ESP32 development board
- DHT22 temperature and humidity sensor
- 128x64 OLED display
- Jumper wires
- USB cable for power, flashing, and serial monitoring
Wiring Overview
Confirmed from the source code:
- DHT22 data pin ->
GPIO4 - OLED display -> hardware I2C via
U8g2
Typical ESP32 defaults often used for I2C are:
- SDA ->
GPIO21 - SCL ->
GPIO22
OLED I2C displays commonly use address 0x3C, but this should be verified on your hardware.
See docs/hardware.md for a fuller hardware summary, wiring notes, and troubleshooting guidance.
Software Stack
- PlatformIO for project management, build, and upload
- Arduino framework for ESP32 firmware structure and peripheral access
U8g2for OLED graphics and text renderingDHT sensor libraryfor reading the DHT22 sensorArduinoJsonfor parsing the OpenWeatherMap JSON responseWiFi,WiFiMulti,HTTPClient, andtimefrom the ESP32 Arduino core for network connectivity, HTTP requests, and NTP time sync
PlatformIO Environment
The current project configuration uses:
- Environment:
esp32-s3-devkitc-1 - Platform:
espressif32 - Framework:
arduino - Serial monitor speed:
115200
The more common generic PlatformIO board choice for many ESP32 examples is esp32dev, but this project is configured for an ESP32-S3 board, so esp32-s3-devkitc-1 is used here.
Libraries
Configured in platformio.ini:
bblanchon/ArduinoJson: parses the weather API JSON responseolikraus/U8g2: drives the OLED display and renders text/bitmapsadafruit/DHT sensor library: reads local temperature and humidity from the DHT22
Also used from the ESP32 Arduino core:
WiFiandWiFiMulti: connect to one of multiple configured Wi-Fi networksHTTPClient: fetch weather data from OpenWeatherMaptime: sync and format date/time from NTP
Project Structure
.
├── assets/
│ └── temperature-weather-display.jpg
├── docs/
│ └── hardware.md
├── include/
│ ├── config.h
│ └── config.example.h
├── src/
│ ├── images.h
│ ├── status_icons.h
│ └── main.cpp
├── .gitignore
├── LICENSE
├── platformio.ini
└── README.md
Build And Upload
Using the PlatformIO CLI:
pio run
pio run --target upload
pio device monitor --baud 115200
Using VS Code with the PlatformIO extension:
- Open the project folder.
- Build the project.
- Upload to the board.
- Open the serial monitor at
115200.
Configuration
This project uses local configuration for Wi-Fi credentials and the OpenWeatherMap API key.
- Open
include/config.h - Fill in your Wi-Fi SSID/password and OpenWeatherMap API key
- Update
WEATHER_CITYandWEATHER_TIMEZONE - Keep
include/config.huntracked
include/config.h is ignored by Git, while include/config.example.h is intended to remain public.
Example:
static const char* OPEN_WEATHER_MAP_KEY = "YOUR_OPENWEATHERMAP_API_KEY";
static const char* WEATHER_CITY = "Rome,IT";
Interfaces Used
- Wi-Fi: required for NTP sync and OpenWeatherMap access
- I2C: used by the OLED display through the default
Wirebus - GPIO: DHT22 data line on
GPIO4 - Serial: USB serial monitor output at
115200
Weather API Notes
- Service used in the firmware: OpenWeatherMap current weather endpoint
- Polling interval:
10minutes - If the API key is not configured, the firmware still starts and the local DHT22 page remains available
Display Notes
- The source includes support for both
SH1106andSSD1306128x64 OLED displays - The active driver is selected in
src/main.cppby enabling eitherDRIVER_SH1106orDRIVER_SSD1306 - Choose the driver that matches the OLED module you actually have
- The current rotation is
U8G2_R2because the display is mounted upside down in this build - If your display is mounted normally, you can change
U8G2_R2toU8G2_R0
License
This project is released under the MIT License.