1. Home
  2. Knowledge Base
  3. energyShield 2 Pro
  4. Using the Real-Time Clock – eS2 Pro

Using the Real-Time Clock - eS2 Pro

The real-time clock (RTC) module on the energyShield 2 Pro provides the user with real, accurate time and date information.

Setting the Time

The RTC is set using the setTimeAndDate(). The easiest way to use this is to run the setTimeAndDate example for the energyShield 2 Pro. This demo allows the user to set the time and date through the serial terminal.

Reading Time and Date Values

When using the NS_energyShield2 library, time and date values are not read directly from the RTC. They are read from a local buffer. The buffer is updated by calling the command readClock(). Therefore, the user must call readClock() every time the program goes to use the time and date data. Once readClock() has been called the user can use the time and date functions (e.g. seconds(), minutes(),  hours(), etc.)  to read values from the buffer.

For more information, take a look at the NS_energyShield2 Library Reference.

Was this article helpful?

Related Articles