Issues with connecting after Stop Sleep

I need my Electron to wait for 30 seconds before it continues collecting additional data, and to make this process more energy efficient I want it to enter sleep mode. I'm using a third-party sim (unsure if related to this), and whenever I enter stop sleep mode, my Electron is unable to connect afterwards. It runs in Semi-Automatic mode, and Particle.connect is called only after it wakes up. A simplified sample of my code looks like:

STARTUP(cellular_credentials_set("m2minternet.apn", "", "", NULL));
unsigned int lastConnectSample = 0;

void setup() {
Particle.function("digitalread", tinkerDigitalRead);
Particle.function("digitalwrite", tinkerDigitalWrite);
Particle.function("analogread", tinkerAnalogRead);
Particle.function("analogwrite", tinkerAnalogWrite);


System.sleep(D0, RISING, 30);

if (millis() - lastConnectSample >= 8000) {
lastConnectSample = millis();

Particle.connect definitely is being called repeatedly. I'm thinking it may have forgotten it's APN credentials after waking up?

Found the issue; Cellular.on() needs to be called after waking up. Was confused, as this isn’t required by default when it initially starts running code.

1 Like

Thank you for posting your solution!