Electron doesn't connect to Particle cloud after draining battery

Hi all,

I have a problem connecting an electron to the cloud following a battery test where I completly drained the battery.

In the draining test, I was running a script that used deep sleep and woke up every 15 minutes, turn on cellular, publish to the cloud, and turn off before going back to deep sleep. This test was a succes. However, after complety draining the battery, I connected it to USB to recharge and now it doesn’t connect to the Particle cloud anymore. The battery does charge. It starts to connect (blinking green), then starts to log into the Particle cloud (blinking Cyan) but instead of breathing Cyan it starts breathing white and quickly goes back to blinking green.

Could it be that this device is somehow blocked by the Particle Cloud? I can imagine that under the wrong circumstances, just before completely draining the battery, it might have tried to connect very often. As in: wake up, try to connect, require just to much power from battery, power down. Start up again, etc.

I have tried the following things already:

  • upload (DFU) a script to the electron that does not connect and only charges the battery and monitors this charge over Serial. This work fine.
  • upload tinker (DFU). Tinker shows the same problem when trying to connect.
  • run particle keys doctor [device ID] from the CLI. No change.

Any thoughts? I need to deploy 15 electrons next week that need to survive draining their battery for an scientific experiment, so any help is appreciated.

@RolfHut when that happened (battery drained), what is the state of the electron?

sorry, I don’t understand your question. What do you mean with “state”? The battery test took two days, I wasn’t there when it drained. I guess, since all power is used during the cell connect, it must have been connecting when it finally drained.

Was the RGB status led on? Was the red charging led on?

What is the current behavior like when you power up the electron? Does it blink green?

@RolfHut Here is the code structure I’m using to keep the Electron from draining the battery completely and it also resets the modem one time if the Electron does not connect to the cloud after trying for 5 mins which helps from my testing.

SYSTEM_MODE(SEMI_AUTOMATIC);
//SYSTEM_THREAD(ENABLED);
// This #include statement was automatically added by the Particle IDE.
#include "Ubidots/Ubidots.h"

#define TOKEN "Your Ubidots Token"  // Put here your Ubidots TOKEN
#define DATA_SOURCE_NAME "ElectronSleepNew"

SerialLogHandler logHandler(LOG_LEVEL_ALL);  //This serial prints system process via USB incase you need to debug any problems you may be having with the system.

Ubidots ubidots(TOKEN); // A data source with particle name will be created in your Ubidots account


int button = D0;         // Connect a Button to Pin D0 to Wake the Electron when in System Sleep mode. 
int ledPin = D7;         // LED connected to D1
int sleepInterval = 60;  // This is used below for sleep times and is equal to 60 seconds of time. 


void setup() {
 //Serial.begin(115200);
 pinMode(button, INPUT_PULLDOWN);  // Sets pin as input
 pinMode(ledPin, OUTPUT);          // Sets pin as output

 ubidots.setDatasourceName(DATA_SOURCE_NAME); //This name will automatically show up in Ubidots the first time you post data. 
 
 PMIC pmic; //Initalize the PMIC class so you can call the Power Management functions below. 
 pmic.setChargeCurrent(0,0,1,0,0,0); //Set charging current to 1024mA (512 + 512 offset)
 pmic.setInputVoltageLimit(4840);   //Set the lowest input voltage to 4.84 volts. This keeps my 5v solar panel from operating below 4.84 volts.  
}

void loop() {
    
FuelGauge fuel; // Initalize the Fuel Gauge so we can call the fuel gauge functions below. 
 
    
if(fuel.getSoC() > 20) // If the battery SOC is above 20% then we will turn on the modem and then send the sensor data. 
  {
   
   float value1 = fuel.getVCell();
   float value2 = fuel.getSoC();
   
  ubidots.add("Volts", value1);  // Change for your variable name
  ubidots.add("SOC", value2);    

  Cellular.connect();  // This command turns on the Cellular Modem and tells it to connect to the cellular network. 
  
   if (!waitFor(Cellular.ready, 600000)) { //If the cellular modem does not successfuly connect to the cellular network in 10 mins then go back to sleep via the sleep command below. After 5 mins of not successfuly connecting the modem will reset.  
    
    System.sleep(D0, RISING,sleepInterval * 2, SLEEP_NETWORK_STANDBY); //Put the Electron into Sleep Mode for 2 Mins + leave the Modem in Sleep Standby mode so when you wake up the modem is ready to send data vs a full reconnection process.  
    
}  
  
     ubidots.sendAll(); // Send fuel gauge data to your Ubidots account. 

     digitalWrite(ledPin, HIGH);   // Sets the LED on
     delay(250);                   // waits for a second
     digitalWrite(ledPin, LOW);    // Sets the LED off
     delay(250);                   // waits for a second
     digitalWrite(ledPin, HIGH);   // Sets the LED on
     delay(250);                   // waits for a second
     digitalWrite(ledPin, LOW);    // Sets the LED off
  
     System.sleep(D0, RISING,sleepInterval * 2, SLEEP_NETWORK_STANDBY); //Put the Electron into Sleep Mode for 2 Mins + leave the Modem in Sleep Standby mode so when you wake up the modem is ready to send data vs a full reconnection process.  
    
  }
  else //If the battery SOC is below 20% then we will flash the LED 4 times so we know. Then put the device into deep sleep for 1 hour and check SOC again. 
  {
      
  //The 6 lines of code below are needed to turn off the Modem before sleeping if your using SYSTEM_THREAD(ENABLED); with the current 0.6.0 firmware. It's a AT Command problem currently. 
  //Cellular.on();
  //delay(10000);
  //Cellular.command("AT+CPWROFF\r\n");
  //delay(2000);
  //FuelGauge().sleep();
  //delay(2000);
  
  
  digitalWrite(ledPin, HIGH);   // Sets the LED on
  delay(150);                   // Waits for a second
  digitalWrite(ledPin, LOW);    // Sets the LED off
  delay(150);                   // Waits for a second
  digitalWrite(ledPin, HIGH);   // Sets the LED on
  delay(150);                   // Waits for a second
  digitalWrite(ledPin, LOW);    // Sets the LED off
  delay(150);                   // Waits for a second
  digitalWrite(ledPin, HIGH);   // Sets the LED on
  delay(150);                   // Waits for a second
  digitalWrite(ledPin, LOW);    // Sets the LED off
  delay(150);                   // Waits for a second
  digitalWrite(ledPin, HIGH);   // Sets the LED on
  delay(150);                   // Waits for a second
  digitalWrite(ledPin, LOW);    // Sets the LED off
  
  System.sleep(SLEEP_MODE_DEEP, 3600);  //Put the Electron into Deep Sleep for 1 Hour. 
  
  }
}    
    
2 Likes

Hi Kenneth,

  • the RGB was doing the normal cycle when the power died: blinking green, blinking cyan, breathing cyan. Normally it goes off after breathing cyan because it goes into deep sleep, now it went off because the power died. There was no charging (and thus no red charging LED) at that time

  • now, when I power it up, everything behaves as it should: the red charging LED only lights up when I actually charge it. The only problem is that it doesn’t connect to the cloud: it moves from blinking cyan to breating white, than quickly to blinking green again. I even tried with a fresh battery: same issue.

My gutfeeling is that something caused one of the players upstream, either the cell-tower, the ISP, or Particle, to have flagged my device as something that should be on their network. Does that sound plausible at all?

Rolf

cc @BDub into the conversation

hi @RWB,

Thanks: I am going to add that to the code of the other devices. For know I am mainly looking for a way to get this device back…

I have a question on the PMIC though. When I set the charging current to 1024, I guess that is the max charging current, right? Is this value retained when you go into deep sleep?

Rolf

ok, new development. I tried to completely reinstall the firmware using the mac OS firmware tool. No errors while doing so. But now my electron only blinks dark blue on startup or reset. It is connected to USB and has a good battery on it. I can get it out of listening mode by holding mode, in which case it goes back to the errors mentioned in the original post.

the cloud shows no activity whatsoever for this particular electron.

Rolf

Did you do a particle keys server (in DFU mode)? It’s a good idea to do that as well whenever you do a keys doctor.

1 Like

Hi @rickkas7,

THAT FIXED IT!

does anyone know how those keys can get out of sync? Is there function you need to call once in a while to maintain them?

Rolf

3 Likes

Yes, that sets the Max charging current to 1 Amp. That value is set every time the Electron wakes up and will remain until the Electron goes back to sleep which then the charging rate will drop back down to 100mA charge rate.

If you are charging while the Electron is on via USB or Solar Power when the Electron goes into deep sleep then the 1A charging rate sticks until all voltage to the charging input is dropped which then causes it to revert back to the 100mA charge rate.

There is an unsolved mystery when running down a battery. Occasionally, portions of the flash can be erased. It’s not as simple as running on low voltage, it’s some combination of factors. In any case, you could lose configuration (including the keys) or you could lose the boot loader. The best plan for now is to avoid running the battery completely down, if possible. It’s related to this:

that is tricky, because my electrons will be floating down the Irryawaddy river in Myanmar next week. In theory they will have enough power to last two days and the added solar panel should charge them to full during sunny days. However: of they get in a low reception area and start calling in more often, they might draw more power and die. They should than wake up when the sun has charged the battery enough. (I have them call in once every 15 minutes, but if that doesn’t work, it tries again the next minute, until it works)

for now, I’ll implement @RWB solution to go into very deep sleep for prolonged periods when battery drops below threshold and get “back to working” when charged.

thanks for all the help: great community!

1 Like

I’ve been testing that specific code for a few weeks now and it’s working reliably when it comes to sleeping and then coming back online once the power goes up above 20% SOC.

If your charging via a solar panel all day then the 1Amp charging current will be enabled all day long because the solar panel will be supplying voltage to the Vin pin which will keep the PMIC from dropping back into the 100mA max charging rate.

I would trust the code to keep the Electron from ever getting back into the state where it lost the Key’s.

Let us know how the project goes Myanmar. What exactly are you doing? It sounds unique and interesting.

1 Like

Hi @RolfHut,

I have tried two different methods to connect a solar panel, solar panel controller (Adafruit LiPoly), and Particle Electron. For unknown reason, I could not use the solar panel and LiPoly because Particle goes crazy to find a cellular signal (green blinking only). Could you please share your setup for connecting solar panel and a controller to Particle? Thanks.