Built to order

IoT Diesel Generator Fuel Theft Alert System with Level Sensing and Runtime Logging (ESP32)

This project builds an IoT diesel generator fuel theft alert system using an ESP32 that measures diesel level in a test tank with an HC-SR04 ultrasonic sensor mounted above the fuel. When the level drops beyond a set threshold while the generator is off, a SIM800L GSM module sends an SMS theft alert, and low-fuel and runtime events are logged to a dashboard. Suitable for B.E./B.Tech final-year projects in Electronics, Electrical Engineering and IoT.

IoT & Embedded ESP32HC-SR04 ultrasonic sensorHTML · CSS · JavaScript dashboardArduino IDE · C/C++SIM800L GSM module · SMS alertsNon-invasive DG output sensingMedian filtering in firmwareRegulated DC power supplyHybrid
IoT Diesel Generator Fuel Theft Alert System with Level Sensing and Runtime Logging (ESP32) — project thumbnail preview
More project photos (2)

The problem

Diesel generator sets in hostels, hospitals, housing societies and small industrial units sit unattended for long stretches, and the fuel inside their tanks is easy to siphon off without leaving obvious traces. The loss usually surfaces only when a dip-stick check is done or when the generator runs dry during an outage, by which time there is no record of when the level actually fell. Owners also rarely know how many hours a set has run between refills, so consumption cannot be reconciled against runtime. This project builds a monitoring node that watches the tank continuously: an ultrasonic sensor measures the diesel level from above, the controller separates genuine consumption during running hours from unexplained drops while the set is off, and a GSM link reports theft and low-fuel events by SMS while every event is logged against time.

How it works

  1. The HC-SR04, fixed in a bracket above the test tank, fires an ultrasonic pulse at intervals; the ESP32 times the echo from the diesel surface and converts the air-gap distance into fuel level using the calibrated empty and full heights.
  2. A burst of repeated readings is median-filtered to reject sloshing and surface ripple, and the filtered level is converted to approximate litres from the tank's cross-section before being stored with a timestamp.
  3. A non-invasive sense circuit on the DG output reports RUNNING or OFF to a digital input; while the set runs, level changes are booked as consumption and added to the runtime log with start and stop times.
  4. While the set is OFF, the firmware compares each new filtered level with the last stable stored level; a drop beyond the configured theft threshold within the check interval raises a theft event.
  5. On a theft event or a low-fuel crossing, the ESP32 commands the SIM800L over its serial interface to send an SMS naming the event, the level before and after, and the time, to the configured number.
  6. Level samples, runtime records and alert events are served to the dashboard, which draws the level history chart, updates the gauge and lists the newest events first.
  7. The node keeps sensing on its regulated supply, and the event log is retained in non-volatile storage so a power interruption does not erase the theft and runtime history.

Tech stack:

  • ESP32 (Wi-Fi + Bluetooth SoC, used as controller)
  • HC-SR04 ultrasonic ranging module
  • SIM800L GSM/GPRS module · SMS alerts
  • Non-invasive DG output sense circuit
  • Arduino IDE (C/C++ firmware)
  • HTML · CSS · JavaScript dashboard
  • Median filtering · level calibration in firmware
  • Regulated 5 V / 4 V-class DC supplies
Parameter Value
Controller ESP32 development board (implemented)
Level sensor HC-SR04 ultrasonic module (implemented)
Sensor range 2 cm to 400 cm (datasheet)
Sensor accuracy class Approximately 3 mm (datasheet class, before tank calibration)
Test tank capacity Approximately 20 L transparent test tank (prototype scale)
Theft threshold Approximately 1 L drop while DG is off (design target, firmware-configurable)
Low-fuel alert point Approximately 25% of tank height (design target, firmware-configurable)
GSM module SIM800L, 3.4 V to 4.4 V supply (datasheet)
Alert channel SMS over 2G GSM to one configured number (implemented)
Runtime logging Start/stop timestamps, per-day and total hours (implemented)
Level sensing interval Approximately every 60 s (design target, firmware-configurable)
Dashboard Local web dashboard — gauge, history chart, runtime and alert logs (implemented)
Node supply 5 V DC regulated adapter, separate 4 V-class rail for GSM bursts (design target)

Project features

  • [Non-contact ultrasonic level sensing] An HC-SR04 sensor mounted above the diesel surface measures the air gap to the fuel, and the ESP32 converts that distance into level and approximate litres using the test tank's calibrated height, so nothing is dipped into the fuel itself.
  • [Theft detection while the DG is off] The firmware compares the stored level with the current level at intervals; a drop larger than the configured threshold while the generator output sense reads OFF is treated as a theft event rather than normal use.
  • [Runtime sensing on the DG output] A non-invasive sense circuit on the generator output tells the controller whether the set is running, so fuel consumed during genuine running hours is logged as consumption and never flagged as theft.
  • [SMS alerts over GSM] A SIM800L module sends theft-alert and low-fuel SMS messages to a configured mobile number, so an alert reaches the owner even where there is no Wi-Fi coverage at the generator site.
  • [Runtime hours logging] Start and stop times from the output sense are accumulated into total runtime hours and per-day run records, letting fuel filled, fuel consumed and hours run be compared side by side.
  • [Low-fuel refill alert] When the measured level crosses the configured low-fuel mark, the system raises a refill reminder by SMS and marks the event on the dashboard before the tank reaches the pickup limit.
  • [Local dashboard with level history] A web dashboard shows the current level gauge, a level-versus-time history chart, the runtime log and the alert event list, so the complete behaviour of the node can be demonstrated from one screen.
  • [Configurable thresholds] Theft drop, low-fuel level and sensing intervals are firmware parameters (configurable in code) — they can be retuned for a different tank height or alert preference; a larger industrial tank fitment is an optional customisation, not part of the base build.

What is included

  • Working fuel-theft monitoring prototype (ESP32 node, HC-SR04 on tank bracket, SIM800L with antenna, DG output sense circuit, test tank assembly)
  • Controller firmware / source code with level sensing, theft logic, runtime logging and SMS alert code
  • Dashboard demo (single-file web app) showing level gauge, history chart, runtime log and alert events
  • Circuit diagram, wiring documentation and component list
  • Tank calibration and threshold setup instructions
  • Project report PDF (background, sensor theory, theft-logic design, methodology)
  • Project abstract PDF
  • PPT presentation for final review
  • Viva Q&A preparation document (ultrasonic ranging, GSM AT commands, filtering, runtime reconciliation)

Limitations & prerequisites

  • Prototype scale: level sensing is demonstrated on an approximately 20 L test tank; fitting the bracket and recalibrating for a full-size DG day tank is site work outside the base build.
  • Ultrasonic readings are disturbed by fuel sloshing, foam and a tilted sensor; median filtering reduces this but readings taken while the tank is being filled or moved can still jump.
  • Level-to-litres conversion assumes a uniform tank cross-section; irregular or horizontal cylindrical tanks need a calibration table and will show larger litre errors near the ends.
  • The HC-SR04 figure of approximately 3 mm is a datasheet accuracy class for the bare module; installed level accuracy depends on bracket alignment, temperature and calibration against known volumes.
  • SMS delivery depends on 2G GSM coverage and an active SIM with balance; in areas where 2G service is withdrawn, alerts need a different communication module.
  • The SIM800L draws short high-current bursts when transmitting (datasheet supply 3.4 V to 4.4 V); it needs its own adequately rated rail — sharing a weak USB supply causes resets during SMS sending.
  • Theft logic flags level drops, not people: a genuine drain for maintenance while the DG is off will also raise an alert unless the event is acknowledged in the log.
  • Not a certified security or metering system: there is no tamper-proof enclosure rating, no custody-transfer fuel measurement certification and no insurance-grade event evidence.

Frequently Asked Questions

Is this project suitable for a final-year project?

Yes — Electronics, Electrical Engineering and IoT programmes can all carry this build. It demonstrates ultrasonic sensing and calibration, embedded decision logic that separates consumption from theft using a runtime input, GSM communication with AT commands, and data logging with a dashboard, which together give concrete, explainable material for the report and viva.

How does the system tell theft apart from normal fuel use?

A non-invasive sense circuit on the generator output tells the ESP32 whether the set is running. Level drops recorded while the set runs are booked as consumption against runtime hours. A drop beyond the configured threshold while the set is off cannot be engine consumption, so that pattern is what raises the theft alert.

Which controller and sensors are used?

The controller is an ESP32. Fuel level comes from an HC-SR04 ultrasonic module (datasheet range 2 cm to 400 cm) mounted above the diesel, alerts go through a SIM800L GSM module (datasheet supply 3.4 V to 4.4 V), and generator running state comes from the output sense circuit.

Does the system work without Wi-Fi or internet?

The protective functions do not need Wi-Fi: level sensing, theft logic, runtime logging and SMS alerts all run on the node itself and the GSM network. The dashboard is a local web view of the logged data; where Wi-Fi is unavailable the same log can be reviewed on a directly connected display device.

What power supply does the node need?

The ESP32 node runs from a regulated 5 V DC adapter. The SIM800L is powered from its own 4 V-class rail rated for its transmission bursts, because a shared weak supply can dip and reset the module mid-SMS. A small backup battery for the node is an optional customisation, not part of the base build.

Can the thresholds and tank size be changed?

Yes. Theft drop, low-fuel point, sensing interval and the empty/full calibration heights are firmware parameters. A taller tank mainly needs bracket repositioning and recalibration; a tank with a non-uniform cross-section additionally needs a level-to-volume calibration table in the firmware.

Components & software requirements
  • ESP32 (Wi-Fi + Bluetooth SoC, used as controller)
  • HC-SR04 ultrasonic ranging module
  • SIM800L GSM/GPRS module · SMS alerts
  • Non-invasive DG output sense circuit
  • Arduino IDE (C/C++ firmware)
  • HTML · CSS · JavaScript dashboard
  • Median filtering · level calibration in firmware
  • Regulated 5 V / 4 V-class DC supplies
Delivery information

Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.

Support terms

Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.

Download free synopsis (PDF)

Enter your name and email — the synopsis PDF downloads immediately. We may send occasional project updates; no spam, unsubscribe anytime.

Get a quotation