Network Time Using ESP8266

Network Time Using ESP8266

We learn how to build a cute little digital clock that communicates with NTP servers and displays network or internet time. We use the WeMos D1 mini to connect to a WiFi network, obtain the NTP time and display it on an OLED module.

The video above talks you through the entire process of building this project.

Step 1: Gather the Electronics

We Need The WeMos D1 Mini And A 0.96 oled moduleWe Need The WeMos D1 Mini And A 0.96″ OLED Module

To build this project, you will need a WeMos D1 mini or compatible board that uses the ESP8266 chipset along with an OLED module. The sketch should also work with the ESP32 boards but I haven’t tested this.

Step 2: Edit and Upload the Sketch

Sketch ModulesSketch Modules

Add Your WiFi CredentialsAdd Your WiFi Credentials

Set The Time Zone For Your RegionSet The Time Zone For Your Region

Install The U8g2 LibraryInstall The U8g2 Library

Add The ESP8266 BSP URLAdd The ESP8266 BSP URL

Install The ESP8266 BSPInstall The ESP8266 BSP

Select The Correct Board SettingsSelect The Correct Board Settings

Make Sure The Correct Time Is PrintedMake Sure The Correct Time Is Printed

Download the sketch using the link at the bottom of this post and open it using the Arduino IDE.

Start by adding your network credentials as we need to connect to a WiFi network. Then, make sure you add the correct time zone information. You can visit the following link to obtain the relevant time zone string for your region: https://remotemonitoringsystems.ca/time-zone-abbreviations.php

Before you can upload the sketch, make sure that you have installed the U8g2 library along with the board support package for the ESP8266 boards. Check the images for further information or watch the video for detailed instructions. Once completed, plug in the board and make sure you have selected the right board settings as seen in the image. Then, hit the upload and wait for it to complete.

Once uploaded, open up the serial monitor and make sure that the correct time is being displayed. If not, make sure you have selected the right time zone for your region.

Step 3: Connect the OLED Module

Wiring Connections For OLED ModuleWiring Connections For OLED Module

Wire Up The OLED Module And TestWire Up The OLED Module And Test

Use the wiring diagram above to connect the OLED module to the microcontroller board. Power on the board and you should see the time displayed on the module.

Step 4: Add the Modules to the Enclosure

The 3D Printed EnclosureThe 3D Printed Enclosure

Wire The OLED, Add Double Sided Tape And PlaceWire The OLED, Add Double Sided Tape And Place

Wire up The OLED To The WeMosWire up The OLED To The WeMos

Final Build Top ViewFinal Build Top View

Final BuildFinal Build

Once you’re happy with the results, download and 3D print the model from the following link: https://www.thingiverse.com/thing:857858

The board sits on the back cover while the OLED module sits at the end of the enclosure. You can use double-sided tape to hold the OLED module in place and you can also add a bit of hot glue near the wires to keep it in place. Solder the wires from the OLED module to the microcontroller board and then seal the unit by using some glue to hold it together. Plugin the microUSB cable and it should work as expected.