How goez35/smart-traffic works
Smart Traffic Light is a four-lane IoT monitoring and adaptive signal-control system. In the main workflow, a cloud worker processes sensor readings, chooses adaptive timing and signal phases, and persists lane state and cycle history; the dashboard reads that state, displays monitoring and logs, and lets an operator submit a manual override. ESP32 communication, live-state APIs, and browser auto-refresh are also product capabilities. The worker and several integrations are only partially sampled, so uncertain links are dashed rather than asserted as verified calls.
Main entry points: index.php Dashboard page · traffic_db.sql MySQL traffic state · simpang_grid.php Lane controls · worker_mqtt.php Adaptive MQTT worker
Components 18
Adaptive Control
- Adaptive MQTT worker
worker_mqtt.php - Manual override handler
update_manual.php
Dashboard & APIs
- Dashboard page
index.php - Lane controls
includes/simpang_grid.php - Cycle & event logs
includes/log_table.php - Live status summary
includes/hero.php - Live-state API
api_live_state.php - ESP32 API
api_esp32.php
Persistence
- MySQL traffic state
traffic_db.sql - Schema initializer
includes/db_init.php - Database connection
koneksi.php
Device & Messaging
- ESP32 signal controller
esp32/smart_traffic_esp32/smart_traffic_esp32.ino - PHP MQTT client
includes/MqttClient.php
Simulation
- Web simulation
simulasi.php - Local traffic simulator
simulasi_lokal.php
Other components
- Traffic operator
- Web browser
- MQTT broker
Connections 19
- Traffic operator → Web browser: uses dashboard
README.md - Web browser → Dashboard page: opens
README.md - Dashboard page → Database connection: loads connection
index.php - Database connection → Schema initializer: initializes schema
koneksi.php - Dashboard page → MySQL traffic state: reads lane state & logs
index.php - Dashboard page → Live status summary: renders
index.php - Dashboard page → Lane controls: renders
index.php - Dashboard page → Cycle & event logs: renders
index.php - Web browser → Lane controls: submits override
includes/simpang_grid.php - Lane controls → Manual override handler: posts form
includes/simpang_grid.php - Adaptive MQTT worker → MySQL traffic state: reads & writes state
worker_mqtt.php - Adaptive MQTT worker → PHP MQTT client: uses client
worker_mqtt.php - PHP MQTT client → MQTT broker: exchanges messages
- ESP32 signal controller → MQTT broker: publishes sensor & signal data
- ESP32 API → MySQL traffic state: accesses device state
api_esp32.php - Live-state API → MySQL traffic state: reads live state
api_live_state.php - Web browser → Live-state API: refreshes status
- Web browser → Web simulation: opens simulation
- Local traffic simulator → MySQL traffic state: reads config & writes simulated state
simulasi_lokal.php