Notifications
Clear all

[Solved] NTP sync *interval* does not work?

12 Posts
2 Users
3 Likes
1,250 Views
wwjd777
(@wwjd777)
Member
Joined: 2 years ago
Posts: 20
Topic starter  

   
Quote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 

@wwjd777

This may be a stupid question, but what do you expect to happen when you run this ?

Your main loop appears to just look for 1000 millis or more to elapse and then celebrates that event by printing a dot, resetting to the last millis and then starting over.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
wwjd777
(@wwjd777)
Member
Joined: 2 years ago
Posts: 20
Topic starter  

@will 

yes it seems stupid but I did expect to see on the Serial Monitor the output when the sync function is called

so I expected to see this every x seconds:

NTP Time Sync <=====================================
NTP Epoch: 1638472314
NTP Time : 19:11:54
Epoch Pre Sync: 3605
Epoch Post Sync: 1638472314
Drift Correct: 1638468709

This output is after startup but after that no resync:

setup(): begin
Current Wifi firmware: 1.4.8
Latest Wifi firmware: 1.4.8
Attempting to connect to SSID: JezusHoudVanJe!
Connected to wifi
SSID: JezusHoudVanJe!
IP Address: 192.168.178.92
signal strength (RSSI):-52 dBm
NTP Time Sync <=====================================
NTP Epoch: 1638472314
NTP Time : 19:11:54
Epoch Pre Sync: 3605
Epoch Post Sync: 1638472314
Drift Correct: 1638468709
setup(): ready
.........
--- exit ---


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 

@wwjd777 

Sorry to be obtuse, what "synch function" and when/where is it called ?

If you mean synchNTPTime, it's called in setup() so it does appear once on the serial monitor, but it's not explicitly called anywhere else in your code.

Anything seems possible when you don't know what you're talking about.


   
wwjd777 reacted
ReplyQuote
wwjd777
(@wwjd777)
Member
Joined: 2 years ago
Posts: 20
Topic starter  

As I understand it, the line below has extra arguments of which the last one is the 'sync' parameter in seconds.

NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 10);

But I think it's best to start all over and look for a better example to work from. 
I don't want to waste your or anybody's time..

Thank you and if I succeed I will post is here so others may benfit

 


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 

@wwjd777 

Ah, OK. So that is supposed to reinvoke the synch routine every 10 seconds (presumably); but how is it told which of your routines to call ? 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
wwjd777
(@wwjd777)
Member
Joined: 2 years ago
Posts: 20
Topic starter  

   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 

@wwjd777 

Glad it's working now.

No need to feel stupid, making mistakes and investigating them is how you learn things; I've found that I rarely learned anything by getting it right the first time. It's when you have to delve deeply into it that you really learn how it works by starting from how it doesn't work.

So now we've BOTH learned something 🙂

Anything seems possible when you don't know what you're talking about.


   
wwjd777 reacted
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 

@wwjd777 

By the way, you should check whether the update() function should only be called when you're interested (i.e. after each second) or every time through the loop.

Many classes require frequent calls because they're operating on some internal timing mechanism and so they require frequent calls to ensure proper operation.

Anything seems possible when you don't know what you're talking about.


   
wwjd777 reacted
ReplyQuote
wwjd777
(@wwjd777)
Member
Joined: 2 years ago
Posts: 20
Topic starter  
Posted by: @will

@wwjd777 

By the way, you should check whether the update() function should only be called when you're interested (i.e. after each second) or every time through the loop.

Many classes require frequent calls because they're operating on some internal timing mechanism and so they require frequent calls to ensure proper operation.

That is a very good point.  I checked and the update function must be checked frequently as it checks if the setUpdateInterval() time has passed. (I don't have the library code snippet here, I'm on another pc)

Yes I learned a lot by making many mistakes... The 'bat' on your Avatar has made the difference I think, made me look harder. 😉   thank you for your understanding!

 


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 
Posted by: @wwjd777

The 'bat' on your Avatar has made the difference I think, made me look harder. 😉

🙂

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
wwjd777
(@wwjd777)
Member
Joined: 2 years ago
Posts: 20
Topic starter  

   
ReplyQuote