Network time protocol in ESP32

Network Time Protocol (NTP) is one of the best ways to synchronize networked computers at the same time. It’s simple, lightweight, and not only does it allow computers to maintain a one-time value together, but it also allows some computer manufacturers to save some money on hardware costs. Raspberry Pi is probably the most well-known example of a low-cost computer without the additional cost of a real-time clock (RTC). Although Pi basically sets up NTP automatically, other microcontrollers like ESP32 do not, but with some functions it is possible to configure them to use this time value.

This project requires the implementation of MicroPython for ESP32. Micropython is a way of running Python code on microcontrollers or other embedded systems that Python does not normally need. Fortunately enough, NTP libraries are built correctly, so once you turn on Micropython in ESP32, it’s as easy as calling a library. Of course you need to make sure you have an internet connection, and then take the time, sync it to the machine and then set the timezone.

For a bonus practice, the creator of the project [Bhavesh] Daylight Savings recommends trying to configure time, although this can be a surprisingly difficult problem to solve. In the meantime, there are several more ways to install a clock in such a microcontroller. An RTC module is an obvious choice, but you can also get an incredibly accurate time using a GPS module.

Leave a Reply

Your email address will not be published.