15 Просмотры
Implementing an OLED Display based NTP Clock with Deep Sleep using the SparkFun ESP32 Thing.

In this video, we will create an OLED Display based NTP Clock, which will wake from deep sleep to synchronize and update once every minute. We will also display the current date on the OLED Display. Finally, we will give you an activity to incorporate GPS location service to this project, and implement deep sleep in it yourself.

(If you liked this video and would like to buy our course, you are in for a pleasant surprise. Please click on the link below to buy the course for $25 ONLY. Original price is $195.

The idea of timekeeping is of prime concern in many applications. For example, imagine a data logger that has to store values at regular intervals, or a relay that has to activate at a certain time. We generally use a Real Time Clock Module to keep track of the time. But there are several disadvantages in using an RTC Module for projects. For instance, they need to be manually synchronized regularly to avoid errors in timings. Furthermore, they require a separate power source, like a Button Cell. At some point in time, we will need to replace the battery.

As the ESP32 can connect wirelessly to the internet, the easiest solution is to use the Internet itself to keep track of the time. The solution here is to use Network Time Protocol, with which you can get precise date and time, for free, that too without the need for any additional hardware. Furthermore, unlike the RTC Module, you don’t need to worry about additional power or manual synchronization when using NTP.

So what is NTP?

It’s a standard Internet Protocol for synchronizing the computer clocks to some reference over a network. NTP sets the clocks of computers to Coordinated Universal Time, any local time zone offset or daylight saving time offset is applied by the client. In this manner, clients can synchronize to servers regardless of location and time zone differences. The NTP system is based on Internet time servers. These are computers with access to atomic clocks such as those operated by the U.S. government.

NTP uses a hierarchical architecture. Each level in the hierarchy is known as a stratum. At the very top are high-precision timekeeping devices, such as atomic clocks, GPS or radio clocks, known as stratum 0 hardware clocks. Stratum 1 servers have a direct connection to a stratum 0 hardware clock and therefore have the most accurate time. Each stratum in the hierarchy synchronizes to the stratum above and act as servers for lower stratum computers.

Now let us look at how the NTP works?

●First, the client device such as ESP32 connects to the server using the User Datagram Protocol on port 123.
●Then the client transmits a request packet to an NTP server.
●In response to this request, the NTP server sends a timestamp packet.
●The timestamp packet contains multiple information like UNIX timestamp, accuracy, delay or timezone.
●Finally, the client can then parse out current date & time values.

In the Deep Sleep project, we will implement NTP and show the current time and date on the OLED display. The project will be in deep sleep mode for the 58 seconds of every minute and then wake up for 2 seconds to synchronize and update the display. After that, it will go to deep sleep mode, and this cycle continues. The choice to use OLED Display was to reduce the power consumption further.

Now let's start the project. First, wire up the OLED Display to your ESP32.

Now open the “NTPOLED_DEEP_SLEEP.ino” file from the downloaded repository. I will now explain the code. The code starts with the macro definitions for the conversion factor for the deep sleep. Here we will deep sleep for 58 seconds.

The “WiFi.h” library provides ESP32 specific WiFi methods which helps us to connect to the network, while the “time.h” is the native time library of ESP32 which does NTP Server synchronization.

In this video, we have covered the following topics
●Implement OLED Display based NTP Clock with Deep Sleep
●An activity to integrate GPS Tracking with Deep Sleep

(If you liked this video and would like to buy our course, you are in for a pleasant surprise. Please click on the link below to buy the course for $25 ONLY. Original price is $195.

Check us out on
Website :
Catalogue :
Facebook :
Twitter :
LinkedIn :
Instagram :
Email :
Комментариев нет.