@bpr Are you using the bit of code in your sketch?
Iāve tried many variations, from using Serial1DebugOutput debugOutput(115200, ALL_LEVEL); debug output to check and print to serial the success of the publish (always returned true, erroneously), to using various hard and soft delays before and after the publish (try to keep cloud connection open to get the publish out the door) to a bare bones stripped down version like so:
#include "Particle.h"
char publishStr[10];
uint32_t start;
int sleepInterval = 30;
bool pubsuccess;
void setup() {
pinMode(D1, INPUT_PULLDOWN);
}//setup()
void loop() {
sprintf(publishStr, "%iM",sleepInterval);
pubsuccess = Particle.publish("e1", publishStr, 60, PRIVATE);
System.sleep(D1, RISING, sleepInterval * 60);
}//loop
but it just eventually stops publishing after around 5 awakenings. Even waking it up with pin D1 doesnāt get it to start publishing again, though itāll blink green and then breathe cyan for awhile before resuming sleep.
Bummer.
Be sure to add this to the Git issue so they can keep working on this considering itās a rather key feature for the Electron.
Keep me posted on the progress if you can.
@RWB The cavalry is coming! Just noticed release/v0.5.0 is showing up in the repo (probably soon to appear in the Web IDE) and includes PR#909 and 918.
Iām getting good results with this:
#include "Particle.h"
SYSTEM_MODE(AUTOMATIC); //(MANUAL);
char publishStr[10];
uint32_t start;
int sleepInterval = 60;
bool pubsuccess;
void setup() {
pinMode(D1, INPUT_PULLDOWN);
}//setup()
void loop() {
delay(1);
Particle.connect();
waitFor(Particle.connected, 60000);
Particle.process();
sprintf(publishStr, "%iM",sleepInterval);
pubsuccess = Particle.publish("e1", publishStr, 60, PRIVATE);
System.sleep(D1, RISING, sleepInterval * 60);
}//loop
waitFor(Particle.connected) above seems rather important. Iām unsure about the pros/cons of
System.sleep(D1, RISING, sleepInterval * 60, SLEEP_NETWORK_STANDBY);
// Does not turn off network
(effect on battery drain ?)
EDIT: re current/battery drain - I have an inexpensive current meter, so this could be off a bit but Iām getting 10-20ma sleeping without SLEEP_NETWORK_STANDBY and 20-60ma with SLEEP_NETWORK_STANDBY while asleep along with a lot of current draw fluctuations between 20-60ma. I havenāt found SLEEP_NETWORK_STANDBY to be necessary when sleeping an hour (not tested above that). With STANDBY you seem to be able to skip the 15-30 seconds of blinking green and are able to directly wake up breathing cyan and rapidly fall back asleep, so some battery drain is avoided
also unsure if Particle.connect();
is actually necessary or not. doesnāt seem to be with AUTOMATIC mode
@BPR good to hear that
So to be clear your seeing success with the v0.5.0 firmware right?
correct, though the develop branch with those pull requests had the important changes a little earlier. You have to get your local toolchain set up! Youāre missing all the fun!
Iām interested in avoiding data overhead of 5-6k each time it wakes. Anybody got that working yet with v0.5.0 firmware? Iād like to do 10-20 minute cycles.
Where do we look to see when new firmware (0.5.0 first) is released for the Web IDE? Is there any way to be notified a day in advance so we can schedule time to try it?
@sbright33 @RWB Iāve been playing around a lot with this. I really wish there was a way to get near real-time data usage info. Seems like it should be possible from the electron somehow?
My current test app:
#include "Particle.h"
//SEMI_AUTOMATIC APPEARS BEST FOR STOP MODE
#define SEMI //MAN //AUTO
#ifdef AUTO
SYSTEM_MODE(AUTOMATIC);//most reliable?
#endif
#ifdef SEMI
SYSTEM_MODE(SEMI_AUTOMATIC);//lesser current?
#endif
#ifdef MAN
SYSTEM_MODE(MANUAL); //least current?
#endif
char publishStr[10];
int sleepInterval = 0;
bool pubsuccess;
void setup() {
pinMode(D1, INPUT_PULLDOWN);
//!!!! to retain ability to flash you should connect to the cloud here and delay at least
/// 20 seconds to retain ability to reflash the electron if you are flashing OTA!!!!!
}//setup()
void loop() {
delay(10);//SEEMS to increase reliability??
System.sleep(D1, RISING, SLEEP_NETWORK_STANDBY);// wake on pin D1
delay(10);//SEEMS to increase reliability??
#ifdef MAN
Cellular.on();
// while (!Cellular.connecting()) {} doesn't compile
// while (!Cellular.ready()) {} //steady blue, freezes
Particle.connect();
waitUntil(Particle.connected);
// Particle.process(); //doesn't seem necessary
#endif
#ifdef SEMI
Particle.connect(); //breathes white without this
waitUntil(Particle.connected);
// Particle.process(); //doesn't seem necessary
#endif
sprintf(publishStr, "%iMS",sleepInterval);
pubsuccess = Particle.publish("e1", publishStr, 60, PRIVATE);
// System.sleep(D1, RISING, sleepInterval * 60);// has to renegotiate connection
// System.sleep(D1, RISING, sleepInterval * 60, SLEEP_NETWORK_STANDBY);// Does not turn off network
// System.sleep(D1, RISING, SLEEP_NETWORK_STANDBY);// wake on pin D1
}//loop
@BPR I do not have a half or whole day dedicated to figuring out how to compile locally so at this point Iām just waiting for the 5.0 firmware to come out and hope it fixes the problems.
@sbright33 You should be able to see the 0.5.0 firmware become selectable next to your Electron when compiling via the Web IDE. Not sure how you would do it when building locally because I donāt do that.
@sbright33, there will be a notification in this forum, just keep your eyes open
But a rough indication when itāll become likely to hit the decks can be found here
https://github.com/spark/firmware/milestones
And even after itās released you donāt have to go to the new version, if you are not sure whether your project will work with it or not.
You can always choose to target older firmware versions on Build till you were able to throroughly test agains the new version (or you go the local build road already).
OK, so over the weekend what was working great - electron able to publish despite stop mode sleep periods longer than about 25-26 minutes - isnāt working so great now (all on develop branch. there were some changes I pulled in, didnāt register what they were). Now what happens under both AUTOMATIC and SEMI_AUTOMATIC system modes in wakeup after >25 minutes is the device shows is dashboard as coming online but no publish, unless I wake it up again within 25-26 minutes of the earlier failed publish attempt, and that publish works. Could it just be itās just all inconsistent, the recent firmware changes on develop, my code is bad, I just canāt figure it out.
So Iām just curious if its all data communication that does not work when you try to Particle Publish an it does not work or is it just the Particle Cloud Publish function that is not working?
If itās just the Particle Publish that is not working then I would be looking at a different service to push my event dat to.
Iām just waiting till the 0.5.0 firmware is ready to try to play with all this.
Initial testing seems to result in the following code (with delays) successfully publishing after > 25 minute sleep. Iāll try to check it again in the morning. Iām interested if others are finding this.
//pulldown resistors on both D1 and WKP
#include "Particle.h"
SYSTEM_MODE(AUTOMATIC);
char publishStr[10];
int sleepInterval = 0;
bool pubsuccess;
uint32_t start;
void setup() {
pinMode(D1, INPUT);
}//setup()
void loop() {
delay(1);
System.sleep(D1, RISING, SLEEP_NETWORK_STANDBY);// wake on pin D1
//next try delay here
start = millis();
while (millis() - start < 6000UL) {Particle.process();}
sprintf(publishStr, "%iMS",sleepInterval);
waitUntil(Particle.connected);
//next try delay here
start = millis();
while (millis() - start < 6000UL) {Particle.process();}
pubsuccess = Particle.publish("e1", publishStr, 60, PRIVATE);
}//loop
@BPR OK, now Iām running 0.5.0_r1 firmware
Here is the code that Iām using now. Iām not Particle.publishing but instead sending the battery SOC and Voltage readings to Ubidots.
From your previous post I added the SLEEP_NETWORK_STANDBY to the System.sleep code and now when it wakes up it skips the 15-30 seconds of flashing green which is great since now it just wakes up and is instantly ready to send data since itās already connected to the cellular network.
For now Iām just sleeping for 1 min for quick testing but now I need to stretch out the sleep times to see i there are any network connect issues after sleeping for 30 mins or hours.
Here is the code Iām using:
// This #include statement was automatically added by the Particle IDE.
#include "Ubidots/Ubidots.h"
#define TOKEN "Your Token Goes Here" // Put here your Ubidots TOKEN
Ubidots ubidots(TOKEN); // A data source with particle name will be created in your Ubidots account
int button = D0;
int ledPin = D7; // LED connected to D1
int sleepInterval = 1;
void setup(){
pinMode(button, INPUT_PULLDOWN); // sets pin as input
pinMode(ledPin, OUTPUT); // sets pin as output
//Serial.begin(115200);
ubidots.setDatasourceName("PinWakeTestCode"); // Uncomment this line to change the data source Name.
}
void loop(){
FuelGauge fuel;
float value1 = fuel.getVCell();
float value2 = fuel.getSoC();
ubidots.add("Volts", value1); // Change for your variable name
ubidots.add("SOC", value2);
ubidots.sendAll();
digitalWrite(ledPin, HIGH); // sets the LED on
delay(500); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(500); // waits for a second
digitalWrite(ledPin, HIGH); // sets the LED on
delay(500); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(500); // waits for a second
digitalWrite(ledPin, HIGH); // sets the LED on
delay(500); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(500); // waits for a second
System.sleep(D0, RISING, sleepInterval * 60, SLEEP_NETWORK_STANDBY);
}
@RWB great to see you can test stop mode on electron now! For some reason I seem to need delays both before and after sleep call to get it functioning reliably. Not sure why I do, but you donāt. Also, while it avoids the long blinking green renegotiation with sleep < 26 mins, > 26 minute sleep (approx) still has to go through the long blinking green cycle. Hereās my SEMI_AUTOMATIC mode test app:
//pulldown resistors on both D1 and WKP
#include "Particle.h"
//SYSTEM_MODE(AUTOMATIC);
SYSTEM_MODE(SEMI_AUTOMATIC);
char publishStr[10];
int sleepInterval = 0;
bool pubsuccess;
uint32_t start;
void setup() {
pinMode(D1, INPUT);
Particle.connect();
waitUntil(Particle.connected);
//next try delay here
start = millis();
while (millis() - start < 6000UL) {Particle.process();}
}//setup()
void loop() {
delay(1);
System.sleep(D1, RISING, SLEEP_NETWORK_STANDBY);// wake on pin D1
//next try delay here
start = millis();
while (millis() - start < 6000UL) {Particle.process();}
sprintf(publishStr, "%iMSSA",sleepInterval);
Particle.connect(); //do we need this??? apparently DO if
//sleep duration > 25 mins
waitUntil(Particle.connected);
//next try delay here
start = millis();
while (millis() - start < 6000UL) {Particle.process();}
pubsuccess = Particle.publish("e1", publishStr, 60, PRIVATE);
}//loop
@bpr I have been running the Electron with the code I posted above except I changed the sleep delay to 30 mins.
Itās working perfectly which is good news. I guess Iāll try pushing it to 1 hour sleep sessions now.
Are you seeing any issues with Particle Publish reliability at any delay time with the latest firmware?
@RWB reliability seems good regardless of sleep period, but not tested extensively. Since Iāve been using manual wakeup, it woke and published after 8 -9 hrs fine. Are you getting the blinking green renegotiation when sleeping 30 -60 mins like I am?
I think the green happens after about 2x minutes. I forgot 21? 28?
@bpr @sbright33 I started sleeping for 1 hour and when it wakes up after 1 hour there is no flashing green, it just goes directly to breathing cyan.
What does the flashing green actually mean?