I am currently experiencing some problems with publishing a bunch of values to the cloud.
The basic functionality of the device is:
Power up
Take sensor reading
Store it in retained Int Array
If it's booting up for the 12th time:
Collect all data and publish it to the cloud
Back to sleep
Right now some of the Electrons (I have a small series of prototypes running) are coming online (status message is published in cloud) but the data I want to publish is not reaching the cloud.
Some of the devices might be in regions with bad cellular coverage, but the fact that they get online makes me think that connectivity in general is not an issue.
Has anybody experienced similar problems?
Could timing be an issue?
@rickkas7 once wrote in a mail: "I added a delay(8000); before the publish because a few were getting lost"
Are there other parts in the code where an additional delay would make sense?
This code has been working fine for quite some time now, but I am getting these errors quite frequently now. I just attached the parts where I suspect the error to come from:
By the way - the device is running in Semi-Auto Mode .
void setup(){
Particle.connect();
waitFor(Particle.connected, 45000);
delay(8000);
Particle.publish("s",concatMsg(aDist,getRssi(Cellular.RSSI()),getQual(Cellular.RSSI()),getBatt()),ttl,PRIVATE);
Particle.process();
delay(30000);
}
String concatMsg(int dist[],int rssi, int qual, int batt){
// Create comma-seperated String out of all parameters
// 12 x Distance, RSSI, Signal Quality, Battery
// Example: "120,115,113,110,105,98,98,80,61,30,80,57,89,25,88"
String msg = "";
for(int i = 0; i<sendInterval; i++){
msg += String(dist[i]);
msg += ",";
}
msg += (String(rssi));
msg+=",";
msg += (String(qual));
msg+=",";
msg += (String(batt));
return msg;
}
@ScruffR pointed out that working with strings might cause issues with memory, but it has worked fine for quite some time now (about 2-3 months) - I don't know if that might be the cause: