When working with Samsara’s platform to track vehicle mileage, it’s important to understand the nuances of how mileage is measured and reported. You can obtain three key mileage-related data points from the Vehicle Stats History API:Documentation Index
Fetch the complete documentation index at: https://samsara-showcase.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
obdOdometerMeters– The odometer reading reported by the vehicle’s onboard diagnostics (ECU).gpsDistanceMeters– The distance traveled (in meters) since the Samsara Vehicle Gateway was installed, based on GPS calculations.gpsOdometerMeters– The GPS-based “odometer” reading, which can be manually edited by the customer in Samsara to correct odometer readings for vehicle maintenance and other use cases.
Recommendation: use obdOdometerMeters
We recommend using obdOdometerMeters as your primary mileage data source. Fleets commonly rely on the ECU odometer read to track usage and service intervals. However, there are scenarios where the vehicle’s ECU does not provide diagnostic coverage for odometer readings. In these cases:
- Fallback to
gpsDistanceMeters: If noobdOdometerMetersvalue is available, usegpsDistanceMetersto calculate distance traveled for the time period. - Avoid
gpsOdometerMetersfor general mileage: This value is only used if (a) the ECU does not report odometer data and (b) a customer has manually edited in a “starting odometer” in Samsara. While useful for fleet maintenance intervals within Samsara, this value may not reflect the true mileage unless your use case specifically requires the manually edited reading.
How to retrieve distance data
The example below shows how to pull odometer and distance information for vehicles over a specified time period. Example requestobdOdometerMeters.value: Odometer reading in meters from the onboard diagnostics system.gpsDistanceMeters.value: The distance in meters traveled based on GPS since the Vehicle Gateway was installed.gpsOdometerMeters.value: A GPS-based odometer that may have been manually overridden in the Samsara UI.
How to calculate distance for a time range
- Check
obdOdometerMeters:
If available, calculate the difference between the odometer readings at the start and end of the period. - Use
gpsDistanceMetersifobdOdometerMetersis missing:- If no ECU reading is present, you can use
gpsDistanceMetersto see how much the vehicle traveled during the same period. - Keep in mind,
gpsDistanceMetersaccumulates from the time the gateway is installed, so typically you would calculate distance by comparing values from two timestamps.
- If no ECU reading is present, you can use
- Do not rely on
gpsOdometerMetersfor general usage:- This is primarily for manual maintenance interval tracking. Unless your specific workflow requires the manual data entered by the fleet manager, avoid using
gpsOdometerMetersas a general source of truth for mileage.
- This is primarily for manual maintenance interval tracking. Unless your specific workflow requires the manual data entered by the fleet manager, avoid using
Handling potential data gaps
- Missing odometer readings:
If the ECU read is missing or invalid (e.g., certain vehicles do not report an odometer), always fall back ongpsDistanceMeters. - Jumps in odometer values:
If you see a large jump inobdOdometerMeters, verify that the Vehicle Gateway was properly associated and configured for this vehicle, and that a different vehicle wasn’t accidentally assigned the same gateway.
Putting It All Together
Below is an example that might be used to calculate daily distance traveled:By combining these data fields, you can build robust mileage-tracking features in your integration:
- Prefer ECU odometer (
obdOdometerMeters.value) where available. - Fallback to GPS distance (
gpsDistanceMeters.value) in the absence of ECU coverage. - Avoid manual “GPS odometer” (
gpsOdometerMeters.value) unless your specific workflow requires it for maintenance logs.