Greetings all - I hope you can help with a strange issue that I appear to be having with the time library timelib.h
This is a simple project based around getting time from an NTP source via a WiFi connection and running a clock which displays the time, temperature, pressure and date in two Nixie tubes (I am a Nixie addict).
I have been experiencing an on-going issue when trying to sync with an NTP time source. Originally I was using the method where the timelib was using the 'built in' time sync function where I set a sync function name and the sync interval. I set the interval to 300 seconds but would notice that on occasion - the clock time (this project is all about clocks) was 5 minutes out - the same as the sync interval - it would correct itself after a while.
For another reason, I changed the method so that I called the getNTP() when I wanted to so that I could call a function to check for daylight saving / BST and then apply that when using setTime() - in this way the clock would auto correct for BST/DST. I was using the ticker.h library to set a variable every 5 minutes. The main loop would check for the variable change and call getNTP() accordingly. Again, this would sometimes be out by 5 minutes (the interval between calling getNTP).
By now I am pulling out what little hair remains!
Wondering if it was the ticker include causing an issue I removed that and used another method to call getNTP() every 2 minutes - again, sometimes the clock would be out by 2 minutes (though interestingly, whilst it was 'out' at one point I noticed that it was only 20 seconds out).
This is all very frustrating - especially when trying to show the time - as near second perfect as compared to every other clock I own!
In addition to timelib, the sketch is also using libraries for a BMP280 sensor and neopixels.
I am happy to post the entire sketch if required but wanted to avoid the 'here's my sketch please fix it' approach, equally, I wanted to save you all from the pain you'd endure when looking at my coding attempts!
I would be grateful if anyone could point me in the right direction or provide any pointers as to where I should be looking at whether there is anything particular that I should be looking out for.
I also realise that the title of this post suggests that the library might be behaving strangely - I fully accept that the library will be fine, it will be what I am trying to do with it!). I posted it here as I am using timelib which is a PJRC product - if I should post in the Project Guidance section then please advise, I fully understand.
Thank you.
This is a simple project based around getting time from an NTP source via a WiFi connection and running a clock which displays the time, temperature, pressure and date in two Nixie tubes (I am a Nixie addict).
I have been experiencing an on-going issue when trying to sync with an NTP time source. Originally I was using the method where the timelib was using the 'built in' time sync function where I set a sync function name and the sync interval. I set the interval to 300 seconds but would notice that on occasion - the clock time (this project is all about clocks) was 5 minutes out - the same as the sync interval - it would correct itself after a while.
For another reason, I changed the method so that I called the getNTP() when I wanted to so that I could call a function to check for daylight saving / BST and then apply that when using setTime() - in this way the clock would auto correct for BST/DST. I was using the ticker.h library to set a variable every 5 minutes. The main loop would check for the variable change and call getNTP() accordingly. Again, this would sometimes be out by 5 minutes (the interval between calling getNTP).
By now I am pulling out what little hair remains!
Wondering if it was the ticker include causing an issue I removed that and used another method to call getNTP() every 2 minutes - again, sometimes the clock would be out by 2 minutes (though interestingly, whilst it was 'out' at one point I noticed that it was only 20 seconds out).
This is all very frustrating - especially when trying to show the time - as near second perfect as compared to every other clock I own!
In addition to timelib, the sketch is also using libraries for a BMP280 sensor and neopixels.
I am happy to post the entire sketch if required but wanted to avoid the 'here's my sketch please fix it' approach, equally, I wanted to save you all from the pain you'd endure when looking at my coding attempts!
I would be grateful if anyone could point me in the right direction or provide any pointers as to where I should be looking at whether there is anything particular that I should be looking out for.
I also realise that the title of this post suggests that the library might be behaving strangely - I fully accept that the library will be fine, it will be what I am trying to do with it!). I posted it here as I am using timelib which is a PJRC product - if I should post in the Project Guidance section then please advise, I fully understand.
Thank you.