Problem establishing timers with TimeAlarms

Hello,

I'm having problems for establishing timers.
It does work if I take that specific code into a new sketch, but it doesn't in my project. Maybe due to RAM problems, I still need to check this further.

Anyway, here is the code:
Edit

I want to set 18 timers, one for each sensor.
Each call of the timer will execute sendData().
In order to know which sensor should read, it will take the AlarmID, cause it corresponds with the index of the sensor in the array ports[].

But after connecting to Galileo, it is called at unexpected times.
After putting the setting of the timers into a separate function, the function is not called at all, although the sketch can still get UDP messages and works normally.

  • establish not stablish.
Alarm.timerRepeat(ports[i].interval,sendData);    //Alarm.id => datatemp[i]

When sendData gets called, how will it know which sensor to print data from?

void sendData(){
  udp.beginPacket(remote,localPort);
  udp.print(macS);
  udp.print(index);
  udp.print(data[index]);
  udp.endPacket();
  moveIndex();
  Serial.print(F("ID "));
  Serial.println(Alarm.getTriggeredAlarmId());
}

It looks like you'll get whatever value happened to be in index last when the alarm goes off. Is that intended?

float data[DATA_SIZE] = {1,2,3,4,5,6,7,8,9,10}; //buffer for local data, queue

I'm always impressed when people use a float array and integer initializers.

Where is this array actually used?

Yes, by the moment it should print just something since I still don't have connected the sensors.
I explain it after the code. The ID alarm and the index of the corresponding sensor, are the same.

It is used in sendData(). I used integers for fast typing.
Is it actually a problem with Arduino? Because it always worked for me.

I want to set 18 timers, one for each sensor.

From the TimeAlarms readme

Q: How many alarms can be created?
A: Up to six alarms can be scheduled.
The number of alarms can be changed in the TimeAlarms header file (set by the constant dtNBR_ALARMS,
note that the RAM used equals dtNBR_ALARMS * 11)

Have you changed the constant in the .h file as suggested ?

Yes I did. It was the first thing I did.
Actually, u need to change it in the library, defining it again in the sketch is not valid.

As I said, if I take all the respective code about timers in a separate sketch, it works well.
It sets 18 timers and they are triggered in time.

In the loop, freeRam gives 881. I still need to check about setting the timers up.

Actually, u need to change it in the library, defining it again in the sketch is not valid.

That is what the readme tells you to do, after all.

I found the problem, there was a mistake in the configuration message.

Thanks for answering :smiley: