7.9. sntp — SNTP protocol

The sntp module provides functions for automatic time synchronisation

7.9.1. Functions

sntp.start_time_sync(interval_msec)

Enable automatic time synchronisation and configure to synchronise every interval_msec time interval in msec for auto time sync. Returns the result.

sntp.stop_time_sync()

Disable automatic time synchronisation

# SNTP Example
import sntp
import time

MILLISECONDS      = 1
SECONDS           = 1000
MINUTES           = 60 * SECONDS
HOURS             = 60 * MINUTES
DAYS              = 24 * HOURS

print("Wubby SNTP Example")

# Synchronise time with NTP server and set time sync period for re-sync
sntp.start_time_sync(10 * SECONDS)

# Stop synchronisation
#sntp.stop_time_sync()

while True:
    time.sleep(5)