# How to put a Photon 2 to sleep?

**URL:** <https://community.particle.io/t/how-to-put-a-photon-2-to-sleep/68906>\
**Category:** Tutorials\
**Tags:** photon2\
**Created:** [December 31, 2024, 1:35pm UTC](https://community.particle.io/t/how-to-put-a-photon-2-to-sleep/68906 "2024-12-31T13:35:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThomasV](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/thomasv/32/29539_2.png) [@ThomasV](https://community.particle.io/u/ThomasV)\
**Post date:** [December 31, 2024, 1:35pm UTC](https://community.particle.io/t/how-to-put-a-photon-2-to-sleep/68906/1 "2024-12-31T13:35:12Z")

</div>

So I have a Photon 2 which is once a minute measuring air quality related data and publishing it to the Particle cloud. The sensor is a [Grove SENS5](https://www.seeedstudio.com/Grove-All-in-one-Environmental-Sensor-SEN55-p-5373.html) all-in-one environmental sensor using I2C, the Photon 2 is attached to a [Grove Shield FeatherWing](https://www.adafruit.com/product/4309).

The program is also writing data to the serial terminal, as well as to an OLED-display, but the display is physically disconnected, and as I'm normally powering the device with a power bank, a serial terminal is not in use

As I'm using a power bank, I'd like to put the device to sleep, but it seems it's not working as a USB charger doctor measures 120-130 mA all the time. It is also blinking the normal slow-breath cyan. I've put below in the setup()-function, `interval2` is 60000.

I suppose I'm misunderstanding something with how the sleep is working, so would need some guidance.

I'll probably later increase the interval from 1 to 2 or more minutes.

```auto
SystemSleepConfiguration config;
config.mode(SystemSleepMode::STOP)
    .network(NETWORK_INTERFACE_CELLULAR)
    .flag(SystemSleepFlag::WAIT_CLOUD)
    .duration(interval2);
System.sleep(config);

```

---

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [December 31, 2024, 3:06pm UTC](https://community.particle.io/t/how-to-put-a-photon-2-to-sleep/68906/2 "2024-12-31T15:06:32Z")

</div>

`.network(NETWORK_INTERFACE_CELLULAR)` is not a valid option for the Photon 2, a Wi-Fi device. The sleep is probably not occurring because of invalid options. Try it with that removed.

---

<div class="post-metadata">

**Author:** ![ThomasV](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/thomasv/32/29539_2.png) [@ThomasV](https://community.particle.io/u/ThomasV)\
**Post date:** [December 31, 2024, 5:04pm UTC](https://community.particle.io/t/how-to-put-a-photon-2-to-sleep/68906/3 "2024-12-31T17:04:32Z")

</div>

Thx!  
It helped in that the device right away goes to sleep for a minute, then wakes up, but then never sleeps again.  
I did not beforehand consider that the sensor also might (?) lose power during the sleep, which might reset at the VocIndex to its starting point of 100. So I might skip the sleep in this project, but would of course be nice to know how to get a continuous sleep 😀

---

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [December 31, 2024, 8:22pm UTC](https://community.particle.io/t/how-to-put-a-photon-2-to-sleep/68906/4 "2024-12-31T20:22:25Z")

</div>

Where is your sleep call? When you use STOP mode sleep, execution continues after wake at the line after System.sleep. Anything that's in setup won't be run again on wake.

---

<div class="post-metadata">

**Author:** ![ThomasV](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/thomasv/32/29539_2.png) [@ThomasV](https://community.particle.io/u/ThomasV)\
**Post date:** [January 1, 2025, 1:31pm UTC](https://community.particle.io/t/how-to-put-a-photon-2-to-sleep/68906/5 "2025-01-01T13:31:03Z")

</div>

It was in setup, but when I moved to loop, it started to work...  
But, how to flash new firmware to it when it's just awake for a few seconds?  
I was finally able to do a local flash, and the program runs, but the device don't have cloud connection anymore, it's fast blinking blue.

I did restore it [this way](https://docs.particle.io/tools/device-restore/device-restore-usb/), but still no cloud connection.  
I'll now try to reestablish cloud connection somehow.

Edit: Ok, reconfigured the WiFi, not sure what happened, but now it works again. I'll refrain from using sleep until I understand it better, anyhow in this case I'll probably won't be able to use it due to the sensor characteristics.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/6/4/64635adccc35238caa19e9b553ec3e98b163d026.png) [@system](https://community.particle.io/u/system)\
**Post date:** [January 31, 2025, 11:31pm UTC](https://community.particle.io/t/how-to-put-a-photon-2-to-sleep/68906/6 "2025-01-31T23:31:40Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
