Reading noisy fuel data from cars: what OBD doesn’t tell you
The fuel level jumped up and down while the car was simply driving. Nobody added fuel, and nobody took any. The data was lying.
On this page
Key takeaways
- The fuel sensor measures the surface, not the volume — slopes and braking move it.
- A moving average hides real refuels. Use a median, then speed-aware smoothing.
- Only trust a change that lasts minutes while the vehicle is stopped.
Where the number comes from
Most vehicles report fuel level through the OBD port as a percentage from a float sensor in the tank. The sensor measures the surface of the fuel, not the volume. When the vehicle accelerates, brakes, climbs or parks on a slope, the surface tilts and the reading moves — sometimes by 8% in a few seconds.
- 01 Float sensor
- 02 OBD / CAN
- 03 Device
- 04 Filter
- 05 Alert
Why a moving average isn’t enough
A simple moving average smooths the line but also smooths the real events. A 60-litre refuel becomes a slow ramp, and a real drain disappears into the curve. You need a filter that removes spikes but keeps steps.
Remove the spikes, keep the steps. That is the whole job of a fuel filter.
// rolling median, then speed-aware EMA
const m = median(window(raw, 11));
const a = speed > 5 ? 0.08 : 0.25;
level = level * (1 - a) + m * a;
Only trust change when the car is still
The final rule is simple: report a refuel or drain only if the change is larger than the noise band and persists for several minutes while the vehicle is stationary. This one rule does most of the work against false alerts.
All charts and numbers in this article use sample data.
What OBD still doesn’t tell you
Tank shape. A 10% drop at the top of a saddle tank is not the same volume as 10% at the bottom. Calibrate per vehicle model, or your litres will be wrong even when your percentages are right.
- Telematics
- OBD
- Signal processing
Was this article useful? Thanks for the feedback!
Software & AI Engineer in Riyadh. I write about building systems where mistakes are expensive.