I tried to set the time on my ESP32 with the version "MicroPython v1.13 on 2020-09-02; ESP32 module (spiram) with ESP32" with ntptime. This doesn't work. This leads to an OSError 202 when using the ntptime module.
After a long search, I found that utime.gmtime() is not available. Why ?
gmtime
Re: gmtime
https://github.com/micropython/micropyt ... ntptime.pyevidently gets you gmtime() on a ESP8266. Hopefully, it works for the ESP32 as I want to use it as well.
-
- Posts: 5
- Joined: Sat Apr 18, 2020 6:22 am
Re: gmtime
no it work not
esp32 use instead of utime.gmtime ()
the function utime.localtime ()
But thank you anyway for your good modules
Code: Select all
>>> import utime
>>> utime.gmtime()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'gmtime'
>>> utime.localtime()
(2000, 1, 1, 2, 0, 44, 5, 1)
>>>
the function utime.localtime ()
But thank you anyway for your good modules
Re: gmtime
What I am going to try is:
- place that version of ntptime.py on the ESP32
- write a small test program which imports ntptime
My understanding is that that will only get you UTC so you need to make your own correction for your timezone.
I have only started using Micropython on the ESP32 so maybe I have got this all wrong.
- place that version of ntptime.py on the ESP32
- write a small test program which imports ntptime
My understanding is that that will only get you UTC so you need to make your own correction for your timezone.
I have only started using Micropython on the ESP32 so maybe I have got this all wrong.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: gmtime
I think on the ESP32 you need to replace gmtime with localtime. @davef is correct, these names reference a function which returns UTC. MicroPython has no timezone support.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: gmtime
retep.rellleum,
Found this viewtopic.php?f=16&t=3675&start=10, especially the post by kwtf and after modifying it for NZ time seems to work fine.
Found this viewtopic.php?f=16&t=3675&start=10, especially the post by kwtf and after modifying it for NZ time seems to work fine.