OBD-II Precision

Inquiry and support for Freematics products
Post Reply
Leggo
Posts: 3
Joined: Sun Sep 24, 2017 11:58 pm

OBD-II Precision

Post by Leggo »

Hello,
I am trying to get higher precision on some of the PIDs. For example, when reading PID_DISTANCE, is it possible to get a reading with decimal places or is it strictly integers?

I've noticed that the obd.read() command only accepts int values, and does not allow floats, doubles, or bytes.

Thanks for the help,
Anthony
stanley
Site Admin
Posts: 1018
Joined: Sat Mar 01, 2014 3:15 am

Re: OBD-II Precision

Post by stanley »

It's a 16-bit integer value in km. You can measure distance traveled by sampling OBD speed and time elapsed.
Leggo
Posts: 3
Joined: Sun Sep 24, 2017 11:58 pm

Re: OBD-II Precision

Post by Leggo »

Thanks Stanley. I'm trying to think what would be an accurate way to measure this. I think I understand what you are saying.

So use the PID_SPEED function and the Arduino function millis(). Find the difference between each millis() read and multiply that by PID_SPEED. Does that sound right?

Thanks.
stanley
Site Admin
Posts: 1018
Joined: Sat Mar 01, 2014 3:15 am

Re: OBD-II Precision

Post by stanley »

Basically it is like:

distance = (v1 + v2) * (t2 - t1) / 2;
Leggo
Posts: 3
Joined: Sun Sep 24, 2017 11:58 pm

Re: OBD-II Precision

Post by Leggo »

Perfect, that was along the lines of what I was thinking. Thanks Stanley!
Post Reply