Smart Red Light Violation Detection System - shalan/CSCE4301-WiKi GitHub Wiki

Smart Red Light Violation Detection System

Name GitHub
Yousef Sayed GH_UID1
Marwan Abudaif GH_UID2
Hadi Hesham GH_UID3

1. The Proposal

Abstract / Elevator Pitch:

Running red lights is a leading cause of serious traffic accidents in Egypt and worldwide. Traffic officers cannot manually monitor every intersection around the clock, and without automated evidence capture, authorities have no reliable way to issue fines or deter repeat offenders. Simple motion-based detection systems cannot distinguish between a pedestrian crossing the street and a vehicle running a red light, producing false alarms that waste enforcement resources.

Our project is the Smart Red Light Violation Detection System — an embedded real-time system that automatically detects vehicles crossing a stop line during a red light phase, captures photographic evidence with a flash-synchronized camera, and logs every violation with a timestamp to a PC. The system uses two Force-Sensitive Resistors (FSRs) embedded at the stop line that respond to the physical pressure of a vehicle's tyre. Because a car tyre applies roughly 10–20 times more pressure per unit area than a pedestrian's foot, the system filters out pedestrians at the hardware level by setting an ADC threshold between the two pressure ranges. To confirm a full vehicle has crossed (not just a partial approach that reversed), both sensors must trigger in sequence within a calibrated time window.

The firmware runs on a Nucleo STM32 / Tiva C microcontroller using FreeRTOS with six concurrent tasks (pressure detection, violation logic, camera and flash, traffic light cycle, display and alert, UART logging) across multiple priority levels. When a violation is confirmed during the red light phase, the system simultaneously fires a 1W flash LED and sends a capture command via UART to an ESP32-CAM module, which photographs the vehicle and saves the image to an SD card with a timestamped filename. The event is logged to a PC terminal, the LCD updates the violation count, and the buzzer alerts nearby enforcement. This system demonstrates a practical, real-world embedded application of multitasking, inter-task communication, and event-driven sensor fusion — all using hardware readily available in Egypt for under 300 EGP.

Project Objectives & Scope:

Minimum Viable Product (MVP):

  • Automatic traffic light cycle (GREEN → YELLOW → RED) using software timers
  • Detection active only during the RED light phase
  • Dual FSR pressure sensors detecting front and rear axle passage in sequence
  • Hardware-level pedestrian filtering via ADC threshold tuning
  • Full FreeRTOS architecture with 6 concurrent tasks and proper inter-task communication (queues, mutexes, event groups, task notifications, software timers)
  • Flash LED synchronized with camera capture (20 ms burst)
  • ESP32-CAM integration via UART for photo capture and SD card storage
  • Real-time LCD display showing current light state, violation count, and last event time
  • UART event logging to PC terminal with timestamps
  • Audible buzzer alert on confirmed violation
  • Manual override buttons (force red light, reset counter)

Stretch Goals:

  • Configurable detection thresholds via keypad (adjustable time window for slow vehicles or large trucks)
  • Persistent violation count stored in flash memory (survives power cuts)
  • Web dashboard served by ESP32-CAM via WiFi showing live violation feed
  • Emergency vehicle exemption mode (master button to temporarily disable detection)
  • Multi-lane support by replicating the hardware unit per lane
  • Historical statistics (violations per hour/day) shown on LCD
  • Night mode with increased flash brightness

2. System Architecture

2.1 High-Level Block Diagram:

(To be added — architecture diagram will be uploaded separately)

Subsystem Breakdown:

To be completed after the architecture diagram is finalized.

3. Hardware Design

Component Selection:

To be completed.

Schematics & Wiring:

To be completed — circuit diagrams, pinout tables, and breadboard layouts.

Bill of Materials (BOM):

To be completed — table listing component names, part numbers, quantities, costs, and datasheet links.

Power Budget:

To be completed — calculations ensuring the power supply can handle peak current draw.

4. Software Implementation

4.1 Software Architecture:

To be completed — firmware design description (FreeRTOS-based with preemptive scheduling).

4.2 Flowcharts & State Machines:

To be completed — visual diagrams of the violation detection state machine and traffic light cycle.

4.3 Key Algorithms:

To be completed — pressure threshold filtering, time gap pedestrian filter, flash/camera synchronization.

4.4 Development Environment:

To be completed — IDE and toolchain (STM32CubeIDE / Keil uVision, FreeRTOS kernel).

5. Testing, Validation & Debugging

5.1 Unit Testing:

To be completed.

5.2 Integration Testing:

To be completed.

5.3 Challenges & Solutions:

To be completed — log of major bugs, hardware failures, and solutions.

6. Results & Demonstration

6.1 Final Prototype:

To be completed — photos of the completed build.

6.2 Video Demonstration:

To be completed — link to demo video.

6.3 Performance Metrics:

To be completed — data showing how well the project met its objectives (detection accuracy, response time, false positive rate).

7. Project Management

7.1 Division of Labor:

Team Member Primary Responsibilities
Yousef Sayed Hardware wiring, FSR pressure sensor interfacing, Pressure Detection Task firmware, Violation Logic state machine, ADC threshold calibration
Marwan Abudaif ESP32-CAM integration and UART communication, Flash LED circuit (transistor + driver), Traffic Light Task and timing cycle, Camera & Flash Task synchronization
Hadi Hesham UART logging task and PC terminal protocol, Display & Alert Task (LCD + buzzer), Wiki documentation, Proposal and final presentation, Integration testing

All team members will collaborate on:

  • System integration and debugging
  • Edge case testing (pedestrian filter, partial crossings, timeout handling)
  • Demo preparation and rehearsal
  • Final presentation delivery

7.2 Timeline:

Date Milestone Status
Apr 15 Proposal presentation ✓ Complete
Apr 20 Wiki page live (Checkpoint A) In progress
Apr 20 – Apr 28 Core firmware: FSR sensor reading + traffic light cycle + basic state machine Pending
Apr 29 Progress demo: live violation detection working Pending
Apr 30 – May 5 Full integration: ESP32-CAM + flash + UART logging + LCD display Pending
May 6 Integration update (Checkpoint B) Pending
May 7 – May 12 Bug fixes, threshold tuning, edge case testing, demo rehearsal Pending
May 13 Final demo & presentation Pending

8. Appendices & References

8.1 Source Code Repository:

https://github.com/..... (to be added)

8.2 References:

To be completed — datasheets, tutorials, academic papers, and course materials used during development.

⚠️ **GitHub.com Fallback** ⚠️