If you are asking a question, please follow this template:
- My goal is: to fetch current time and run a job on a specific time.
- My actions are: I have included SNTP library in mos.yml and invoked Timer.now() function to fetch current time
- The result I see is: I see the time shown is the time elapsed since ESP8266 has started
- My expectation & question is: I am expecting to get the current time in my timezone so that I can use crontabs to schedule the job. How can I get current time in India timezone?
In order to synchronize the time using sntp
, your device must have internet connection.
To get the local time you have to add sys.tz_spec
in your mos.yml
Ref. https://github.com/mongoose-os-libs/core/blob/74a909e5078c911dc6f0d665ddbdac2540b5ce6b/mos.yml#L41-L48
A simpler way to do this is provided by @mamuesp’s timezones library.
@nliviu, thanks a lot. I had set wifi credentials using mos command line tool. I was not aware that if you flash the app again, then configuration needs to be set once again. I was able to solve this problem by setting wifi credentials and SNTP timezone information in mos.yml. Thanks a lot for your help.
1 Like
After flashing the firmware the first time, you can OTA update it and conf9.json
(ie. the device configuration changed with mos --port <your_port> config-set
, mos wifi
) will be preserved between updates.