I have an embedded board which sends information from IMU sensors along with a timestamp received from a RTC Module.
The Timestamps are obtained from Adafruit's RTClib
The code has a function called unixtime()
which provides me timestamps as follows:
1537466106
1537466107
1537466109
If I enter the above mentioned timestamps in Online Epoch Converter, it provides me the correct time as of today.
I send this information via HTTP and the information gets stored in InfluxDB under imu
measurement as follows:
Query: SELECT * FROM imu LIMIT 100
time eul_x eul_y eul_z liac_x liac_y liac_z location nodeid status
---- ----- ----- ----- ------ ------ ------ -------- ------ ------
1537466106 273.25 -0.88 4.06 -0.06 -0.74 9.81 front node1 0
1537466107 273.25 -0.88 4.12 -0.09 -0.87 9.72 front node1 0
1537466109 273.25 -0.88 4.12 -0.09 -0.86 9.62 front node1 0
1537466110 273.25 -0.88 4.12 -0.07 -0.84 9.67 front node1 0
1537466111 273.25 -0.88 4.12 -0.1 -0.85 9.71 front node1 0
1537466112 273.25 -0.88 4.12 -0.08 -0.86 9.74 front node1 0
1537466113 273.25 -0.88 4.12 -0.04 -0.83 9.7 front node1 0
1537466114 273.25 -0.88 4.12 -0.07 -0.84 9.7 front node1 0
1537466115 273.25 -0.88 4.12 -0.07 -0.85 9.67 front node1 0
1537466116 273.25 -0.88 4.12 -0.06 -0.85 9.67 front node1 0
1537466117 273.25 -0.88 4.12 -0.06 -0.84 9.66 front node1 0
1537466118 273.25 -0.88 4.12 -0.07 -0.83 9.66 front node1 0
1537466119 273.25 -0.88 4.12 -0.09 -0.83 9.68 front node1 0
1537466120 273.25 -0.88 4.12 -0.08 -0.84 9.7 front node1 0
1537466121 273.25 -0.81 4.12 -0.08 -0.87 9.52 front node1 0
1537466123 272.12 -0.81 -3.06 -0.15 0.54 9.74 front node1 0
Now I run an Chronograf Instance on the machine to visualize the data obtained in the above mentioned measurement
Chronograf Query
Strangely the table always keeps showing that the timestamps are point to the Epoch of 1970
Querying a single field from the Database provides the following output:
Research
I read the documents for InfluxDB and they have timestamps for nanoseconds
precision.
On the contrary the timestamps I mentioned above are in fact, correct but why can Chronograf/ InfluxDB not grasp it correctly?
case
I obtain the timestamps as uint32_t
from the RTClib
but I am not sure how do I convert it to nanoseconds precision.
I am sending the timestamp information as a string, is it wise to concat zeros to the string? If So how many zeroes might be required?
Hardware
I am using the DS3231 RTC module which provides a precision of seconds. [1].
According to documentation for InfluxDB's HTTP Write Syntax [2]:
Since Information provided by the RTC is hardware specific, I assume the precision cannot be changed. (doubtful)
Solution
I used the
precision
parameter in the HTTP write syntax in my Arduino Sketch as follows:The
precision
value iss
(in seconds). This will save the information in InfluxDB in the correct way viz.And Visualization is perfect in Chronograf with all the above mentioned Queries in the question.
[1] Adafruit's DS3231
[2] InfluxDB HTTP Write Documentation