I’m working on a project that needs to go to sleep when not in use, to conserve battery, and wake up quickly to take measurements, but the electron is taking too long to wake up.
if (quietCount >= QUIETAMOUNT) //sleep count
{
#ifdef DEBUG
Serial.println("Going to sleep!");
Serial.print(Time.hour()); Serial.print(":");
Serial.print(Time.minute()); Serial.print(":");
Serial.print(Time.second()); Serial.println();
delay(10);
#endif
quietCount = 0; //already going to sleep
//how long until the device needs to wake up at the next measurement period?
accel_standby();
read_register(ACCELADDRESS, 0x16); //reset interrupt pin
accel_active();
int secToNextMin = 60 - Time.second();
int minToNextHour = 59 - Time.minute();
int currentHour = Time.hour();
if(currentHour % 2 == 0) //odd or even hour
seconds = secToNextMin + ((minToNextHour)*60) + 3600;
else
seconds = secToNextMin + ((minToNextHour)*60);
delay(10);
System.sleep(WKP, FALLING, seconds); //sleep until time is up, or pin WKP goes high
delay(1000);
#ifdef DEBUG
Serial.println("Pressing snooze");
#endif
accel_standby();
read_register(ACCELADDRESS, 0x16); //reset interrupt pin
accel_active();
#ifdef DEBUG
Serial.println("Waking up!"); Serial.println();
#endif
}
This is the sleep portion of the code (the entire code is very long)
I’m counting the up and down movements of an accelerometer, and the device goes to sleep after a couple of seconds without movement and wakes up when it moves again.
When the device wakes up the embedded led flashes green for about 50 seconds before breathing green and moving on with the program. I need this cut down to no longer than 1 or 2 seconds, preferably less. If I had to guess, the electron is getting caught up in trying to connect to cellular. I’m using SYSTEM_MODE(SEMI_AUTOMATIC); and keeping cellular disconnected because I don’t need it and I’m working in an area with pretty bad reception.
Is there a way to minimize it looking for a signal it doesn’t need, can’t have, and I don’t want? If that’s not the problem, does anyone have any idea how to cut down the time to fully wake up? Thanks in advance