What is the best way to get fuel consumption (MPG) using OBD2 parameters?

That's the formula for instant consumption.

If you want to work out average consumption, work out the total volume of fuel used over time and divide by the total distance traveled over the same period.

UPDATE: That is what the ratio SHOULD be. unless you want to melt pistons or lose power. The air/fuel ratio isn't supposed to change unless you change the type of fuel, e.g. to 102 octane Petrol or Ethanol. That calculation is probably the most accurate you'll get unless you want to make it horribly complex by

  1. including the readings from all six O2 sensors to verify optimal combustion took place,
  2. factoring in engine temperature (cooler engines allow better combustion because it allows denser oxygen into the intake manifold),
  3. whether or not timing advance is set properly or not (which you'll have to check against a datasheet).
  4. and whatever else I left out.

Mind you, on the off-chance you're working on a Toyota: Toyota has an extra sensor that actually measures how much fuel is being injected into the engine. So you can just read that PID. But for other cars, the given formula is the standard.

UPDATE 2: some common Air/Fuel Ratios:

  1. Natural gas: 17.2
  2. Gasoline: 14.7
  3. Propane: 15.5
  4. Ethanol: 9
  5. Methanol: 6.4
  6. Hydrogen: 34
  7. Diesel: 14.6

You'll also need to consider that when the engine is under high loads, the Air/Fuel ratio changes downward.


If you can read injector pulsewidth and divide by speed you can get the instant consumption. If you have the total fuel used and a distance, you can get the average. Getting injector pulsewidth is the direct way to get fuel consumption. It is the actual amount of fuel injected (well, it's the time the injector is open, but calculating how much is injected is easy at that point).

Tags:

Obd Ii