Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How to design an IoT-based digital watch using ESP32

By Nikhil Agnihotri April 23, 2024

In this project, we’ll design a digital watch as an Internet-of-Thing (IoT) device. It will connect to an online API through a Wi-Fi network. Based on the user’s location, it will display the local date, time, and weather conditions. 

The watch is built using an ESP32 microcontroller and an SSD1306 OLED display. The Weather API retrieves the date, time, and weather information.

Components required 

  1. ESP32 x1
  2. SSD1306 OLED x1
  3. Connecting/Dupont wires

Circuit connections
To design the digital watch, we must interface SSD1306 OLED with ESP32. SSD1306 is used as an SPI interface and has the pin diagram below. 

To interface the SSD1306 OLED with ESP32, follow the circuit connections described in the table below.

The circuit diagram of the digital watch:

Registering with Weather API
This IoT digital watch relies on the Weather API. Register for an account on WeatherAPI.com (click on the “sign up” button), and you’ll receive an API key to build this project. 

Complete the sign-up process by filling out the request information on the form.

Next, you’ll receive a confirmation e-mail. Open your email and confirm your Weather API account.

After confirming your Weather API account, login to WeatherAPI.com with your registered credentials.

After you will login, your API key will be shown. Make a note of this API key for use in the device code.

Arduino sketch
After making the circuit connections and noting your API key from WeatherAPI.com, upload the following sketch to ESP32. Remember to replace your Wi-Fi credentials and API key in the sketch.

How it works
The IoT-based digital watch easily retrieves and displays the date, time, and weather information from the Internet. When the watch is powered on, it initializes the OLED (organic light-emitting diode) display. Then, it retrieves the date, time, and weather information from the Weather API by connecting to the local Wi-Fi network. These network credentials are hard coded in the watch’s sketch. 

The data received from the online API is in JSON format. The device sifts through the required data fields from the JSON data to retrieve the correct date, time, and weather information. This data is then rearranged in a proper format and displayed over the SSD1306 OLED. The watch retrieves the date, time, and weather information every ten milliseconds. 

The code
The sketch begins by importing the SPI.h, Wire.h, Adafruit_GFX.h, Adafruit_SSD1306.h, WiFi.h, HTTPClient.h, and ArduinoJson.h libraries. 

  • The SPI.h, Wire.h, Adafruit_GFX.h, and Adafruit_SSD1306.h libraries are required to work with the SSD1306 OLED. 
  • The WiFi.h and HTTPClient.h libraries connect the watch to the Internet via a Wi-Fi connection. 
  • The ArduinoJson.h sifts through the JSON data from the API. 

Next, ESP32’s pin assignments with SSD1306 are declared. An object of Adafruit_SSD1306 is instantiated. The variables are declared to store the Wi-Fi SSID and password and the Weather API key. 

The variables are declared to store date, time, day, temperature, and humidity values. An object of the StaticJsonDocument class is instantiated to store the received JSON data. 

In the setup() function, the baud rate for serial debug messages is set to 115200 bps. The Wi-Fi connection is initialized, and the local IP address is printed to the serial console. The SSD1306 OLED display is also initialized. 

The user-defined function, stringToCharArray(), is defined to extract the year, month, date, hour, and minute values from the string received as the “datetime” in JSON data. 

In the fetchData() function, ESP32 makes an HTTP request to the Weather API and receives the HTTP response from the API as a payload. The payload is received as JSON data and sifted through for the required date, time, and weather information, which are extracted into global variables and declared. The weekday is calculated by implementing Zeller’s congruence. 

In the loop() function, the date, time, day, and weather information are received by calling the fetchData() function. The data fields are displayed on the OLED screen in a pre-determined visual layout.  

Results

You may also like:


  • How to build a facial recognition system using ESP32-CAM

  • What temperature sensors are used for electronics and IoT devices?

  • How to make an Internet clock using ESP8266

  • What are the top weather APIs for the IoT?

  • How to design an IoT-based smart alarm

Filed Under: Electronic Projects
Tagged With: digitalwatch, electronicproject, ESP32, internetofthings, IoT, weatherapi
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • High Side current sensing
  • The comparison of different Tcl script checkers
  • Voltage mode pushpull is a nonsense SMPS?
  • Reducing "shoot-through" in offline Full Bridge SMPS?
  • How to simulate power electronics converter in PSpice?

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe