OVERVIEW:
The project implements a lightweight time synchronization system using two ESP32 microcontrollers connected to LM393 sound sensors and a Raspberry Pi gateway. When a sound event is detected, each ESP32 generates a timestamp and sends it to the Raspberry Pi via Bluetooth. The Raspberry Pi records the received timestamps, calculates the clock offset between devices, estimates network delay, and detects clock drift over time. Based on these calculations, it sends correction messages back to the ESP32 devices to adjust their clocks. This process runs periodically to maintain synchronization while minimizing communication and computational overhead. The basic timestamp difference experiment showed large offsets (around 3.5–4.5 seconds) due to network delay and timing inconsistencies. However, after incorporating round-trip delay compensation and drift correction, the ground truth experiment achieved high precision with offsets confined within approximately ±0.0015 seconds (millisecond-level accuracy). This demonstrates that delay and drift correction significantly improves synchronization accuracy in resource-constrained embedded systems.
