Impee goes offline after about 15 mins

My impee seem to go off line after 15 to 20 mins of inactivity with message:

“Tuesday, December 18, 2012 14:56:01: Power state: online=>offline”, can anyone advice plse

I have the same issue when using the imp with batteries. Any comments would be helpful.

We’re looking into it. Thanks for your patience.

Does your imp send any output, or just wait for input? Generally the power state message means that the server has sent the imp a ping to check connectivity, and the imp has not replied.

A couple of common things can cause this:

  • Infinite loops in your code. You should not be using while(1); if you want to run stuff repeatedly, you should be using imp.wakeup(). The TCP stack runs when the user thread is not running, in order to provide more predictable execution of user code.

  • NAT timeouts. Right now, we only ping from the server end to keep the link up. On some routers, this isn’t enough. Client side pings are coming, but until they arrive you can do something like this to ensure that traffic flows from the client side every minute:

function watchdog() { imp.wakeup(60,watchdog); server.log("watchdog"); } watchdog();

Thanks for the response Hugo, I am using the imp for remote switch in a marine environment. The router is a 3g net gear router using a 3g dongle. I have alreadly tried the watchdog function, it does solve the problem, however as it seems to take about 2 or 3 seconds for imp to complete wakeup function, if you happens to send a command to the imp during this time period, the command is missed?

Which wakeup function do you mean? A hardware wake from a server.sleepfor/sleepuntil, or imp.wakeup()?

imp.wakeup()s execute as soon as the time is reached if no other code is being run. No commands should be lost.

I am new to imp; I was using imp.wake(), and i was unaware that the function is immediate, it just appears that sometimes the command is missed when i added the stopwatch routine. Perhaps it was due just to latency. Auto client ping at regular interval built into the firmware sounds good idea. I can see that there is a possible tradeoff for power consumption, what is the typical current draw for the imp (at 5v) when it is active vs sleep state? Great product with heaps of potential.

Sending data periodically is a miniscule amount of power - the packets are very short (at wifi bitrates!) and so they practically vanish into the average when they’re every minute or so.

Typical draw at 3.3v is ~90mA right now when on wifi and not in powersave mode, and ~5-7mA when in powersave mode… ie, imp.setpowersave(true). As the DCDC on April is 90%+ efficient, that’s equivalent to ~66mA/~5mA at 5v.

Hi Hugo,
Compliments of the season & hope u had a good holiday. Played with my Imp today and with your watchdog routine in my program, I got:
Thursday, January 17, 2013 11:14:30: ERROR: bad parameter types for method
Thursday, January 17, 2013 11:14:30: ERROR: at watchdog:65
Thursday, January 17, 2013 11:14:30: ERROR: from main:81

This was working before, has it got something to do with the new firmware?
Thks,
Ken

Sounds like there’s a typo at line 65, possibly I quoted the code segment wrong :slight_smile:

Can you paste that bit? Hard to tell the exact error without seeing the code. I suspect it’s within the watchdog() function.

Hi Hugo,
Thks for prompt response:
Line 81 is the call to watchdog: watchdog()

This is the part of the code (watchdog):

function watchdog() {
imp.wakeup(5*60, “watchdog”);
server.log(“watchdog”);
}

Curious thing was it was working before.

The problem is at:

imp.wakeup(5*60, "watchdog");

…because imp.wakeup() doesn’t take a string – it takes the actual function:

imp.wakeup(5*60, watchdog);

In earlier releases, this error was only caught when the wake-up actually happens. In modern releases, it’s caught earlier, at the point that imp.wakeup is called.

Peter

Thanks Peter,
Very impressed, you guys are good and quick on the mark, seems to work now…I know its been discussed before, just to clarify, does new release of firmware get pushed to all the imps when they power down & up. Can we assume that we will always have the latest version so long we power up & down the imp once in a while?

What currently happens is, when a new release is ready we “push” it to all imps. Any imps that are connected to the server at that moment, get it immediately; other imps get it the next time they connect to the server, which is usually at power-on.

In the future, manufacturers of imp-based devices will be able to push updates themselves at a time that’s (a) convenient for them and (b) after they’ve made sure the update works with their application. (But we do try to make sure that releases are always backwards-compatible, so the update really ought to work with their applications.)

Peter

Still going offline randomly!

Hi,
From the forum recently, I know there are few issues of imp going offline & u guys are working on it. Maybe this might give u some more clues?

The code is just a simple web controll servo & I have added the watchdog and decrease it to 3 mins, and I am still having the imp going off line randomly, I tried to reload the code on planner but nothing, I have to repower the imp to start it working again. I was just showing off the imp to my coleague and it went off line!

Could it be my wireless router modem, its a 3g netgear mbr624gu, but I do not have any issues with arduino ethernet or all my PC on the router. I just wat it to work reliabily.

The watchdog code:
function watchdog()
{
imp.wakeup(3*60, watchdog);
server.log(“watchdog”);
}

The latest log of last time it went offline for no reason (just a few minutes ago:
Tuesday, January 22, 2013 12:22:37: Device configured to be "kkwebservo-1"
Tuesday, January 22, 2013 12:22:37: watchdog
Tuesday, January 22, 2013 12:23:41: Received 1 ON command.
Tuesday, January 22, 2013 12:23:43: servo cycled.
Tuesday, January 22, 2013 12:24:40: Received 1 ON command.
Tuesday, January 22, 2013 12:24:42: servo cycled.
Tuesday, January 22, 2013 12:25:14: Received 1 ON command.
Tuesday, January 22, 2013 12:25:16: servo cycled.
Tuesday, January 22, 2013 12:25:37: watchdog
Tuesday, January 22, 2013 12:26:28: Received 1 ON command.
Tuesday, January 22, 2013 12:26:29: servo cycled.
Tuesday, January 22, 2013 12:26:50: Received 1 ON command.
Tuesday, January 22, 2013 12:26:51: servo cycled.
Tuesday, January 22, 2013 12:28:39: watchdog
Tuesday, January 22, 2013 12:29:25: Received 1 ON command.
Tuesday, January 22, 2013 12:29:27: servo cycled.
Tuesday, January 22, 2013 12:31:38: watchdog
Tuesday, January 22, 2013 12:33:52: Received 1 ON command.
Tuesday, January 22, 2013 12:33:54: servo cycled.
Tuesday, January 22, 2013 12:34:39: watchdog
Tuesday, January 22, 2013 12:35:55: Received 1 ON command.
Tuesday, January 22, 2013 12:35:57: servo cycled.
Tuesday, January 22, 2013 12:37:39: watchdog
Tuesday, January 22, 2013 12:40:39: watchdog
Tuesday, January 22, 2013 12:41:00: Power state: online=>offline

Any suggestions?
Thanks,
Ken

Similar to the other cases I’ve looked at recently, the issue is that the server has sent a message to your imp, but the imp has not responded. The server hence marks the imp as offline. What should have happened in this case is that the watchdog would have kicked in ~3 minutes later and forced the imp to reconnect, but it seems that has not happened for you.

Is there anything in the router log at that time? The manual shows that the D-link has pretty verbose logs which might help identify this issue - it seems like it’s closing the NAT path even though there’s traffic on the link. There’s obviously still a bug on our end with reconnect, though.