B4R Question rESP8266rtc erroneous alarms

daveinhull

Active Member
Licensed User
Longtime User
Hi all,

I'm using the very nice little library called rESP8266rtc and it generally works very well.
However, I'm getting spurious alarms happening.
I've set an alarm using the
B4X:
rtc.SetAlarm(1,rtc.ThisTime(12,1,0))
In the alarm routine I'm just setting a flag at the moment to test the code, but this will be replaced with something useful. Then I just reset the alarm with another call to the same as above.
The alarm fires perfectly on time, but then a few (appears random) minutes later it triggers again.
Has anyone used this library and seen anything similar, or have any thoughts on what could be causing it.
The rtc event handler is reacting to the item 0 alarm call which is the second tick.
There's no other timers, but there is some regular astream.writes to the WiFi.

Any thoughts anyone, thanks
Dave
 

daveinhull

Active Member
Licensed User
Longtime User
Hi again,

A bit of follow-up. I had the one second tick event enabled, I.e.
B4X:
rtc1.initialise ("RTC_Event",true)
So thought to disable this, and now the spurious alarms have stopped.
I'm no C expert, but I took a look at the C library code around the SetAlarm and the start_one_second_tick functions. In both these functions there is reference to a variable called 'counter' but with no declaration, and the first use is
B4X:
counter++;
I was under the belief that in C you had to explicitly declare variables and I would have thought also to initialise them. For example the start_one_second_tick function is
B4X:
Void B4RESP8266rtc::start_one_second_tick() {
counter++;
if (counter==0) counter=1;
this->enabled[0] = counter;
scheduler.add(millis() + 1000, fncu, counter, this);
}

Shouldn't this cause a compiler error and even if you don't need to explicitly declare variables won't it give unpredictable results?
Am I missing something?

Thanks
Dave
 
Upvote 0

daveinhull

Active Member
Licensed User
Longtime User
Ok, stupid me, forgot to check the .h file, declaration is in there, sorry.

However, if anyone has used this library, have they tried it with both the second tick set to true and also an alarm set? Did it work?

Dave
 
Upvote 0
Top