Contents
System Overview
Fuel is typically 30-40% of fleet operating costs. This system helps reduce costs through monitoring and optimization.
Benefits:
- 10-20% fuel cost reduction
- Fuel theft detection & prevention
- Driver behavior monitoring
- Route optimization insights
- Maintenance scheduling
Fuel Sensors
| Type | Accuracy | Cost | Installation |
|---|---|---|---|
| Ultrasonic | ±1% | $$ | External mount |
| Capacitive | ±0.5% | $$$ | Drill required |
| Float | ±3% | $ | Tank access needed |
| OBD-II | ±5% | $ | Plug & play |
Hardware Setup
- ESP32: Main controller
- Ultrasonic Sensor (JSN-SR04T): Waterproof fuel level
- GPS Module: Location tracking
- 4G/NB-IoT: Cellular connectivity
- Accelerometer: Crash/tilt detection
ESP32 Firmware
#include <TinyGPS++.h>
float readFuelLevel() {
// Send ultrasonic pulse
digitalWrite(TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG, LOW);
long duration = pulseIn(ECHO, HIGH);
float distance = duration * 0.034 / 2;
// Convert to fuel percentage
float fuelPercent = map(distance, 5, 50, 100, 0);
return constrain(fuelPercent, 0, 100);
}
void detectTheft() {
static float lastFuel = 100;
float currentFuel = readFuelLevel();
// Sudden drop = potential theft
if (lastFuel - currentFuel > 10 && !engineRunning) {
sendAlert("FUEL_THEFT", currentFuel);
}
lastFuel = currentFuel;
}
Theft Detection
Common theft patterns the system detects:
- Sudden Drop: >10% when engine off
- After Hours: Fueling outside schedule
- Location Mismatch: No gas station nearby
- Frequency: Too many refuels
Analytics Dashboard
// Fuel consumption query (InfluxDB)
SELECT mean("fuel_level") FROM "fleet_fuel"
WHERE time > now() - 7d
GROUP BY time(1h), "vehicle_id"
// Calculate MPG
SELECT (distance / fuel_consumed) as mpg
FROM "trip_data"
GROUP BY "vehicle_id"
Installation Considerations:
- Ensure sensor compatibility with fuel type
- Follow hazardous location regulations
- Calibrate sensors for tank shape
- Test before fleet-wide deployment
Next Steps
- Add driver ID integration
- Implement fuel card integration
- Add predictive maintenance
- Connect to dispatch system
Related: Fleet Tracking | OBD-II Monitor