Lightweight time synchronization algorithm for wireless sensors