# Shutting down photon after 1 minute if configured wifi not found

**URL:** <https://community.particle.io/t/shutting-down-photon-after-1-minute-if-configured-wifi-not-found/55329>\
**Category:** Firmware\
**Tags:** photon\
**Created:** [March 25, 2020, 12:22pm UTC](https://community.particle.io/t/shutting-down-photon-after-1-minute-if-configured-wifi-not-found/55329 "2020-03-25T12:22:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nitinjs123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/nitinjs123/32/28313_2.png) [@nitinjs123](https://community.particle.io/u/nitinjs123)\
**Post date:** [March 25, 2020, 12:22pm UTC](https://community.particle.io/t/shutting-down-photon-after-1-minute-if-configured-wifi-not-found/55329/1 "2020-03-25T12:22:48Z")

</div>

To preserve battery,  
how to shut down photon after 1 minute if configured wifi access point not found?

---

<div class="post-metadata">

**Author:** ![armor](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/armor/32/18398_2.png) [@armor](https://community.particle.io/u/armor)\
**Post date:** [March 25, 2020, 1:17pm UTC](https://community.particle.io/t/shutting-down-photon-after-1-minute-if-configured-wifi-not-found/55329/2 "2020-03-25T13:17:22Z")

</div>

System.sleep()? There are various modes stop and standby, wake using the WKP pin or RTC.

---

<div class="post-metadata">

**Author:** ![nitinjs123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/nitinjs123/32/28313_2.png) [@nitinjs123](https://community.particle.io/u/nitinjs123)\
**Post date:** [March 30, 2020, 5:17am UTC](https://community.particle.io/t/shutting-down-photon-after-1-minute-if-configured-wifi-not-found/55329/3 "2020-03-30T05:17:49Z")

</div>

I wrote following sketch to sleep the photon after 70 seconds if wifi is not found  
however it is not going to sleep mode

```auto
SYSTEM_MODE(SEMI_AUTOMATIC);

int secAlive = 70;
bool isConnectTriggered = false;
bool isConnected = false;
int secPassedSinceTrigger = 0;
int secPrev = Time.local() % 86400;

void triggerConnect(){
    Particle.connect();
    isConnectTriggered = true;
    secPrev = Time.local() % 86400;
    secPassedSinceTrigger = 0;
}

void setup() {
    if(isConnectTriggered==false){
        triggerConnect();
    }
}

void loop() {
    if(isConnectTriggered==true){
        if(isConnected == false){
            int secNow = Time.local() % 86400;
            secPassedSinceTrigger = secNow - secPrev;
        }
        
        isConnected = Particle.connected();
            
        if(isConnected == false){
            if(secPassedSinceTrigger>= secAlive){
                int sec24Hours = 86400;
                System.sleep(SLEEP_MODE_DEEP, sec24Hours);
            }
        }else{
            //connected proceed to work
            Particle.publish("connected", String(isConnected));
            Particle.publish("Seconds Passed", String(secPassedSinceTrigger));
        }
    }
    delay(1000);
}

help appreciated

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/3/2/3291e3c9351789fe8620ae5bcec8d3fec67ff221.png) [@system](https://community.particle.io/u/system)\
**Post date:** [September 28, 2020, 5:17pm UTC](https://community.particle.io/t/shutting-down-photon-after-1-minute-if-configured-wifi-not-found/55329/4 "2020-09-28T17:17:51Z")

</div>

Closed on September 28, 2020, 5:17pm UTC

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