Electron not publishing after Sleep (Stop Mode)

we’ll all be in trouble when this money saving feature gets fixed

@ScruffR Can you shed some light on the difference between the System.sleep() function and the manual Soft Power Down of the Electron.

I’m not too deep into the topic but “Soft Power Down” was introduced with this enhancement
https://github.com/spark/firmware/pull/767

The way I read the “blurb” there, it should have the same effect as

  Cellular.off();
  System.sleep(SLEEP_MODE_DEEP);

On the other hand - as the docs about System.sleep() tell - the API will give you better control how deep your device should sleep and when and how it should wake again.

Thanks @ScruffR. I was thinking why is the following working “The electron has been coming back online, after manually pressing Reset, with no problem every two hours and even after powered down overnight.” but as the Post title states the “Electron not Publishing after System.Sleep” Why does it work mechanically but not in code ( System.Sleep())?

The topic says “Stop Mode”, but deep sleep and hence Soft Power Down are what’s called “Standby Mode” (ST Microsystems jargon).
Stop Mode continues after wake with the next instruction after the System.sleep() call, while Standby Mode wakes as if the device just started and goes through all the bootup procedure including connetion and setup().

That’s the difference between System.sleep(SLEEP_MODE_DEEP [, wakeTime]) and System.sleep(wakePin, wakeEdge [, wakeTime]) - the former isStandby Mode the latter Stop Mode.

And hitting RESET might again change some nuances in the startup procedure.

2 Likes

Thanks @ScruffR.

Hi bpr,

I tried to compile it locally and then wrote a simple sleep program. But unfortunately my electron is behaving weird:

White 3 seconds
Fast green : 10 seconds
Fast Cyan : 2 seconds
Bursting Orange + Red : 1 second.

I am not sure why it is behaving. I tried to put the new cloud key but no luck.

Thanks,
Satyen

@satendra4u, not sure why you’d get that unless maybe you compiled from the main folder. Make sure you follow the instructions to run make… etc from the modules folder. Are you compiling from develop? I recently found it wouldn’t compile at all on develop, had to go back to v0.4.9
EDIT: Scratch that about the develop branch. I misspoke. I had that issue w/ a photon compile, not w/ electron. Received compile error: …/…/…/build/target/system/platform-6-m/\libsystem.a(system_sleep.o): In function CloudClass::process()': C:\particle\develop\system/../wiring/inc/spark_wiring_cloud.h:299: undefined reference toApplicationWatchdog::last_checkin’
I wasn’t even using sleep in that photon app. There might currently be a temporary issue in the develop branch.
EDIT2: electron stop mode sleep app just compiled fine for me in develop branch. Only get the problem w/ a photon.

Electron stop mode sleep now seems to work with local build on the develop branch as long as you merge feature/ping_configuration and ping the network somewheres around every 10 minutes (in my case). Electron was able to come out of stop mode sleep and publish every 30 minutes all night. Still seems to use about 20ma in stop mode but I only have an inaccurate usb power monitor. Some info here https://github.com/spark/firmware/pull/913 . I’m interested what other people find.

#include "Particle.h"

char publishStr[20];
volatile uint32_t start;
volatile int sleepInterval = 30;

void setup() {
  pinMode(D1, INPUT_PULLDOWN);

//each keepAlive ping uses 100bytes of data
//I've also tried every 19 mins but didn't work
  Particle.keepAlive(600);//10 minutes
}//setup()

void loop() {

  sprintf(publishStr, "%i", sleepInterval);
  Particle.publish("e1", publishStr, 60, PRIVATE);

  start = millis();
  while (millis() - start < 6000UL) {Particle.process();}

  System.sleep(D1, RISING, sleepInterval * 60); //, SLEEP_NETWORK_STANDBY); doesn't seem to work

  start = millis();
  while (millis() - start < 6000UL) {Particle.process();}

}//loop

One way to get the firmware installed and merged (on windows):

C:\particle>git clone https://github.com/spark/firmware.git electronstopmode

C:\particle>cd electronstopmode

//merge feature/ping_configuration with develop
C:\particle\electronstopmode>git merge 82fc1130d4aafc7b986327d74bad71fc1950cfb4

Then compile your app from modules

@bpr That’s good news!

So all I need is the Particle CLI to do this right? I don’t need all the other programs for compiling locally right? I’ll give this a try if so.

@RWB , No you do need to be able to compile locally AFAIK, unless there is some way to have Particle-CLI use the develop branch that I am not aware of.
Some more info on some apparent remaining issues: https://github.com/spark/firmware/pull/913#issuecomment-198835297

@bpr I read the link you provided.

So I see Bdub suggest a disconnect and reconnect if sleeping more than an hour to re establish a data connection with the cloud.

I’m a tad bit confused though. What exactly has changed for the better? Has any changes been made since you first started having this problem with wakeup and no publishing happening?

@RWB,

Me, too!! Beause all I changed was the keepAlive, which shouldn't have done anything :confused:

@bpr So do you have the System.sleep working on the Electron now?

I took a look at the git page and see you have it working now: https://github.com/spark/firmware/pull/913

1 Like

Seems to work fine off of develop branch now. Serial monitoring over >12 hrs indicated no missed publish connections ( think i published every hour or so) . Not sure of the data usage angle though.

@bpr That’s good to hear.

So with the current Electron firmware is the Web connectivity totally lost so no Web communication can happen or is it just the Particle cloud functions that do not fire off after a 21 min or longer sleep?

I was just thinking if it was just a particle Publish problem then I could just try connecting to Ubidots to send me a email when my mailbox door is opened. But if the Web connectivity does not work at all after waking from a long sleep then I guess that wouldn’t work either.

Still have not had time to figure out how to build firmware locally.

Well, now I’m finding that I no longer see successful publishes after about 5 stop mode wakeups (whether I set the wakeup interval to 30 minutes or 60 minutes). This is frustrating!
I learned that pubsuccess = Particle.publish("e1", publishStr, 60, PRIVATE); doesn’t really indicate a successful publish so I may have been misled, or results are just inconsistent perhaps. Anyone else testing electron stop mode wakeup connection to cloud under the develop branch of the firmware?

Is it just the Particle Cloud that does not work or is it all data transmission after wake up that is not working?

I’m attempting to send data to Ubidots instead of Particle.publish and see if it’s any different.

All I’m really testing is whether the publish upon awakening is working

I just tried to test if I could send data to Ubidots after a System.sleep wake but their new library will not compile so have to get that fixed before I can move forward with that test.