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
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
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
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
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.
Download Sketch: https://github.com/bnbe-club/network-time-using-esp8266-diy-12