Time library - strange behaviour

Status
Not open for further replies.

scalesr1

Member
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.
 
Hello and thank you for your most speedy response.

In this situation I am not using Teensy hardware, this is running on WeMos D1 or Node MCU. I posted here as timelib is (I believe) a PJRC 'product' many apologies if this is not the right place.
 
Indeed that is a PJRC contribution and I have used it on ESP8266 IIRC - it was a webserver and got NTP time as well. It has been some time but I recall at that time it was failing to build properly but was fixed perhaps 2-3 yrs ago now.

Device details can be helpful/critical. I had to ask about T_3.2 because without crystal installed the RTC doesn't run. I'm not sure about the devices in use and if it is using a normally updated time value or relying on an RTC between updates - but it seems the OP is suggesting the time value doesn't update after an NTP refresh?

Support here is biased toward Teensy and Arduino - so there may be a more informed place to ask - unless needed details are posted and seen by someone familiar with what is described this may go unanswered. It seems this would be a common use for a connected device - like I found for the ESP8266 - and maybe a web search will find sample usage in the same context that will show what is missing?

Paul may even see something given proper detail or sample usage that shows the issue.
 
Status
Not open for further replies.
Back
Top