server.sleepfor looks to be an effective way of saving power between periodic network uplinks, permitting an imp to be run from batteries for an extended period.
However, what if one wanted to configure an imp to do something useful - such as polling a pin - on a faster duty cycle between uplinks? Is there a way to sleep the WiFi interface without a cold boot?
Not currently. From another thread
As I’ve said in other threads, the current main power consumer is wifi. There’s currently no way to enable low power mode for wifi in your code, but this will be coming. Until then, you’re going to be around 80-90mA with no way (apart from sleepfor) to reduce this.
Eagerly awaiting my imp import to UK and the low power WiFi mode.
I wonder whether there is a call for an active mode with the WiFi powered down?
Is the WiFi sign-on blocking? Is there an opportunity to do a sleepfor, wake and execute a small amount of code and then go straight back to sleep before the WiFi is fully up?
I think in the current code that the imp has to do a small exchange with the server before proceeding. Its been talked about in other threads and I believe at some point we will see a way to turn wifi on and off and to have an imp with intermittent internet connectivity still function.
Using imp standalone
Request for wifi disable/enable
So the next big release implements wifi power save mode; you should see about 5mA whilst connected to wifi (depending on what your code is doing obviously). This is much better than where we are right now, but still too high power for most battery powered applications.
What ecolby is asking appears to be what we call a “shallow wake”, where the imp comes up and runs code, but doesn’t even try to connect to wifi until the code asks for it. This is next on the list after the vimp (server-side imp) stuff. This allows you to eg wake and check a value to see if it’s gone out of an acceptable range, transmitting only when necessary. These wakes are quick and low power.
When the vimps are in you can use the server-side code to cache values to be pushed to an imp when it connects, allowing you to send new data via the http API even when the imp is sleeping.