IoT vehicle telematics for fleet & logistics — ESP32 + SIM7600G 4G/GPS tracker with fuel-theft detection, tamper/cargo security alarms, offline-resilient MQTT reporting, and OBD2 data over ESP-NOW. Includes firmware, KiCad PCB, and 3D enclosure.
Loading README and project media…
A self-contained IoT telematics device for fleet & logistics vehicles — GPS tracking, fuel-theft detection, tamper/security alarms, and offline-resilient cloud reporting.
Built around an ESP32 and a SIM7600G 4G LTE + GPS modem, FleetGuard rides inside the vehicle, talks to a companion OBD2 node over ESP-NOW, watches its own sensors, and streams everything to the cloud over MQTT. When the network drops, it buffers to flash and uploads automatically once it's back — nothing is lost.
FleetGuard is a complete, field-deployable vehicle-telematics unit designed for the logistics industry. It is a two-node system:
The repository also includes three standalone bench/diagnostic sketches (battery gauge, current monitor, fuel-level probe), the custom PCB, the 3D-printed enclosure, and the bill of materials — i.e. everything required to reproduce the device end to end.
CFUN=4), and wakes instantly on any sensor trigger (RTC-capable pins).flowchart LR
subgraph Vehicle
OBD[OBD2 Node\nESP32 + ELM327] -- ESP-NOW --> TRK
SENS[Security sensors\nCase / Fuel cap / 2x Cargo door] --> TRK
FUEL[Analog fuel probe] --> TRK
TRK[FleetGuard Tracker\nESP32 + SIM7600G]
FLASH[(LittleFS\noffline buffer)] <--> TRK
end
TRK -- 4G LTE / MQTT --> BROKER[(MQTT Broker)]
TRK -- GPS --> SAT((GNSS))
BROKER --> DASH[Fleet Dashboard]
FleetGuard/
├── Ahmeds_Final_Code/ # ⭐ Main tracker firmware (ESP32 + SIM7600G, MQTT, GPS, sleep, security)
│ └── Ahmeds_Final_Code.ino
├── Ahmeds_Battery_Percentage/ # Standalone: 1S LiPo fuel gauge (MAX17048) + Wi-Fi dashboard
│ └── Ahmeds_Battery_Percentage.ino
├── Ahmeds_Current_Sensor/ # Standalone: INA226 current/power monitor + Wi-Fi dashboard
│ └── Ahmeds_Current_Sensor.ino
├── Ahmeds_Fuel_Level/ # Standalone: analog fuel-probe reader + Wi-Fi dashboard
│ └── Ahmeds_Fuel_Level.ino
├── Ahmeds_PCB/ # KiCad project + Gerber/drill manufacturing files (JLCPCB)
├── Ahmeds_Enclosure/ # Autodesk Inventor 3D enclosure (case top/bottom + PCB assembly)
└── Ahmeds_BOM/ # Bill of materials (v1 and v2)
| Sketch | Role | Connectivity | Highlights |
|---|---|---|---|
| Ahmeds_Final_Code | Production tracker | 4G LTE (SIM7600G), MQTT, ESP-NOW | GPS, fuel-theft x3, 4 security inputs, offline flash buffer, deep sleep |
| Ahmeds_Battery_Percentage | Bench tool | Wi-Fi AP (FleetGuard → 192.168.4.1) | MAX17048 fuel gauge, live WebSocket dashboard, CSV log |
| Ahmeds_Current_Sensor | Bench tool | Wi-Fi STA (fixed IP) | INA226 current/voltage/power, peak + coulomb-counted Ah, waveform |
| Ahmeds_Fuel_Level | Bench tool | Wi-Fi AP (FleetGuard → 192.168.4.1) | Smoothed/calibrated tank %, theft & refuel detection |
The three bench sketches were used to characterize the sensors individually before the logic was integrated into the production tracker firmware.
Core components (see Ahmeds_BOM/ for the full costed list):
| Category | Part |
|---|---|
| MCU | ESP32-WROOM (Wi-Fi + Bluetooth) |
| Cellular + GPS | SIM7600G (4G LTE) |
| OBD2 interface | ELM327 (Bluetooth/Wi-Fi) |
| Current sensing | INA226 / ACS712 |
| Battery gauge | MAX17048 / ZB2L3 tester |
| Power | 18650 cells (9000 mAh) · 1S 15A BMS · TP5100 charger · XL6009 / MT3608 boost · LM2596 buck |
| Fuel probe (bench) | Water-level sensor (stand-in for a real capacitive/resistive sender) |
| Fabrication | Custom 4-layer-ready KiCad PCB (manufactured at JLCPCB) |
| Mechanical | Custom Autodesk Inventor enclosure (top + bottom + PCB mount) |
PCB — open Ahmeds_PCB/Try.kicad_pro in KiCad. Gerber + drill files are included for direct ordering.
Enclosure — open the .iam/.ipt files in Ahmeds_Enclosure/ with Autodesk Inventor.
TinyGSM, PubSubClient, ArduinoJson, LittleFS (bundled with ESP32 core), and for the bench sketches arduinoWebSockets (Markus Sattler) and INA226.Ahmeds_Final_Code/Ahmeds_Final_Code.ino in the Arduino IDE.Serial commands: saved dumps the offline queue · clear wipes the offline log.
Edit these near the top of Ahmeds_Final_Code.ino:
const char* apn = "internet"; // your SIM's APN
const char* mqtt_server = "broker.hivemq.com"; // MQTT broker (move to your own for production)
const int mqtt_port = 1883;
const char* mqtt_topic = "monztrack/device01/gps";
Pin map (ESP32-WROOM):
| Label | Pin | Function |
|---|---|---|
ESP32_TX_PIN | 12 | → SIM7600 RX |
ESP32_RX_PIN | 14 | ← SIM7600 TX |
PWRKEY_PIN | 27 | SIM7600 power key |
PIN_S1 | 33 | Device-case tamper |
PIN_S2 | 32 | Fuel-cap switch |
PIN_MAG1 | 15 | Cargo door 1 |
PIN_MAG2 | 18 | Cargo door 2 (no deep-sleep wake) |
FUEL_PIN | 34 | Analog fuel probe (ADC1) |
This repository is configured to be public. Keep these points in mind:
FleetGuard with password A12345678a. Because the repo is public, anyone can read this password — it's fine for bench testing, but change it before deploying a real device.broker.hivemq.com) — anyone can subscribe to your topic. Move to a private, authenticated broker for production.Recommended for production: move secrets into a secrets.h (git-ignored) or build flags, use a unique per-device Wi-Fi password, and add MQTT username/password + TLS.
Ahmed Yousef Saeed Khalifa Project: SGU Logistics — FleetGuard
© Ahmed Yousef Saeed Khalifa. All rights reserved. See LICENSE.
The source headers declare "All rights reserved." If you'd prefer this to be open-source (so others can use, study, and contribute), replace
LICENSEwith an MIT or Apache-2.0 license.