Diesel Engine Fuel Consumption Calculation
Introduction
Calculating the fuel consumption for a diesel engine car requires more complex algorithms, taking the lambda/O2 probe measurements into account. Not every car provides lambda probe values over OBDII, hence consumption calculation is currently only supported for a subset of diesel cars.
Parameters
The following parameters are required for estimating fuel consumption:
Parameter 
Abbrevation 
unit 
provided by 
minimum required air for diesel = 14.5 
MRAD 

constant 
diesel fuel density = ~ 0.83 
DFD 
kg/l 
constant 
Intake air pressure 
IAP 
kPa 
OBDII 
Intake air temperature 
IAT 
°C 
OBDII 
Mass air flow 
MAF 
kg/s 
OBDII 
Vehicle speed 
Speed 
km/h 
OBDII 
O2 lambda equivalence ratio 
O2 EQ 
(ratio) 
OBDII / statistics 
mass fuel flow = MAF * 3600 / (O2 EQ * MRAD) 
MFF 
kg/h 
onthefly calc 
volumetric fuel flow = MFF * DFD 
VFF 
l/h 
onthefly calc 
Fuel consumption = VFF * 100 / Speed 
FC 
l/100km 
onthefly calc 
Fuel Consumption
The app calculates the current (distinct) fuel consumption as volmetric fuel flow (
l/h) for each measurement point. It is assumed that there is no fuel consumption at all for Lambda Voltage values > 1.1V. The transformation to
l/100km is done after finishing a track route:
Fuel consumption = average(VFF) * total_duration / total_distance * 100
 total_duration provided as hours
 total_distance as kilometres
O2 Lambda Equivalence Ratio
We have observed that O2 lambda ER data provided via OBDII is often capped at a value of 2.0. Thus the formula breaks as the actual value is likely to exceed that threshold. The app uses the derived lambda ER formula if it observes a OBD lambda ER value > 1.97.
Using statistic methods it is possible to create a regression function using the O2 lambda voltage which is also provided when O2 lambda ER is available. The result is a function of the form

f(x) = a / ( b  c * x )
 where x is the Lambda Voltage value
The coefficients might vary across different cars and engines. This has to be evaluated. For a VW Passat B6 2.0l TDI we have calculated the following coefficients from a given track:
Calcuating the Regression function (DEPRECATED)
The regression function is assumed static for all cars at the moment. The following is kept for the sake of completness:
In order to get a fealing on how such a regression function varies across different cars, a first step would be to calculate a similar function for
 different tracks of the same car
 different cars
and compare the coefficients.
Attached find an example excel sheet with a trend line calculation for the regression function.
Required steps in Excel:
 Filter data using "O2 Lambda Voltage ER <= 0.98"
 create an XY diagram (x = Voltage, y = Voltage ER)
 create a 3degree polynomic trend line (e.g. see Office help or this turorial for details) and display its formula in the diagram