2

I have an ESP32 board, with Micropython installed properly, and connecting to local the internet.

Since it have to do a scheduled jobs- its clock need to be synced. After boot it get a generic date 1/1/2000.

How can Micropython updates int clock using ntp.pool.org or other?

Guy

1

2 Answers 2

3

From this post on the Micropython forum:

There is primitive NTP support in the ESP32 port (borrowed from the ESP8266 port). In short:

import ntptime 
ntptime.settime()  # Synchronise the system time using NTP

Caveat: There is no timezone support so the system time will be set to UTC.

From this discussion, you need to make sure you have an active internet connection before trying to set the time, and you should expect to get occasional timeout errors and handle these appropriately.

For reference the source of the ntptime module is here

Sign up to request clarification or add additional context in comments.

Comments

0

You can get a DS3231 RTC. I’m currently using one and it works great.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.