Electron not publishing after Sleep (Stop Mode)

I’ve played around with the timings a bit more. I’ve tried 20 minutes, 6 minutes, and 2 minutes, and now I can’t get any to work consistently. Here’s my current code:

#define publish_delay 10000
FuelGauge fuel;

void setup() {}

void loop() {
	long value=fuel.getSoC();
    Particle.publish("aiobatt", String(value), 60, PRIVATE);
    uint32_t start = millis();
    while (millis() - start < 5000UL) Particle.process();
    System.sleep(D0, RISING, 120);

If you compile locally you can make the code change that fixes this. If you do not compile locally then you will have to wait for the next firmware release to get the fix via the online IDE.

I also tried a few things but none of them worked out.

Please excuse my ignorance, but could you point me to a guide or a previous post about how to make the code change (if such a post exists)? I’ve been building and flashing via the particle cli, is there a switch of some sort or a procedure that I can do to include these changes?

Particle CLI does not build locally, so this part applies

For real local building you’d need to download a local toolchain (search the term to find where and how) and the complete system firmware (see open source section)

@ScruffR, slightly off-topic: I am usually building locally for my Photons. For the Electron I am bit confused as to which branch I should use. The Electron is for some reason on 0.4.8. I am not sure if I should flash 0.4.8, 0.4.9, 0.5.0 beta or develop. Are they all compatible with the Electron? Are 0.5.0 and develop compatible with the Photon?

The aim is to have all devices running off one repo, so you should be able to build any of the above for the Electron and Photon, but 0.4.8 is the only thoroughly tested one yet for Electron use specifically.
That’s the reason why this is currently considered the latest “stable” version.

But maybe @mdma might chime in with the official Particle statement, as I’m only a user too :wink:

1 Like

That was also my understanding. That’s why I was surprised and thought that maybe the other ones got a bit out of sync. I guess I will try with the 0.5 for now. I’d like to have some of the features of the 0.4.9. Thanks!

@BDub Hey I know your busy with a thousand different task but I wanted to ask about the System.sleep() function.

It seems that your https://github.com/spark/firmware/pull/845 code change.

@bpr Has been testing this fix out and has come to the conclusion that System.sleep() does work with your fix but not if the sleep time is set longer than 25 mins.

He posted this error on Git

Do you think this is another issue with the cellular IP address changing every 25 mins?

Having this same bug… Can others confirm that doing the local compile fix here is the right thing to do… Or should we wait for the web IDE change ? When might that be ?

Well, I was absolutely going to try the local compile, but I got sidetracked by other projects and life obligations. I’ll see if I can’t give it a shot tonight. No ETA on the 0.5.0 firmware that I’ve seen other than “Soon”.

Same situation here

With 0.4.8 it blinks green when it wakes from sleep (stop) for about 30 seconds.
Does this mean it’s handshaking and using 3-6k of data?
This will be fixed in 0.5.0 to save data usage?

Some times it will take 30 seconds to connect to the cellular network.

The System.sleep() function will not particle publish after the 2nd or 3rd wake up due to the current bug. The current fix which to get you need to be setup to compile locally fixes this issue but there is still a bug where if you sleep longer than 25 mins Particle.publish will not transfer successfully.

So we all have to wait until they get this fixed. No word yet on when that is going to be but hopefully soon considering its one of the most important features needed with the Electron.

1 Like

Just wanted to clarify that it will not use 3-6k of data after every sleep in 0.5.0 for handshaking?
This is indicated by my speakers clicking and fast green blink for 30 seconds?
What will be the maximum sleep (stop mode) to avoid handshake in 0.5.0?
Is there a temporary workaround in 0.4.8?

The temporary workaround is to get setup to build the firmware locally and then use the code change linked below.

This will get System.sleep working but it will not work right if you sleep longer than 25 mins right now. That’s a new bug that needs to be fixed.

I have been following this post about the System.sleep() function bug with the Electron. I was wondering what is the difference between the System.sleep() function and the manual Soft Power Down of the Electron?

Until the System.sleep() function is updated I have been manually putting the Electron into Soft Power Down* every two hours to simulate my program executing theSystem.sleep() function. The electron has been coming back online, after manually pressing Reset, with no problem every two hours and even after powered down overnight.

Do you mean aside from the interrupt waking the Electron?

it’s a good question!

according to the docs:

This uses a deep sleep mode for the Electron, and will still use 0.13mA


@autolib & @BulldogLowell The key issue as I understand it is not whether it comes back online fine but whether it has to “renegotiate” or whatever with the cell tower when it does come back up, because the data usage is quite a bit higher when it has to renegotiate. I’m pretty unschooled in these things so I may be confused

Well, the key issue for me is actually reconnecting! Right now, without being able to reconnect, I save a ton of money on Data.