@BDub I’m having issues with the Electron not reconnecting or reaching Cellular.ready() after the Electron has been in deep sleep mode for a few days of bad weather.
So the SOC stays below 20% for 2+ Days while the Electron wakes up every hour to check if the SOC has risen above 20% and it can do this for 20 days before depleting the battery.
Today the sun is out and the Electron is solar charged up to 38% and tries to run the publish code but it can not get past the Cellular.connect(); > Cellular.ready(); so it never starts sending data again unless I manually hit the reset button.
I unplugged the battery and then plugged it back in and I did not get the dark blue flash that indicates a bad or missing SIM card. After hitting reset a couple times the Electron connects and sends data again.
So I’m wondering if there is code I can call to reset the cellular modem without causing large data handshake penalties? My code is below if you want to take a look.
SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);
// This #include statement was automatically added by the Particle IDE.
#include "Ubidots/Ubidots.h"
#define TOKEN "1234567890" // Put here your Ubidots TOKEN
#define DATA_SOURCE_NAME "ElectronSleepNew"
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() {
//Serial.begin(115200);
pinMode(button, INPUT_PULLDOWN); // sets pin as input
pinMode(ledPin, OUTPUT); // sets pin as output
ubidots.setDatasourceName(DATA_SOURCE_NAME);
PMIC pmic;
//set charging current to 1024mA (512 + 512 offset)
pmic.setChargeCurrent(0,0,1,0,0,0);
pmic.setInputVoltageLimit(4840);
}
void loop() {
FuelGauge fuel;
if(fuel.getSoC() > 20)
{
float value1 = fuel.getVCell();
float value2 = fuel.getSoC();
ubidots.add("Volts", value1); // Change for your variable name
ubidots.add("SOC", value2);
Cellular.connect();
if (!waitFor(Cellular.ready, 60000)) {
System.sleep(D0, RISING,sleepInterval * 2, SLEEP_NETWORK_STANDBY);
}
ubidots.sendAll();
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);
}
else
{
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);
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);
}
}