enviroPHAT timestamping


Hi All,

I am using python code to extract data from envirphat platform, there is any way to timestamp the sensor readings rather than using python time library

It will be great to have access to the internal timestamp (if it exists) of each sample




I’m not sure what you mean? Using the Python “time” library would be the correct approach, since the sensors themselves have no concept of time.


Sorry, for my confusing message.

Using datetime for example, we will have a time stamp soon after or just before the new sample is acquired. I was wondering if the board has an internal system (referred to its own clock) to timestamp each sample. Even if it is not an absolute reference it could be useful and more accurate (while evaluating timing between different samples)



As @gadgetoid says the sensors have no concept of time. The time it takes to get the sensor data is pretty darn minimal so I doubt you’d gain anything by doing this - if anything, getting the time from the board will be slower than from the time library I’d think.


Yup. No RTC or anything on the board itself, and if there was then, as @archieroques rightfully says, it would take quite considerably longer to request the time from an external source than to call a Python-native function like time.time(), which would render the whole process a little moot!

I’d say your best bet is to make sure your Pi’s clock is well calibrated, then figure out how long it takes to acquire a sample- roughly- and subtract that value from your Python-generated timestamp.

You’d get phase issues with this however, since the Enviro pHAT library configures the ADS1015 to generate 1600 samples per second, which is one sample every 625 microseconds, and you have no way of knowing how old a sample might be at the time you request and receive it, your actual sample age could vary by up to 625uS at a bare minimum. Couple this with the Pi being a multi-tasking OS, and you must add unpredictable delays onto that.

Anyway, I digress! It’s a hard problem without a simple answer.