Asset tracker disconnect at night and wake up

Hi Guys,

I’m using the assettracker example to track one of my trucks and see how it works. To safe battery and data, is it possible for example disconnect at 10:00pm and wake up again at 04:00am?

Thank’s in advance

Eduard

I wouldn’t know why not. Have a look at the various sleep modes in the docs :wink:

Hi Moors,

I was reading the documentation about sleep mode but I did not find a way to sleep the device in the interval of hours. I saw the way to put it in X minutes or seconds, but I could not find the way to put in an interval, did you have any idea?

Thank’s

Eduard

Wake time - sleep time = amount of seconds to sleep for :wink:

Thank’s Moors but I’m a newbie and your short answers are very difficult to understand :-s

Is it possible to use a function as sleepuntil()?

thank you for your patience

Eduard

If you want to sleep for a day you’d just use System.sleep(SLEEP_MODE_DEEP, 86400); and even years are only made up of seconds (big number, but still).

You can retrieve the current datetime via Time.local() and with this you will only get the time of the day int tNow = Time.local() % 86400.
If you want to wake at a certain time of the day you’d calculate the second of that time as tWake = hour*3600 + minute*60 + second; and if that is one (or d days) in the future you just add d*86400 to that.

With this done you just calculate the difference between the two times and use that as number of sevonds to sleep.

Easy, or not?

1 Like