Electron not publishing after Sleep (Stop Mode)

Looking good data usage wise according to the data counters - we’ll see tomorrow when the the Billing & Usage display updates :fearful:
I did find that sending two small floats (Volts and SoC) directly to Ubidots appeared to consume 5-7 times what a publish to the particle cloud consumes, so I simply have the electron publish to the particle cloud and have a photon subscribing to that publish event and the photon then sends the data to Ubidots.

Thanks for running that test of Particle.publish (Volts and SoC) vs Ubidots publish (Volts and SoC).

5-700% more data consumption per transmission really adds up if your sending frequently. I’m currently publishing (Volts and SoC) data every 60 mins on one device and every half hour on another Electron just for play. They both wake up instantly to berating blue LED and go right back to sleep exactly as expected.

It’s so nice that the Electrons maintain solid reliable data network connections. Since I use my cell phone for my main WiFi hot spot my Wifi connection is always going in and out and leaves with me every time I go some where. The Electons just work all the time now and that’s great to see now with the System.sleep function working correctly.

@aguspg Based on the testing that @bpr has done with tracking data used vs Particle Publish vs Ubidots publish is there any way we can get the data into Ubidots using the lower data rate Particle.Publish method?

Can Ubidots listen for Particle.publish events and store them in the database like normal some how?

Thanks for your input @bpr! we’re improving the Particle library now that the electron is out and data usage quickly became a priority. To make sure you have the latest, click on the “i” for more info next to the library:

Then click on the latest one:

@RWB yes we had done a Particle publish integration but there’s a limit on how much Particle users can send data to external hosts, so it quickly became crowded. We’re talking to Particle to extend this limit.

Next step: provide an option to choose another protocol different than TCP.

2 Likes

@bpr Hey how has the system sleep mode been working for you with the new firmware?

I have been reliably sending data to Ubidots from 2 Electrons with wake periods of 30 mins on one and 1 hour on the other. Zero problems so far.

I’ve been running the Electron off the fully charged 2000mAh battery for a week straight with 30 min wake up periods.

3 Likes

@RWB Yes works well though mine pooped out at Volts= 3.79 and SoC= 72.09 after just under 5 days using NO_ACK (pretty darn reliable) using the code below. Could you show your code?

Edit: forgot to mention I just pulished to cloud and then had a photon subscribe to the event which then published to Ubidots and maybe used only 0.16MB? or so

#include "Particle.h"

SYSTEM_MODE(AUTOMATIC);
char publishStr[20];
int sleepInterval = 30;
uint32_t start;

void publishData() {

  FuelGauge fuel;
  sprintf(publishStr, "%02.2f %03.2f", fuel.getVCell(), fuel.getSoC());
  Particle.publish("e2", publishStr, PRIVATE, NO_ACK);
  start = millis();
  while (millis() - start < 1000UL) {  Particle.process();}

}//void publishData()


void setup() {
  pinMode(D1, INPUT);
  pinMode(WKP, INPUT);
}//setup()

void loop() {

  publishData();

  System.sleep(D1, RISING, 60 * sleepInterval);

}//loop

@BPR I like how your keeping data rates down by using particle publish to a Photon.

Have you tried this yet?

It looks as if it would accomplish the same thing without needing the extra Photon in the mix. Basically Ubidots will receive the Particle.publish event directly without needing the Photon to redirect it. Let me know.

And here is the code I'm using to send data directly to Ubidots. If your willing run a Data rate test vs the Particle.publish directly to Ubidots and see what the difference is.

// This #include statement was automatically added by the Particle IDE.
#include "Ubidots/Ubidots.h"

#define TOKEN "TGiZfnCx9eWGlLC"  // 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 = 60;


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 the webhook method is interesting. Haven’t tried it yet. I am finding that publishing when using the SLEEP_NETWORK_STANDBY parameter fails except for the first initial bootup publish unless the sleep period is rather short (only tested 3 minutes vs 30 minutes). Wonder why SLEEP_NETWORK_STANDBY is not working for me? Could it be that NO_ACK and SLEEP_NETWORK_STANDBY don’t play well together at longer intervals ? Something else the matter with my code?

@BPR The SLEEP_NETWORK_STANDBY just allows a quick re-connection to the 3G network when waking right? I think without the SLEEP_NETWORK_STANDBY you get the flashing green light for approx 30 seconds while waiting on the Electron to reconnect to the 3G network after waking up. I think I have that right.

I have not tried the NO_ACK yet so maybe that is causing your problems. Or it could be just a Particle Publish issue since I’m having no problems sending data to Ubidots directly.

When you tested the Ubidots data rates were you using their latest code? I wonder if the new code is still using 600% more data than the Particle.publish?

I’m just happy the System.sleep is working and I can wake from a Pin change state now but as your trying now getting the data transfer rates as low as possible is the next step for optimization.

Keep me updated, I’m very short on time or I would be doing all this with you.

Hi, All. I’m trying to post data to Ubidots using my Electron (Firmware 0.4.8). I can post approx 5 secs worth of data to my Ubidots dashboard, but then my Electron hangs. That is, after 5 secs of running it does not post data to Ubidots dashboard. In addition, I can not re-flash my Electron remotely (over 3G), and therefore, I have to set manually the system into SAFE MODE. Note: I’m not using Particle SIM, but a Telstra SIM card (Australian). Also, I’m using Particle’s Solar Sheild. Can someone please help me or point me in the right direction?

Long term, I’m keen to use System.sleep(SLEEP_MODE_DEEP,60) to increase my Electron solar / battery life.

Thanks

// This example is to save multiple variables to the Ubidots API

// Define Telstra APN 
#include "cellular_hal.h"
STARTUP(cellular_credentials_set("telstra.iph", "", "", NULL));

// This #include statement was automatically added by the Particle IDE.
#include "Ubidots/Ubidots.h"
#define TOKEN "BYVc##############syZ"  // Put here your Ubidots TOKEN
Ubidots ubidots(TOKEN); // A data source with particle name will be created in your Ubidots account

void setup(){
    pinMode(A0,INPUT);  // Our photoresistor pin is input (reading the photoresistor)
    pinMode(D7,OUTPUT); // Make D7 an output pin
}

void loop(){
    
    // Define fuel
    FuelGauge fuel;
    
    float value1 = fuel.getVCell();
    float value2 = fuel.getSoC();
    
    float value3 = analogRead(A0); 
    
    ubidots.add("BatVolts", value1);  // Change for your variable name
    ubidots.add("SoC", value2);  // Change for your variable name
    ubidots.add("Depth", value3);  // Change for your variable name
    ubidots.sendAll();
    
    digitalWrite(D7,HIGH);
    delay(100);
    digitalWrite(D7,LOW);
    delay(1000);

    // Loop again...

}

@samb375, you may want to try with the latest 0.5.0 firmware which has a lot of fixes since 0.4.8.

Can you try the code I'm using in this post and see if it gives you trouble or not? It's been working flawlessly for me. I'm using the Particle SIM card.

@RWB What firmware version are you using? 0.4.8?

@peekay123 I tried updating my Electron firmware, but I failed many times… It not as straightforward as I thought. How did you do Electron firmware update?

Easiest way to update the Electron to the 0.5.0 firmware that I have found is to use the windows or mac updater app at this link: https://github.com/spark/firmware/releases/tag/v0.5.0

Look for these files at the bottom of the page:

1 Like

I was using 0.4.8.

I just now updated to 0.5.0 and it is sending battery status data to Ubidots after the update.

It works perfectly! Thank you @RWB, and @peekay123 for your help!! :grinning:

I’m very excited… it also flashes remotely via 3G now!!! A very happy person :smiley:

That Windows updater is a gift from the programming Gods for us beginner guys who don’t want to go down the CLI programming interface if not absolutely necessary :smile:

Thanks @BDub & @mdma for the Updater Exe programs!

1 Like

Thank you @BDub and @mdma… great Windows updater!!

1 Like

In function 'void loop()':
test_sleep.cpp:28:32: error: 'SLEEP_NETWORK_STANDBY' was not declared in this scope
}//setup()

This is the error message i am taking when i compile your code... Any help??