Chat freely about anything...

User avatar
By Atlantis
#20817 I need quite accurate time on my projects utilizing ESP8266.
It is quite easy to get a current time by SNTP API, already present in SDK.
But what to do next? How to increment variable storing time every second, to be sure it is precise?
How precise is software timer (os_timer_t)? Can I just set it to perform time_var++ every 1000 milliseconds, or do I need something better? I do not want synchronize time every 10 minutes...
Maybe there is a better way? Can I use system_get_rtc_time() somehow to increment standard Unix timestamp?
User avatar
By scargill
#20834 Grab the time library from Arduino and pinch the central core of it. So I update the time from the web every 24 hours - and in a 1 second callback I maintain it - works a treat. I've not yet used the NTP library - I get my time from a Raspberry Pi running MQTT - but same general idea.
User avatar
By Atlantis
#20885
Grab the time library from Arduino and pinch the central core of it.


For now, I do not need human readable data format. Unix timestamp will be fine. I need it for marking time of measurements from sensors, before sending them to the server.

So I update the time from the web every 24 hours - and in a 1 second callback I maintain it - works a treat. I've not yet used the NTP library - I get my time from a Raspberry Pi running MQTT - but same general idea.


You mean os_timer_t?
Is it precise enough to not adrift from correct value in 24h?
Can software timer be distorter, if delay function is used in different section of code? Or it just runs by itself, as a separate "thread"?