Sleepfor() or wakeup()?

Is there an interval at which point sleepfor() becomes less efficient than wakeup() in terms of battery life? The documentation gives an example of 15 minutes for sleepfor(). Does it negatively impact battery life if that interval is one minute? Would I be better off using wakeup() at that point, and just leaving the wireless on? I have a test running right now, but if my numbers are correct, this test could last months (at least that’s my hope). Any indication or tips prior to that would be great (smile).

Thanks,
Kevin

I’d need to put it in a spreadsheet to work it out, but gut feel is that if you use imp.setpowersave(true) then you may be better off staying awake than doing a 1 minute sleep (this also depends slightly on your wifi network join time). 2 minutes+ then sleepfor() is likely better.

Powersave mode will be getting at least 2x as efficient in the future, so the goalposts will move on this :slight_smile:

Also, the next big release allows you to wake without waking wifi, which means you can collect data points (eg) every minute but only transmit them every hour, or every day. When you’re doing this, you definitely want sleep as you’ll get great battery life!

Small update…

With a 2,000 mAh battery, and an HIH6130 (temp/humidity) sensor, I got just shy of two weeks battery on waking once every minute to report data, and then going back to sleep. I’ll update the code to run in power save mode and run the test again.

Unfortunately, for my application, I’d really like to have semi-real-time data, so right now, reporting every minute is necessary. I may increase that to five minutes at a later date, in which case I’ll go use sleep. I’ll report back with the results using power save mode in the same configuration.

Thanks,
Kevin

@krhoyt: PM me your mac address and I’ll queue a test release for you which shortens the wakeup time significantly.

Hey Hugo,

After talking the idea around a little, most of my potential customers seemed happy with data sampling at every five minutes (some would even take an hour rate). I adjusted the Imp code for every five minutes (with sleep), and using the same 2,000 mAh battery, I’ve had a test unit running successfully for over two months now. While shooting for six months would be amazing, the two month range is already impressive. Getting closer to a formal product now. Thanks!

The break even point for me is currently 30 seconds. More than 30, use sleepfor(), Less use wakeup(). When we have the ability to wake without Wifi, the break even point will be mere seconds. Assuming we can buffer a few data points without sending them each time. At least until 1 minutes. Looking forward to that!

@krhoyt yeah, with release 23 you should be able to do every 5 minutes with sleep for over 6 months (depending slightly on what you’re doing when you wake obviously!).

You can also do the buffering which sbright33 talks about. Very neat.

You mean sending data every 5 mins because it takes less time to connect?
When is 23 coming?

krhoyt mentioned 5 minutes so I did some quick calculations. Yes, release 23 takes about 2 seconds less to connect than release 17.

Coming this week!