E-Series, Problems with Deep Sleep

electron
Tags: #<Tag:0x00007fe21f29e6c8>

#1

Particle Device OS:
I am running on Device OS 1.4.4 on several different E-Series modules encountering the same problem.

Problem:
I am trying to utilized the deep sleep functionality to turn off the cellular modem after 6 minutes of not being able to connect using Particle.connect(). After the device goes into deep sleep, the device will not come back online after the 30 seconds. In my tests, I have the antenna disconnected from the module to ensure that it will not connect. I have also noticed that when not connected, the Time class will not increment (Time.now() is always a constant value). This may be a related issue with the RTC but am not sure. I got around this by using the millis() function to determine the current minute when time is not valid. This is shown below in the code.

Couple things I have check from other forum posts are shared below:

  • VBAT is connected directly to the 3.3V pin on the module
  • VIN is always connected to 5V rail
  • WKP is floating and never gets pulled high

High Level Code:
Code will go into deep sleep after a minute. Device never comes back online.

SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);
STARTUP(System.enableFeature(FEATURE_RETAINED_MEMORY));

retained int num_resets = 0;
int current_minute;
int connect_minute;

void setup() {

    Serial.being(9600);

    pinMode(WKP, OUTPUT);
    digitalWrite(WKP, LOW);

    Particle.connect();

    if (Time.isValid()) {
        connectMinute = Time.minute();
    } else {
        connectMinute = (millis() / 1000) / 60;
    }

}

void loop() {

    Serial.println(num_resets);

    if (Time.isValid()) {
        current_minute = Time.minute();
    } else {
        current_minute = (millis() / 1000) / 60;
    }

    if (!Particle.connected() && current_minute != connectMinute){
        resetDevice();
    }

    delay(1000);

}

void resetDevice() {
    Particle.disconnect();      
    unsigned long startTime = millis();
	while(Particle.connected() && millis() - startTime < 15000) {
		delay(100);
	}
    Cellular.off();
    delay(1000);
    System.sleep(SLEEP_MODE_SOFTPOWEROFF, 30, SLEEP_DISABLE_WKP_PIN);
}

I am not sure if this is a software related or RTC related issue.


#2

Update!

I have noticed that as long that Time.isValid() returns true, the deep sleep functionality does work as intended, but if return false, the device will remain in deep sleep unit physically reset. This can be easily shown by printing out the current device time, Time.now(), in the loop function.

In the resetDevice function, I now have:

void resetDevice() {
    Particle.disconnect();      
    unsigned long startTime = millis();
	while(Particle.connected() && millis() - startTime < 15000) {
		delay(100);
	}
    Cellular.off();
    delay(1000);
    if (Time.isValid()) {
        System.sleep(SLEEP_MODE_SOFTPOWEROFF, 30, SLEEP_DISABLE_WKP_PIN);
    } else {
        System.reset();
    }
}

Why does the RTC not increment when device is not connected? Should the intended functionality be time increment from epoch?