# Another SLEEP\_MODE\_DEEP Question

**URL:** <https://community.particle.io/t/another-sleep-mode-deep-question/47360>\
**Category:** Firmware\
**Tags:** electron\
**Created:** [January 29, 2019, 6:01pm UTC](https://community.particle.io/t/another-sleep-mode-deep-question/47360 "2019-01-29T18:01:03Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![zferrie](https://avatars.discourse-cdn.com/v4/letter/z/ee59a6/32.png) [@zferrie](https://community.particle.io/u/zferrie)\
**Post date:** [January 29, 2019, 6:01pm UTC](https://community.particle.io/t/another-sleep-mode-deep-question/47360/1 "2019-01-29T18:01:03Z")

</div>

Hi All,

I have had some trouble with power consumption with some of my electrons.

All are set outside with the same hardware, solar panels, ect.

However some of them seem to drain the battery very quickly, while others operate with no problem at all. These systems are no more than 50 ft form one another, all oriented in the same direction and angle to charge their battery.

Before I determine the issue to be related to hardware with some of these devices I would like to see if software might be an issue. All are running the same code.

Here is the main loop below.

void loop(void){  
if( (Time.minute() == 59)) {  
digitalWrite(led, HIGH);  
resetvals();  
readSensors()  
sendData();  
digitalWrite(led, LOW);  
System.sleep(SLEEP\_MODE\_DEEP, (55)\*60); //enter sleep mode for 55 min  
}

Is it possible that my (55)\*60 is having some negative effect? Or does that matter?

The electrons seem to go into deep sleep mode (even the ones that are running down the battery). I have not yet used a multimeter on any of them.

Thanks!

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [January 29, 2019, 7:34pm UTC](https://community.particle.io/t/another-sleep-mode-deep-question/47360/2 "2019-01-29T19:34:00Z")

</div>

Could it be that these devices have some difficulty getting a connection after the wake?  
If they should take more than 4 minutes to connect, you may miss the crucial minute `59` and the device may stay connected for another hour before it enters deep sleep again.

---

<div class="post-metadata">

**Author:** ![zferrie](https://avatars.discourse-cdn.com/v4/letter/z/ee59a6/32.png) [@zferrie](https://community.particle.io/u/zferrie)\
**Post date:** [January 29, 2019, 7:57pm UTC](https://community.particle.io/t/another-sleep-mode-deep-question/47360/3 "2019-01-29T19:57:02Z")

</div>

That could be a possibility. How would I go about checking that?

In the past when I have turned them on I see the devices connect within 3 min but I know that doesn’t mean that connection time is always consistent.

Thanks @ScruffR

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [January 29, 2019, 8:00pm UTC](https://community.particle.io/t/another-sleep-mode-deep-question/47360/4 "2019-01-29T20:00:59Z")

</div>

> [@zferrie](#):
>
> How would I go about checking that?

You could add another condition that ensures a timeout for the case you miss that minute  
e.g.

```cpp
  if (Time.minute() == 59 || millis() > 600*1000) 

```

This will ensure that your device won't stay awake for more than 10 minutes (providing your code runs at all 😉)

---

<div class="post-metadata">

**Author:** ![zferrie](https://avatars.discourse-cdn.com/v4/letter/z/ee59a6/32.png) [@zferrie](https://community.particle.io/u/zferrie)\
**Post date:** [January 29, 2019, 8:07pm UTC](https://community.particle.io/t/another-sleep-mode-deep-question/47360/5 "2019-01-29T20:07:07Z")

</div>

Thanks for the advice.

I was looking at Device Vitals and noticed some inconsistencies. Could you explain what the parameters shown below represent?

![image](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/b/d/bd6838cc66ed228d58347f7c442205ee9ea1efe0.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/9/6/962c3cd89992aff8c8a06cfcdc9eb160c8810a80.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/0/5/05aa17dad71015e0d59e75e8937920ff9fe114b5.png)

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [January 29, 2019, 8:16pm UTC](https://community.particle.io/t/another-sleep-mode-deep-question/47360/6 "2019-01-29T20:16:22Z")

</div>

Obviously there is one device that has great difficulty connecting and the uptime suggests that it frequently missed its sleep time and stayed awake.

Try moving that device just a few meters (or swap place with a good one), wiggle the antenna connector a bit, reseat the SIM.  
Try the device detached from any circtuitry in Safe Mode or a dedicated test application.  
You can also flash the cloud debug firmware and have a look at the log - and maybe post it here.

> **[rickkas7/electron-clouddebug](https://github.com/rickkas7/electron-clouddebug)**
>
> Special code for debugging cloud connection issues with the Particle Electron - rickkas7/electron-clouddebug

---

<div class="post-metadata">

**Author:** ![zferrie](https://avatars.discourse-cdn.com/v4/letter/z/ee59a6/32.png) [@zferrie](https://community.particle.io/u/zferrie)\
**Post date:** [January 29, 2019, 8:31pm UTC](https://community.particle.io/t/another-sleep-mode-deep-question/47360/7 "2019-01-29T20:31:19Z")

</div>

I’ll look into that. Thank You.

One odd thing is that I have not missed any data (I looked at the timestamps on the site where I am publishing data) which suggests that the electron is connecting and entering the if( (Time.minute() == 59)) loop which should trigger the sleep mode.

Any thoughts?

Thanks

---

<div class="post-metadata">

**Author:** ![zferrie](https://avatars.discourse-cdn.com/v4/letter/z/ee59a6/32.png) [@zferrie](https://community.particle.io/u/zferrie)\
**Post date:** [January 29, 2019, 8:33pm UTC](https://community.particle.io/t/another-sleep-mode-deep-question/47360/8 "2019-01-29T20:33:55Z")

</div>

I forgot to clarify that the sendData(); subroutine is what sends my data, therefore since my data is sent it suggests that the if( (Time.minute() == 59)) statement is entered

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [January 30, 2019, 6:39am UTC](https://community.particle.io/t/another-sleep-mode-deep-question/47360/9 "2019-01-30T06:39:53Z")

</div>

In that case the long up-time could be an indicator that the device isn’t staying asleep but may wake early due to some signal on the WKP pin.  
To test the theory and counteract this you could use

```cpp
System.sleep(SLEEP_MODE_DEEP, 55*60, SLEEP_DISABLE_WKP_PIN);

```

---

<div class="post-metadata">

**Author:** ![zferrie](https://avatars.discourse-cdn.com/v4/letter/z/ee59a6/32.png) [@zferrie](https://community.particle.io/u/zferrie)\
**Post date:** [January 30, 2019, 4:43pm UTC](https://community.particle.io/t/another-sleep-mode-deep-question/47360/10 "2019-01-30T16:43:39Z")

</div>

Thanks @ScruffR

When I enter the above sleep code I get a

“‘SLEEP\_DISABLE\_WKP\_PIN’ was not declared in this scope”

error message.

Is there something additional that I need to add to my code for the code to work?

I am using the Desktop IDE and my electrons are running 0.7.0 firmware.

Thanks,

Zach

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [January 30, 2019, 4:54pm UTC](https://community.particle.io/t/another-sleep-mode-deep-question/47360/11 "2019-01-30T16:54:54Z")

</div>

That command requires 0.8.0 or later.  
I’d update to 1.0.0

---

<div class="post-metadata">

**Author:** ![zferrie](https://avatars.discourse-cdn.com/v4/letter/z/ee59a6/32.png) [@zferrie](https://community.particle.io/u/zferrie)\
**Post date:** [January 30, 2019, 5:00pm UTC](https://community.particle.io/t/another-sleep-mode-deep-question/47360/12 "2019-01-30T17:00:25Z")

</div>

I see. Is there a workaround for that command in 0.7.0? or a way to update an electrons firmware remotely?

Some of my devices are in NJ (I’m in CO) so I can’t physically access them
