Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Setting the time on an esp32 #87

Closed
saltydog101 opened this issue May 13, 2017 · 7 comments
Closed

Setting the time on an esp32 #87

saltydog101 opened this issue May 13, 2017 · 7 comments

Comments

@saltydog101
Copy link

I've worked with the ESP8266, and there I would set the time on bootup via ntp. I was able to call the RTC class from machine and also, use utime.localtime to help calculate the delta. Then I would call RTC().datetime to set the time accordingly. In the ESP32 port, there is neither an RTC class or a localtime function from utime, I'd be glad to look at adding it, but I wanted to make sure I'm not duplicating the same functionality elsewhere. Is someone already working on something similar?

@dpgeorge
Copy link
Member

I wanted to make sure I'm not duplicating the same functionality elsewhere. Is someone already working on something similar?

Not to my knowledge, so feel free to go for it.

@mcauser
Copy link
Contributor

mcauser commented May 16, 2017

Some work on machine.RTC here: #85

@saltydog101
Copy link
Author

Thanks mcauser! I'll just add the localtime method to utime to complete setting the time.

@nickzoic
Copy link
Collaborator

Cool, I should add a call to machine.RTC().init() to mpy-utils as well ...

@MrSurly
Copy link
Contributor

MrSurly commented May 17, 2017

Actually, I did implement datetime() in #85

Though, I need to update it to make a bit more sense, since I screwed up the year / month thing (1900 and 0-11) Edit 1: Fixed, pushed, matches implementation from the documentation.

Edit 2: Also, implemented using subseconds (255-0) instead of µseconds ... probably not the right thing to do for machine.RTC (as opposed to pyb.RTC)

Edit 3: Implemented RTC().init(()), and replaced subseconds with microseconds

@vandys
Copy link

vandys commented May 22, 2017

Has anybody wired in the SNTP code form the SDK? Seems like it'd be a nice fit.

@saltydog101
Copy link
Author

Thanks @MrSurly, that's what I needed to set the time from ntp.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants