If anyone has ideas, let me know please. Thank you !
I think your NTP time syncing code is not fail safe.
You try syncing 10 tries with a 1 second delay after sending the NTP request.
But what happens if the time server is slow in answering your requests? What if none of 10 requests in a row are answered within one second? And if even not the first reqest is answered within 10 seconds?
What if the first 9 out of 10 requests are not answered at all and the 10th and last request is answered after 2 seconds?
In that case this will happen:
- 9 requests time out and give no NTP time result
- 10th request will also time out, while no packet received within 1 second
- 1 second later the answer will be received and stay in the packet buffer
- after 3600 seconds, you start 10 new requests
- and now you will retrieve the answering packet that has been received 3589 seconds earlier
- so after one hour you do not evaluate what was the answering package to a new request, but you evaluate the answering package to a request that was sent 3591 seconds earlier and to which you got an answering package 3589 seconds earlier.
Who attached this comment:
// ******** FUNCTIONS ********
// Do not alter this function, it is used by the NTP system
I think it would be much better to debug buggy code than to forbid any changes on buggy code.
Even better would be to use a reliable NTP time server.
What is this for a time server?
// ******** NTP Server Settings ********
IPAddress timeServer(195, 200, 224, 66);
In which country is your Arduino to be operated?
Don't you know any "official and reliable" time servers in your country, that are provided by governmental or semigovernmental organizations for "public access" to NTP time?