Electron stops sending data while still connected to 3G network

Hi There

I’m trying to make a simpel firmware that sends accelerometer data to the cloud for each 30 seconds with a sample rate of 1 s.

I have managede to code the firmware and it’s working as supposed to, until its not. For some reason after 2-3 hours it stops sending the data chunk to the cloud, but the device is still connected from what I can see in the Particle Cloud view.

My suspicion is that maybe the code gets a timeout maybe on something and block the loop().

Can somebody see in the code what’s wrong?

#include "Particle.h"
#include "ADXL362DMA.h"

// Libraries above can be found here:
// https://github.com/rickkas7/ADXL362DMA

// System threading is required for this project
SYSTEM_THREAD(ENABLED);

const unsigned int publishPointCount = 30;
String publishMessage = "";
//String DataTag = "simulation";
byte pointCount = 0;

// Connect the ADXL362 breakout:
// VIN: 3V3
// GND: GND
// SCL: A3 (SCK)
// SDA: A5 (MOSI)
// SDO: A4 (MISO)
// CS: A2 (SS)
// INT2: no connection
// INT1: D2
ADXL362DMA accel(SPI, A2);

// This is the pin connected to the INT1 pin on the ADXL362 breakout
// Don't use D0 or D1; they are used for I2C to the PowerShield battery monitor
const int ACCEL_INT_PIN = D2;

void setup() {
	Serial.begin(9600);
	
  	accel.softReset();

	while(accel.readStatus() == 0) {
		Serial.println("no status yet, waiting for device");
		delay(1000);
	}

	 accel.setMeasureMode(true); //Start Meassurement	
}

void loop() {
	int x, y, z, t;
	accel.readXYZT(x, y, z, t);
	Serial.printlnf("New data point [x = %u, y = %u, z = %u]", x, y, z);

	//Build message
	char data[128];
	sprintf(data, "%d,%d,%d;", x, y, z);
	publishMessage = publishMessage + data;
	pointCount++;

	//Validate if message should be sent to Azure
	if (pointCount == publishPointCount){

		Particle.publish("azure", publishMessage);
		Serial.printlnf(Time.timeStr() + " Message send to azure:" + publishMessage);

		publishMessage = "";
		pointCount = 0;

	}

	delay(1000);
}

I’m using a ADXL362 accelerometer on an Electron, running the latest firmware from Particle.

Any help is highly appreciated :slight_smile:

Kind regards
Nikolai