WeatherDuino Forum

Full Version: Time bug in AQM?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all

AQM firmware 320-b003

I'm not 100% sure but I think I may have found a bug in the way the AQM module updates the time - or more importantly what happens when it fails to update the time.

I have just put a display on my AQM module and watching the time it sometimes is an hour out, others not. I changed the run_everyHour to run every 10 mins for debug and turned on serial debug and here is what I see. (Ignore the extra serial debug prints of 'update start' and 'Hourly update run', those are mine to track the routine entry etc)

Sending NTP request to sync clock...
NTP replied
UTC time from NTP server: 01:14:41
Local time adjusted to: 13:14:41
Hourly update run
Update start

Sending NTP request to sync clock...
NTP replied
UTC time from NTP server: 01:24:42
Local time adjusted to: 13:24:42
Hourly update run
Update start

Sending NTP request to sync clock...
NTP Clock adjust failed!

Hourly update run
Update start

Sending NTP request to sync clock...
NTP replied
UTC time from NTP server: 01:34:42
Local time adjusted to: 13:34:42
Hourly update run
Update start

Sending NTP request to sync clock...
NTP replied
UTC time from NTP server: 01:44:42
Local time adjusted to: 13:44:42
Hourly update run


So from the above we see that if an update fails then (because I have set a 10 minute update interval) the time is now 10 minutes slow, and continues to be despite further good ntp updates.

This explains the problem I saw when the updates are hourly, if one update fails then the time remains an hour slow until a system restart is performed.

I'm not sure if anyone else has seen this problem, or maybe it is fixed already in a later version and I just need to upgrade the firmware?

Regards to all

Colin
Hi 41south,

Is good to hear from you again. Smile

I don't remember exactly what was the bug, but I remember of some issue related to the NTP sync on the v3.x branch.
I was comparing the NTP routines and they have changed on v4.x, possibly to fix that bug.

Try upgrading to v4.x.
v4.x also have other important changes (like allowing the use of AUSTRALIA (AQC - NSW) standard), but you will need to upgrade the receiver software too, otherwise you may receive wrong data from the AQM.

Rgs
And good to hear from you too sir, I hope you have been keeping well. Like

Yes I am quite a way behind the current version so I decided to upgrade to version 4. I will let you know the outcome  Smile

Regards
Colin
(16-04-2021, 05:05)Werk_AG Wrote: [ -> ] 
As far as I can tell the upgrade has fixed this, I should have done that first  Rolleyes

BTW the reason I found this was not so much adding the display, but a code modification I've been working on to send the data via MQTT to Weewx. I needed a time stamp in the message (which turned out to be a little tricky because I needed it in UTC time in epoch format) and while working on that discovered the other issue.

But I am please top report that both the time and sending MQTT payloads are now working just fine on version 4.

Cheers
Colin
Hi Colin,
(17-04-2021, 04:27)41south Wrote: [ -> ]...
But I am please top report that both the time and sending MQTT payloads are now working just fine on version 4.
...

Smile Thank you.
 

(17-04-2021, 04:27)41south Wrote: [ -> ]...
(which turned out to be a little tricky because I needed it in UTC time in epoch format)
...


Whenever you need UTC time in epoch format, you can use:
Code:
time_t UTC_time = myTZ.toUTC(now());


As said, it was a great pleasure read from you again.
Keep safe, take care.
Ah, thank you! My way worked, but this will be much easier  Big Grin

I must PM you soon regarding some other things I have been doing with this great system of yours ReadManual

Regards
Colin
 
(17-04-2021, 05:31)Werk_AG Wrote: [ -> ]Whenever you need UTC time in epoch format, you can use:
 
Code:
time_t UTC_time = myTZ.toUTC(now());
The WeatherDuino system is what it is, due to contributions of many users like you.
You are welcome to PM to me.

Cheers
Werk_AG
(17-04-2021, 05:45)41south Wrote: [ -> ]I must PM you soon regarding some other things I have been doing with this great system of yours ReadManual

I'd be interested to hear what you're been upto also Smile
Like Best I get on and do a writeup for you both then. I'm not sure it's anything that will ever be made public as it involves some pretty radical hardware and code changes that I wanted to do with my station. Standby for a PM in the next few days gents Smile
 
(18-04-2021, 23:10)uncle_bob Wrote: [ -> ]I'd be interested to hear what you're been upto also Smile