Blog · 2026-11-10
Calculating fuel flow rate through obd || sensor not supporting 015E and 0110 commands
Stefan Bogdanescu
Founder & Senior Architect
Calculating Fuel Flow Rate Through OBD II When Direct Sensors Are Unavailable
Deriving instantaneous fuel consumption from an OBD-II interface is a classic engineering challenge, especially when the vehicle lacks direct support for PID 015E (Fuel Flow Rate) or PID 0110 (Mass Air Flow). While applications like Torque can display believable metrics on unsupported hardware, achieving that accuracy via indirect calculation requires more than just plugging values into a standard formula. The discrepancy between your result of 2.6 gallons/sec and the expected ~0.000066 gallons/sec highlights a fundamental misunderstanding of engine breathing physics within the calculation logic.
The core issue lies in how you are handling the Intake Manifold Absolute Pressure (IMAP) and, more critically, the Volumetric Efficiency (VE). The formula you implemented attempts to calculate air mass by treating the engine as a simple pump driven by RPM and pressure. However, the term volumetricEfficiency is not a static scalar like 70% or 80%. It is a highly dynamic variable that fluctuates based on throttle position, engine load, intake manifold temperature, and even fuel injection timing. Assuming a constant value for VE effectively decouples the calculation from real-world physics, leading to massive overestimations.
To get a result that approaches reality without direct MAF data, you must shift your approach from calculating "theoretical air mass" to estimating "effective air charge." The most viable path forward involves using the IMAP PID (010F) in conjunction with the Engine RPM (0110 is unsupported, but 011C for Coolant Temp or 0124 for Fuel Trim might be available depending on the ECU) to infer load.
The formula you used:
IMAP = (engineRPM * absolutePress) / ((airTemp + 273) / 2f);
MAF = (IMAP / 60) * (volumetricEff / 100f) * (engineDisp / 1000f) * (28.97f / 8.314f);
contains a dimensional inconsistency that compounds the error. The first term (engineRPM * absolutePress) mixes a time-based rate with a pressure state without accounting for volume displacement per cycle correctly. A more robust approach for indirect MAF calculation relies on the Ideal Gas Law applied to the cylinder volume swept during the intake stroke, adjusted by the correction factor of VE which itself must be modeled or bounded.
If you cannot access VE directly, you can approximate it using a lookup table strategy if you have access to a generic engine map, or simply bound your calculations to prevent physical impossibilities. A better alternative often cited in automotive diagnostics is estimating Mass Air Flow (MAF) via IMAP and Engine Speed, but strictly avoiding the multiplication by a guessed VE unless you are calibrating it against known fuel consumption data.
Consider this adjusted logic for the fuel flow estimation:
// Inputs: rpm, manifoldPressurePa, intakeTempK, displacementLiters
// Step 1: Calculate air density using Ideal Gas Law
$airDensity = $manifoldPressurePa / (8.314 * $intakeTempK) * 0.02897; // kg/m^3
// Step 2: Estimate volumetric flow rate at atmospheric pressure conditions
// This requires knowing the engine is not pumping perfectly (VE < 100%)
// Without a dynamic VE map, we must assume a conservative baseline or use fuel trim data.
$veFactor = 0.85; // Start with a high-end estimate, tune down based on results
// Step 3: Calculate Air Mass per second
$airMassPerSec = ($rpm / 60) * $displacementLiters * $veFactor * $airDensity * (1/1000); // kg/s
// Step 4: Derive Fuel Flow using Stoichiometric Ratio (~14.7:1 for gasoline)
$stoichRatio = 14.7;
$fuelMassPerSec = $airMassPerSec / $stoichRatio;
// Convert to gallons/sec (approx 0.264172 L/gal)
$fuelGallonsPerSec = ($fuelMassPerSec / 0.75) / 3.78541; // Assuming fuel density ~0.75 kg/L
The critical takeaway is that without a dynamic VE curve, your calculation will inherently be an approximation. The massive overestimation you observed likely stems from combining high RPM with a fixed pressure and a guessed VE, ignoring the fact that at wide-open throttle (high load), VE can drop significantly, or conversely, at part load, the air-fuel ratio changes.
If your goal is merely to ensure the numbers are "believable" rather than precise, the most effective strategy is to normalize your calculated fuel flow against a known baseline. If you can access Fuel Trim PIDs (Long Term and Short Term Fuel Trims), these values represent exactly how much the ECU is enriching or leaning the mixture compared to stoichiometric. You can apply this correction factor directly to your estimated air mass to align it with actual combustion events.
// Apply fuel trim as a percentage adjustment
$ltft = $longTermFuelTrim / 100; // e.g., -5 means running leaner
$stft = $shortTermFuelTrim / 100;
$totalCorrection = (1 + $ltft) * (1 + $stft);
$fuelFlowCorrected = $fuelGallonsPerSec * totalCorrection;
By anchoring your theoretical calculation to the ECU's own correction factors, you bypass the need for an accurate VE model. This method acknowledges that the OBD-II protocol is a window into the ECU's internal state, not necessarily a direct sensor feed. When direct PIDs like 015E are absent, leveraging the data the ECU already uses to control injection (fuel trims) provides the most reliable proxy for actual fuel consumption.