« Close

Datasheets and User Guides

Software & Driver


19.0 RTC (T7 Only) [T-Series Datasheet]

Overview - T7-Pro Only

The T7-Pro has a battery-backed RTC (real-time clock) which is useful for assigning timestamps to data that is stored on the microSD card during scripting operations—particularly in situations where the device could experience power failure or other reboots, and does not have a communication connection that can be used to determine real-time after reboot. The system time is stored in seconds since 1970, also known as the Epoch and Unix timestamp.

Battery Life

Typically, the CR2032 battery can be expected to last 12 years. Several factors can influence the expected life including: 

  • Temperatures - Cold temperatures will decrease the battery's life. 
  • Battery age - Batteries naturally discharge as they age. This also has a temperature dependency, but 20% every 10 years is a good rule of thumb. 
  • External Power - When the T7 is powered up the battery is not used to maintain time. This will extend the battery life.

The RTC requires 925 nA to maintain it's time. A typical CR2032 battery has 210 mAH capacity which works out to a life of 25.9 years. We derate our expectations by ~2 to get the above life expectancy.

Reading Time

Read the system time in seconds with address 61500:

Name Start Address Type Access
RTC_TIME_S 61500 UINT32 R    

Get a simple calendar time representation by reading six consecutive addresses, starting with address 61510:

Name Start Address Type Access

To time events faster than 1 second apart, it is possible to read the CORE_TIMER (address 61520) and see how it changes from second to second. To access the core timer value in Lua scripts, use the LJ.Tick() function.

Setting Time

Set the system time by writing a new timestamp (in seconds) to address 61504:

Name Start Address Type Access
RTC_SET_TIME_S 61504 UINT32 W    

To set the T7-Pro's time from a SNTP server, use RTC_SET_TIME_SNTP and SNTP_UPDATE_INTERVAL:

Name Start Address Type Access


[Lua] Read the value of the RTC in a Lua script

table = {}
table[1] = 0    --year
table[2] = 0    --month
table[3] = 0    --day
table[4] = 0    --hour
table[5] = 0    --minute
table[6] = 0    --second

table, error = MB.RA(61510, 0, 6)
print(string.format("%04d/%02d/%02d %02d:%02d.%02d", table[1], table[2], table[3], table[4], table[5], table[6]))

>> 2014/10/15 18:55.22

[C/C++] Read the value of the RTC in C/C++

int LJMError;
double newValue;
LJMError = LJM_eReadAddress(handle, 61500, 1, &newValue);
//returned value of 1413398998 would correspond with Wed, 15 Oct 2014 18:49:58 GMT