[Resolved] Electron doesn't wake after sleep interval

I have an Electron running 0.5.3 and after publishing I put it in stop mode with:

System.sleep(A0, FALLING, SleepS, SLEEP_NETWORK_STANDBY);

Where SleepS is 1200 (20 minutes). After connecting the battery, the Electron will publish then sleep for the expected interval, then wake as expected, publish, and sleep again. It doesn’t wake again after the second sleep. No RGB LED activity, nothing in the log for my Webhook; it just appears to stay in stop mode long after the sleep interval should’ve elapsed.

I originally had SleepS at 3600 but found another forum post that seemed to hint that anything over 25 minutes might be a problem, so I tried 20 and am seeing the same behavior.

A0 isn’t currently connected to anything but I intend to connect it to an active low button; the intent is to either wake when the button is pressed, or after the SleepS interval, whichever comes first.

What am I doing wrong?

Thank you

Can you provide a minimal runnable code that exhibits the same issue to test?
With that one line I can’t reproduce the same problem on my device?

1 Like

About an hour and half after the next wake was due, the board suddenly started publishing as expected. I’ve seen events published every 20 minutes four times. I did disconnect the serial cable from my PC after flashing the board, but didn’t disconnect and reconnect the battery… is it possible that may have caused the inital gap?

This is roughly what I’m doing:

#include "Particle.h"

unsigned long lastIntervalMS = 0;
const int SleepS = 1200;

void setup(void)
{
  Serial.begin(115200);
}

void loop(void)
{
  const unsigned long MS = millis();
  if ((MS - lastIntervalMS) >= 50)
  {
      lastIntervalMS = MS;

      // Do some hardware stuff here... return if we're not ready to publish yet.

      waitUntil(Particle.connected);
      Particle.publish("json", "{}", PRIVATE);

      System.sleep(A0, FALLING, SleepS, SLEEP_NETWORK_STANDBY);
  }
}

Thanks!

Hmm! Mine keeps waking for over an hour now every 20 min.

How are you powering your device?

1 Like

I’m using the 2000 mAh battery that came with the Electron kit.

It’s been waking every twenty minutes for me as well since my last post… not sure why there was that initial gap in time but it seems to be working great now.

1 Like