A lightweight method for time synchronization in wireless sensor networks