Deepsleepfor... help please

Is the code sample in the doc for imp.deepsleepfor(x) the method I should be using if I want to take a point every minute without waking up the WiFi radio at all but then after a certain nv table defined amount of minutes push an averaged point to our server?

I have copy and pasted the code verbatim from the link above and then changed a few things to look like this:

t <- time();

function hourly() {
server.log(“wifi is on right now”); = 0;

function log() {
local min = (t/60) % 60;;
if (min == 59) {
server.log(“wifi should be off here”);
imp.onidle(function() { imp.deepsleepfor(60 - (time() % 60)); });

if (!(“nv” in getroottable())) {
nv <- { data = 0 };



When i run this code the I am seeing this every minute:

2014-05-07 19:00:14 UTC-4: [Status] Device booting; xx.xx% program storage used
2014-05-07 19:00:17 UTC-4: [Device] wifi should be off here
2014-05-07 19:00:17 UTC-4: [Status] Device disconnected; x bytes sent, x received, x total

This leads me to believe that the wifi is turning on every minute to put another point into the nv table. I NEVER want the wifi to turn on for a minute log only for the specified amount of minutes log.

any help would be greatly appreciated.

Your call to server.log() is bringing up the wifi connection in order to perform the log. Remove the log line if you don’t want it to do this, or use a different connection policy here (RETURN_ON_ERROR).

That helped a lot! Thank you. So i basically got from your answer that most any server call will wake up the radio which I was also doing at the start of our actual program. I have moved everything around so any server functions are only called when necessary and everything works well now!

Thank you for your help again.

I am finding that using the code from the same deepsleepfor(x) sample unchanged I get the following error:

2014-05-30 06:37:59 UTC+1 [Device] ERROR: sleeping in main program not recommended, see imp.onidle

ERROR sounds bad, as if it will not actually run. Can anybody suggest why I am getting this error, when clearly ParasitX did not?

Using the code above? That shouldn’t cause the error, as the deepsleepfor() is within an onidle() handler.

Yes, using the code in the link, the official example for deelsleepfor(x). However I cannot repeat the error, so thanks for the reply Hugo but let’s leave it for the Journal of Irreproducible Results.