2658 views|0 replies

28

Posts

1

Resources
The OP
 

ESP32 Network Time Synchronization [Copy link]

 

ESP32 has its own network module, and network time synchronization can be enabled after connecting to WIFI.

MicroPython comes with the ntptime module, which can easily sync time over the network.

import ntptime

ntptime.NTP_DELTA = 3155644800   #设置北京时间

ntptime.host = 'ntp.aliyun.com'  #设置校时服务器

ntptime.settime()                #机器时钟校时
  • 3155644800 = 3155673600-28800
  • 3155673600 = (date(2000, 1, 1) - date(1900, 1, 1)).days * 24*60*60
  • 28800 = 8*60*60
  • The time obtained by ntptime is UTC, which is 8 hours different from Beijing time. Since the time zone cannot be set, a compromise was found.
  • ntp.aliyun.com,ntp1.aliyun.com~ntp7.aliyun.com can be selected

 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list