Electric Imp Attempts WiFi Connection After Deep Sleep

I am using an imp002 for an application that is very power consumption conscious. Under certain conditions it has to do 1s period sleeps, between which it does some sensor readings. I am using the deepsleep for this, because the static 3mA of the imp.wakeup() sleep are forbidden current values for this application.

The problem is that on every second that it awakes the guy attempts to connect to the WiFi, although the WiFi was disabled before the deep sleep. As it wakes up I see a very sudden peak of current over 60mA, so I am guessing that this is due to WiFi connecting, before the imp code turns the WiFi off again by setting the server.disconnect().

In the Imp’s documentation it is stated that awakenings of the deepsleep won’t cause the WiFi to be brought up again, but I am not finding any error in my algorithm. Do you know anything about this or have any suggestion for any revision of my code?

Thank you truly for your attention!

Below is what Peter wrote in a similar thread:


On wakeup after deep sleep, the wifi isn’t turned on until the first time it’s used, i.e. the first time something needs to be sent to the server – that’s imp.configure(), agent.send(), and most of the server.* calls.

…and configure RETURN_ON_ERROR as the first line of your code if you want to return an error for any calls that would bring wifi up as a side effect.

That way, you will only ever get high current usage when you use server.connect()

Thank you for the feedback!

But although the configuring of the RETURN_ON_ERROR in my code was not the first one it was in the 4th or 5th, just after some pins’ configuring but at a first glimpse moving it up seems to have solved it, as it is not doing the sudden blinks on the imp’s LED that indicated those attempts to connect. I will have to bring the guy back to the lab to have the accurate current readings.

Again, thank you.