ESP32 Time and Temperature Display

by khinds10 in Circuits > Arduino

143 Views, 0 Favorites, 0 Comments

ESP32 Time and Temperature Display

IMG_20250211_154256.jpg

ESP32 Time and Temperature Display

This project uses an ESP32 microcontroller to display the current time and temperatures on three TM1637 displays. The first display shows the current time in 12-hour format with a blinking colon and PM indicator. The second display shows the indoor temperature from a DHT22 sensor. The third display shows the outdoor temperature fetched from an online weather API.

Using openweather API - https://openweathermap.org/api/one-call-3

Supplies

Components Required

  1. 1 x ESP32 Development Board
  2. 3 x TM1637 4-Digit 7-Segment Displays
  3. 1 x DHT22 Temperature and Humidity Sensor
  4. Jumper wires
  5. 5mm Tinted Plexiglas

Connect Components - Flash the ESP32

Wiring Diagram


TM1637 Displays


  1. Display 1 (Time)
  2. CLK1: GPIO 22
  3. DIO1: GPIO 23
  4. Display 2 (Indoor Temperature)
  5. CLK2: GPIO 19
  6. DIO2: GPIO 21
  7. Display 3 (Outdoor Temperature)
  8. CLK3: GPIO 32
  9. DIO3: GPIO 25

DHT22 Sensor

  1. VCC: 3.3V or 5V
  2. GND: Ground
  3. Data: GPIO 18

Notes

  1. Ensure all components share a common ground with the ESP32.


Software Setup

Prerequisites

  1. PlatformIO installed on your development environment.
  2. An internet connection for the ESP32 to fetch weather data.

Check out the Git Repository

https://github.com/khinds10/ESP32-3-Display-Clock

This includes the STL files for 3D printing as well as the code to upload to the ESP32 to get it to run.

Configuration

  1. Copy Configuration File
  2. Copy src/config_shadow.h to src/config.h and update the configuration values:
cp src/config_shadow.h src/config.h


Edit config.h

Update the following configuration values in src/config.h:


Time Settings

#define TIME_ZONE -5 // Your timezone offset from UTC (e.g., -5 for EST)
#define DST_OFFSET 1 // Daylight Saving Time offset (1 for DST, 0 for no DST)


Display Brightness (0-7)

#define TIME_DISPLAY_BRIGHTNESS 3 // Brightness for time display
#define INSIDE_TEMP_BRIGHTNESS 1 // Brightness for indoor temperature display
#define OUTSIDE_TEMP_BRIGHTNESS 1 // Brightness for outdoor temperature display


Temperature Calibration

#define TEMP_OFFSET 0.0 // Temperature offset in degrees (adjust if sensor readings need calibration)


WiFi Settings

const char* ssid = "Your_WiFi_SSID";
const char* password = "Your_WiFi_Password";


Data Services Configuration

// DataHub API endpoint
const char* datahub_host = "https://your.datahub.endpoint";

// Weather API settings
const char* weather_api_endpoint = "https://your.weather.api.endpoint";
const char* device_name = "your-device-name";
const char* zipcode = "your-zipcode";

// Location coordinates (for weather data)
float latitude = YOUR_LATITUDE; // e.g., 40.7128
float longitude = YOUR_LONGITUDE; // e.g., -74.0060


Create an account on openweathermap.org to get the right weather data for outside conditions.

The API call being used is: https://openweathermap.org/api/one-call-3

Note: Data API is optional

It's built from the following project:

https://github.com/khinds10/DeviceHub


Update Intervals

// Weather updates
const unsigned long WEATHER_UPDATE_INTERVAL = 60000; // Weather update interval in milliseconds

// Loop manager settings
const int API_UPDATE_INTERVAL = 600; // Update API every 600 samples (10 minutes)
const int RESTART_THRESHOLD = 1800; // Restart after 1800 samples (30 minutes)


These settings control how often the device:

  1. Fetches new weather data (WEATHER_UPDATE_INTERVAL)
  2. Sends data to your API endpoint (API_UPDATE_INTERVAL)
  3. Automatically restarts to prevent memory issues (RESTART_THRESHOLD)


Pin Configuration

The default pin configuration is set up for common ESP32 boards. If you need to change the pin assignments, modify these values:

// Display pins
#define CLK1 22 // Time display clock
#define DIO1 23 // Time display data
#define CLK2 19 // Indoor temperature display clock
#define DIO2 21 // Indoor temperature display data
#define CLK3 32 // Outdoor temperature display clock
#define DIO3 25 // Outdoor temperature display data

// Temperature sensor pin
#define DHTPIN 18 // DHT22 data pin


Building and Uploading

  1. Connect your ESP32 to your computer via USB.
  2. Open the project in your PlatformIO environment.
  3. Build and upload the firmware to the ESP32.

Build Process

IMG_20250210_153743.jpg
IMG_20250210_160401.jpg
IMG_20250210_160556.jpg
IMG_20250210_161437.jpg
IMG_20250210_153811.jpg

Using the 3DPrint/ folder 3D print the STL files to create the case for the project.

Mount the Displays using hot glue to the front panel, also cut and hot glue the Plexiglas (the case allows for 5mm thick glass)

Carefully close the case using the inner-box going inside the larger outer frame. It should snap close with friction.

Finished

IMG_20250210_164237.jpg
IMG_20250210_164244.jpg

Finished