Zenseio Blog

IoT Epoch Time Disaster? Only Time Will Tell
Numerous clocks representing the passage and monitoring of time

Ever heard of the “epoch time”? I’m not talking here about  history periods or geology. Epoch time is simply a standardized time and date reference used in UNIX and many other computers. It defines time, measured in seconds, starting from January 1, 1970 epoch. This is based on an arbitrary, somewhat historical epoch, but, what matters is that it is a commonly followed standard.

Why is this important and what does it have to do with IoT? Many IoT sensor devices have to keep track of time, so when they collectdata readings from sensors, they time-stamp them. IoT devices may collect sensor data for hours, days or weeks before sending them to the Cloud for Big Data analytics. Time-stamping helps to precisely know when the data was measured, not when it was received by a Cloud server. This is very important if the data analytics is to be correct and accurate.

Many IoT devices use what is called Real Time Clock (RTC, for short) to keep track of time. It’s a very low power electronic circuit that counts pulses from an internal clock generator. These pulse counts are converted to seconds and, then, the seconds are counted. What is the count referenced to? A convenient epoch (and, sometimes, the only one possible) is the time of the device power up. But then, the time reference would vary greatly from one device to another. If one device was powered up a month ago and another one yesterday, they  would be both showing different timestamps for the data measured at the same time, say an hour ago. Exacerbating the problem, this time-stamp reference could never be relied upon in absolute terms since the devices could be powered up at arbitrary time. It’s only good for relative time-stamps.

So, this is where the epoch time can be helpful. It’s the standard that all Cloud servers already use. There are standard software libraries written to convert human readable time to epoch time. These libraries have been ported even to IoT devices and utilized to support the epoch time reference (provided they have a communication downlink to synchronize the time reference from the Cloud server, in the first place).

Looks peachy – so, what’s the problem? Well, the IoT devices are very resource constrained because of their low power and low cost requirements. They typically use 32-bit counters for keeping the epoch time. A 32-bit signed counter can hold up to 2^32 values. That is 2,147,483,647 seconds. A quick calculation shows that this seconds counter will overflow sometime on 19 January 2038 – about 21 years from now. For industrial IoT devices this is definitely within their active deployment lifespan. But until the time rolls around, few will worry about these device limitations.

What will happen is that the sensor data time-stamps suddenly wrap around to start from January 1, 1970. Remember “Y2K bug” deja-vu, anyone? Perhaps the Big Data analytics AI algorithms may get very confused about this and draw wrong decisions and cause massive damage. Or perhaps, the AI may be smart enough to figure out what’s wrong and readjust the timestamps without a hiccup. Only time will tell.

But, why risk it? There are solutions that can be used today, that make this epoch time overflow a non-issue.

At Zenseio, we specialize in robust, industrial IoT sensor devices. In our hardware platform, we pay attention to details big and small, so our customers don’t have to worry about them. We are quality freaks.