Particle drawing 180mA from battery while in deep sleep mode

#include "Particle.h"

// This behaves the same for SEMI_AUTOMATIC and MANUAL
SYSTEM_MODE(MANUAL);

SYSTEM_THREAD(ENABLED);

void setup() {
}

void loop() {
	// It's necessary to turn on the cellular modem in MANUAL or SEMI_AUTOMATIC mode
	// before going to sleep. This happens because the modem is put to sleep using AT
	// commands, and they don't work when the modem is not on.
	Cellular.on();

	// This workaround appears to be necessary when using SYSTEM_THREAD(ENABLED).
	// The reason is that .on() and .off() are asynchronous in system threaded mode
	// and if the calls don't complete, sleep mode is not properly entered.
	delay(2000);

	// The Cellular.off() requirement is probably a bug. I think it's because when
	// going to sleep in system threaded mode, it's not waiting for the modem to actually
	// go to sleep. As of 0.6.0 it's necessary, otherwise you drop in a weird mode that
	// ends up using 2.8 to 60 mA instead of 132 uA.
	Cellular.off();
	delay(1000);

	// Resulted in 132 uA power consumption, as it should

	System.sleep(SLEEP_MODE_DEEP, 30);

	// This part not reached; sleep mode deep starts over again after setup()
}

Above is a code example taken from this forum. I would like to find out why particle is drawing 180 mA from battery despite being in deep sleep mode. The lights onboard the particle were off when the code runs the deep sleep function.

Are you raising the same (very similar question) as these

That's what's also quoted in these threads
https://github.com/spark/firmware/issues/1176

If your question is in fact that, don't open a new thread for it - it just binds ressources and is frowned upon (to say the least)

The example code above was used as an example to test the current consumption of the battery. The problem which I faced now is that the current draw from battery (as shown in ammeter) is 180mA even though I put the electron into deep sleep mode.

Two guesses: Ones is that the 2000 ms. delay after Cellular.on() for some reason is not long enough for the modem to turn on. Or maybe it's turn turn off delay. Just for testing, try setting the on and off delays to 15000 and see if that solves the problem.

Also, measuring the current can be tricky, depending on your meter. With many meters, using the nA or uA setting doesn’t provide enough current to successfully allow the cellular modem to turn on, so it can’t be turned off. This post discusses this:

Hi rickkas7,

The firmware I’m running on right now is v 0.60. Attached is the current reading when particle is running on deep sleep mode.

I have tried removing the electron from the main circuit board and run deep sleep mode to measure the current. However, the lowest current rating i can get is 160mA. I have also tried it with a new electron controller which gives me a range of 160 - 180mA

/************************************/
SYSTEM_MODE(SEMI_AUTOMATIC);

void setup() {
delay(1000);
#if (PLATFORM_ID == 6) || (PLATFORM_ID == 8)
System.sleep(SLEEP_MODE_DEEP, 60);
#elif (PLATFORM_ID == 10)
System.sleep(SLEEP_MODE_SOFTPOWEROFF, 60);
#endif
}

void loop() {

}

/************************************/

That code won't work properly. It's like example 3. Since you're in SEMI_AUTOMATIC mode (also happens for MANUAL), the cellular modem is not turned on when the Electron resets. Thus is can't be put to sleep properly.

If you modify it so it's like example 4 it probably will go to sleep properly, though the warning about burden voltage on your meter still applies.

2 Likes

@rickkas7 is correct, when sleeping in semi_automatic mode you must either manually call Cellular.on(); or have already called particle.connect(); which calls Cellular.on(); for you.

Hi rickkas7,

I have tried the example 4 that you have provided. The current still stands at 180mA as shown in the photo attached . Can i ask if what is normal procedure in achieving proper deep sleep mode? I’m actually quite confused about the procedure to put electron in deep sleep mode. Any help will be much appreciated so that i can go through the process in my firmware to identify the bug. Thanks

Hi @NST1992

How are you isolating the power to all those other boards in there? The look like those ultrasonic distance measuring modules that draw from 5-30mA each and I see four of them. In one of your photos above, the LEDs are even turned on for several of those boards as well.

What happens if you take the Electron completely out of your board and just measure the current with just the Electron connected to power via VIN and GND?

Can you first test using System.sleep(SLEEP_MODE_DEEP, 60); in automatic mode to confirm the electron enters deep sleep and enters low power mode? Does the d7 led and the rgb shut off?

Hi @bko

Yes. The LEDs are turned on when electron device is connected to the board. I have removed the electron device from the main circuit board and tested it with deep sleep function. The current still stays at 160 - 180mA even if i removed the electron form the main circuit board or the voltage regulator required top step up to 5V for these sensors. Trying to figure how i can on and off the electron should the deep sleep function stop working

Hi @calebatch

The electron was unable to connect to the cloud as i am using third party sim card, so the deep sleep function could not be achieved. However, the RGB and D7 led were able to turn off when i used deep sleep in manual mode. Does deep sleep supposed to work this way?

Yes, the rgb and d7 led should turn off in deep sleep. You might connect to your pc and read from serial. Another clue that the electron is in deep sleep is it will disconnect from usb when it enters deep sleep. If that happens as well then I would try another measuring device.

The electron device closed the serial port automatically as well, together with the RGB and D7 LEDs. Is Cellular.off function required? Cos i noticed the electron device skipped the Cellular.off() function and went straight to deep sleep mode.

@NST1992 If you want to see the under 1mA current consumption during deep sleep them mimic this code and supply 3.7v to the vBat pin and Gnd.

#include "Particle.h"

// This behaves the same for SEMI_AUTOMATIC and MANUAL
SYSTEM_MODE(MANUAL);

SYSTEM_THREAD(ENABLED);

int ledPin = D7;         // LED connected to D1

void setup() {
     pinMode(ledPin, OUTPUT);          // Sets pin as output
}

void loop() {
 //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, 100);  //Put the Electron into Deep Sleep for 1 Hour. 
} 

If you want to see the 160mA reading then apply power to the Li+ pin and Gnd.

If you apply 5v to Vin and wait a few seconds after the LED’s signal that the Electron has went into deep sleep then you should see current bounce around 0.002 - 0.0014 Amps @ 5v if you have no battery connected to the Electron. The RED charging LED is flashing like crazy since there is no battery connected. If there was a battery connected then the PMIC would be trying to pull 100-500mA to charge the battery during deep sleep.

1 Like

Hi @RWB

I have applied the code and flashed to the electron controller. The output remains at 160mA. I have attached a gif for your reference.

@NST1992 Here is what I get when powering the Electron from pins Li+ & Gnd with 3.7v.

I have the sleep code like this: System.sleep(SLEEP_MODE_DEEP, 30);

If your sleeping less than 30 then you may not be giving it enough time to go into sleep mode so try 30.

Here is a video of it.

If your unit can not do this then you may have damaged it in the past somehow. Try a new Electron.

Hi all,

Thanks for the contribution. I think i may have found out the problem. The 3v3 pin cannot be shut down in deep sleep mode and the battery i have used was 7.4V on the battery pin instead of putting it in the Vin pin. Feel free to provide any feedback if i am wrong :smiley: