VI / EN
Quay lại danh sách ghi chú

Building an IoT-GIS Road Monitoring & Flood Warning System with ESP32 and YOLOv8

A deep dive into integrating edge inertial sensing (MPU6050), waterproof ultrasonic ranging (JSN-SR04T), edge computer vision inference, and GIS spatial mapping with Supabase and Leaflet.

July 20, 2026
IoTESP32GISYOLOv8Edge AI

Introduction

Urban infrastructure in tropical cities faces two recurring hazards during rainy seasons: sudden road degradation (potholes) and severe localized flooding. Traditional citizen reporting systems rely on manual complaints, which are slow and reactive.

In this article, I share the architecture and engineering decisions behind RODA, an automated IoT-GIS system capable of identifying potholes and tracking street flood heights in real time.

1. Edge Sensing: Distinguishing Potholes from Speed Bumps

Using an MPU6050 6-axis IMU mounted near the vehicle suspension, vertical acceleration (a_z) is sampled at 200Hz. A common pitfall in vibration-based anomaly detection is false positives triggered by routine speed breakers.

To solve this:

  • Derivative Thresholding: True potholes produce an initial sharp downward drop followed by high-frequency ringing (vertical jerk |Δa_z| > 2.8g within 40ms).
  • Edge Vision Trigger: When an anomalous vibration spike occurs, the ESP32 signals an onboard camera to snap a roadway frame and upload it to our inference pipeline.

2. Edge-to-Cloud Computer Vision Pipeline

Running full-size vision models directly on microcontrollers is memory-prohibitive. We deployed a quantized YOLOv8n model on Hugging Face Inference API:

  • The snapshot is transmitted via lightweight multipart HTTP POST.
  • The model outputs bounding boxes and confidence scores for road damage classes (pothole, alligator_crack, standing_water).
  • Only verified anomalies are committed to the cloud database.

3. Realtime Geospatial Mapping with Supabase & Leaflet

Each verified road anomaly is stored in Supabase with geographic coordinates, timestamps, and severity indices.

  • PostGIS Extension: Enabled fast spatial queries to cluster nearby reports.
  • Leaflet.js: Used in the frontend web portal to render interactive heatmaps and provide safe rerouting suggestions for commuters.

Conclusion

Combining low-cost edge hardware (under $25 per sensor node) with scalable serverless cloud APIs demonstrates that smart city monitoring can be built reliably without requiring prohibitive municipal infrastructure investments.