# Is there any method to wake up my device at 9:00 am everyday, even though there is a multiple interruptions

Hello Everyone,

I trying to wake up my Electron device everyday by sharp 9:00 am using System.sleep(WKP,RISING, 246060,SLEEP_NETWORK_STANDBY ). Also i am using PIR sensor. If sensor get interrupted then the sleeping cycle starts from the time the device connected tot the cloud. I would like to wake up my device at 9:00 am everyday, even though there is a multiple interruptions.

Calculate the remaining time until 9am and use that as the input for sleep?

2 Likes

@Moors7, I have programmed the same way. but that doesnâ€™t help. During the sleep time, If the PIR sensor gets interrupted, the sleeping cycle restarted again. i am unable to get the wakeup by 9:00am, due to the PIR sensor interruption the wake up time gets varying.

That seems like a fixed time to meâ€¦
Calculate the time difference between the current time, and the next 9am, and use that value in the sleep function. That way, it doesnâ€™t matter how many times it wakes up since it will always calculate how long it needs to sleep for again.

3 Likes

@Moors7 I tried the same, but each day the wake up time changes due to the interruption from PIR sensor. i am looking for a way, that the device shouldnâ€™t care about the multiple interrupts and it should wake up everyday at 9:00 am sharp.

Thank you

So, again, have the Photon device calculate the difference between the current time and 9am every time it wakes up and use that value instead of a hardcoded one. It can then wake up 288992339048 times inbetween, and just recalculate for how long it need to sleep, every time it wakes up.

Letâ€™s say itâ€™s 3:54am, how long until 9am?
or 5:27am, how long until 9am?
or 9:45pm, how long until 9am?

Instead of you calculating that manually, have the Photon device do that, and use the answer in your sleep function.

1 Like

@Moors7 Is the same / similar function available in electron?

It hasnâ€™t got anything to do with the device, itâ€™s just a bit of code youâ€™ll have to program. So yes, either device can do that.

Ok thank you, @Moors7. I will implement the time difference in the sleep function