Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Timestamp on Reading Multi Sensors in Console Log

ANSWERED

Hello

 

I try to use console.log for recording the values from multi-sensors.

 

eg. 

 

Parkpoom_1-1653866521833.png

 

On addEventListener "reading" of each sensor return a different timestamp.

 

Parkpoom_0-1653866308329.png

Even though the time series appears the left can rely on it.

Is there any solution to synchronous timestamps of these values together?

 

Thank you,

Parkpoom

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Sensor timestamps start from an arbitrary value; not necessarily the current time of day. If you need to know the actual time, you could capture it from the Date object. While you could do that for every reading, it would be more efficient to capture it for the first reading, calculate the difference between Date and sensor timestamp, and then use that difference to adjust all subsequent readings. If you're recording data in real-time, you may want to defer that correction until AFTER you've finished recording.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
3 REPLIES 3

Sensor timestamps start from an arbitrary value; not necessarily the current time of day. If you need to know the actual time, you could capture it from the Date object. While you could do that for every reading, it would be more efficient to capture it for the first reading, calculate the difference between Date and sensor timestamp, and then use that difference to adjust all subsequent readings. If you're recording data in real-time, you may want to defer that correction until AFTER you've finished recording.

Peter McLennan
Gondwana Software
Best Answer

Dear Peter,

 

Thank you for your helpful guidance.

 

Best Regards,

Parkpoom

Best Answer

In this post, I would like to share the date time code for each sensor which I use in the reading event. It works for me.

Hope this is useful for developers who may have the same issue.

 

var isoDateString = new Date().toISOString();

console.log(
`${isoDateString},${gyro.timestamp},Gyroscope Reading:,${gyro.x},${gyro.y},${gyro.z},`
);

 

Parkpoom_0-1653908057951.png

 

Thank you

Best Answer