Add NTP time synchronization after WiFi connection
This commit is contained in:
parent
2c10fdff62
commit
db34c25bb4
8
main.py
8
main.py
@ -77,6 +77,14 @@ if wifi and wifi.isconnected():
|
|||||||
|
|
||||||
# Send startup message with IP
|
# Send startup message with IP
|
||||||
send_discord_message(f"Pico W online at http://{ifconfig[0]} ✅")
|
send_discord_message(f"Pico W online at http://{ifconfig[0]} ✅")
|
||||||
|
|
||||||
|
# Sync time with NTP
|
||||||
|
try:
|
||||||
|
import ntptime
|
||||||
|
ntptime.settime()
|
||||||
|
print("Time synced with NTP server")
|
||||||
|
except Exception as e:
|
||||||
|
print("Failed to sync time: {}".format(e))
|
||||||
else:
|
else:
|
||||||
print("\n" + "="*50)
|
print("\n" + "="*50)
|
||||||
print("WiFi Connection Failed!")
|
print("WiFi Connection Failed!")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user