Fleet Management: Real-Time GPS Tracking with Geofencing
How Sentinel Security Suite tracks 500+ vehicles in real-time with sub-second accuracy. Technical architecture for GPS, geofencing alerts, and preventing $2M+ in theft.
Lost vehicles cost logistics companies $12 billion/year (FBI data).
Our Sentinel Security Suite prevented $2.1M in theft for one client alone.
The Challenge
A logistics company with 500+ trucks needed:
- Real-time location (update every 30 seconds)
- Geofencing (alert if vehicle leaves route)
- Historical playback (where was truck X at 2pm yesterday?)
- Tamper detection (disconnected GPS = alert)
The Hardware
GPS Tracker
- Quectel LG69T GPS module
- 4G LTE modem (cellular connectivity)
- Internal battery (continues tracking if external power cut)
- Accelerometer (detect harsh braking, speeding)
Cost: $45/unit (bulk pricing)
Installation
Wired into vehicle's OBD-II port:
- Power from vehicle
- Ignition status (on/off)
- VIN (vehicle identification number)
The Software Architecture
Data Flow
[GPS Tracker]
→ 4G LTE
→ AWS IoT Core (MQTT)
→ Lambda (process & store)
→ DynamoDB (current location)
→ RDS (historical data)
→ WebSocket → Dashboard
Real-Time Updates
MQTT message:
{
"device_id": "TRK-500123",
"timestamp": 1705785600,
"lat": 30.2672,
"lon": -97.7431,
"speed": 65,
"heading": 180,
"ignition": true
}
Lambda processor:
import boto3
def process_location(event):
data = json.loads(event['body'])
# Store current location (DynamoDB)
dynamodb.put_item(
TableName='vehicle_locations',
Item={'device_id': data['device_id'], ...}
)
# Check geofence violations
if is_outside_geofence(data['lat'], data['lon']):
send_alert(data['device_id'])
# Broadcast to dashboard (WebSocket)
ws_client.post_to_connection(
ConnectionId=connection_id,
Data=json.dumps(data)
)
Geofencing Algorithm
Point-in-Polygon Check
from shapely.geometry import Point, Polygon
def is_outside_geofence(lat, lon):
point = Point(lon, lat)
geofence = Polygon([
(-97.75, 30.25),
(-97.70, 30.25),
(-97.70, 30.30),
(-97.75, 30.30)
])
return not geofence.contains(point)
Performance: 2ms per check (fast enough for real-time)
Distance-Based Alerts
"Alert if truck is >50 miles from route":
from geopy.distance import geodesic
expected_location = (30.2672, -97.7431)
actual_location = (lat, lon)
distance = geodesic(expected_location, actual_location).miles
if distance > 50:
send_alert("Vehicle off-route by {distance} miles")
Historical Playback
Query: "Show me where truck #123 was on Jan 15 between 2-4 PM"
SELECT timestamp, lat, lon, speed
FROM location_history
WHERE device_id = 'TRK-500123'
AND timestamp BETWEEN '2025-01-15 14:00' AND '2025-01-15 16:00'
ORDER BY timestamp ASC;
Map visualization: Plot path on Mapbox with color-coded speed.
Tamper Detection
Power Disconnection
Scenario: Thief unplugs GPS tracker.
Detection:
- Internal battery sends "power_lost" alert
- Continues tracking for 8 hours on battery
- SMS alert to fleet manager
GPS Spoofing
Scenario: Attacker broadcasts fake GPS signals.
Detection:
- Cross-reference cellular tower triangulation
- Flag impossible movements (teleporting 100 miles instantly)
- Compare GPS timestamp vs system clock
The Dashboard
Built with React + Mapbox:
- Live map with all vehicles
- Click vehicle → details (speed, direction, ETA)
- Geofence zones (green = safe, red = violation)
- Historical playback scrubber
Performance:
- 500 vehicles updating every 30 seconds
- Dashboard renders at 60 FPS
- WebSocket connection handles 1,000+ messages/minute
Cost Breakdown
Per-vehicle monthly cost:
- GPS hardware: $45 (one-time)
- 4G data plan: $5/month (2 GB)
- AWS infrastructure: $0.50/month
- Total: $5.50/month
Compare to commercial solutions:
- Verizon Connect: $25-40/month
- Samsara: $30-50/month
Savings: 70-85%
Real-World Results
Logistics Client (500 vehicles):
- $2.1M theft prevented (3 stolen vehicles recovered in 24 hours)
- 15% fuel savings (route optimization based on GPS data)
- 92% on-time delivery (up from 78% before GPS tracking)
Security Measures
- Encrypted communication (TLS 1.3)
- Device authentication (X.509 certificates)
- Role-based access (drivers see own vehicle, managers see all)
- Audit logs (who accessed what data when)
Lessons Learned
- Battery backup is essential. Prevents "blind spots" when power cut.
- Cellular coverage gaps exist. Cache data locally, sync when reconnected.
- Speeding alerts annoy drivers. Set threshold at 10 mph over, not 1 mph.
- Geofences need buffers. GPS accuracy ±30 feet, allow slack.
Need fleet tracking for your business?
Explore Sentinel Security Suite
Ready to Build Something?
Let's discuss your next project. Mobile apps, AI integration, or custom development.
Written by AJ Patatanian
Senior full-stack engineer with expertise in React Native, AI/ML, and cloud architecture. Building production apps at SERA Industries.
More articles →Continue Reading
Building the Future: Cross-Platform Development and AI Integration
From mobile gaming to enterprise security systems, explore how modern development patterns, AI integration, and cloud-native architecture are transforming software delivery. Real insights from building production apps.
Zero-Trust Cloud Security: Lessons from Building Enterprise Tracking Systems
How we secure GPS tracking data for fleet management clients. Deep dive into zero-trust architecture, end-to-end encryption, and preventing location spoofing attacks.