Is there a way to prevent the Imp from flashing on wake up?

I use the following device code that wakes the Imp every 5 minutes:

imp.onidle( function() {
server.sleepfor(1 + WAKEINTERVAL_MIN60 - (time() % (WAKEINTERVAL_MIN60)));
});

When it wakes the firmware is installed and run and the Imp status LED flashes until the code completes and puts it back to sleep.

Is there a way to prevent the status LED from doing it’s thing?

Replace server.sleepfor with imp.deepsleepfor.

Peter

Thanks Peter - that seems to work to a degree. The green light no longer flashes but the red/orange wi-fi connecting light does still flash. Can that be eliminated also?

On a cold boot (power-on), the imp will always try and connect to the servers. On a warm boot (timer or pin1 wakeup), it will only connect if the Squirrel code tells it to, or if there is am uncaught Squirrel runtime error.

By default it will connect on any server.* call, including server.log, plus agent.send.

Have a look at http://electricimp.com/docs/resources/wifistatediagram/ – what you’re asking, in effect, is how to get from “Warm restart” to “Active offline” and then back to “Asleep” without going via either “Active connecting” or “Suspended connecting”. And the answer is, don’t make any Squirrel calls that contact the server.

Peter

I contact the server to deliver sensor data when the Imp wakes up. Is it possible to do that without the LED flashing?

Yes. Here’s a model for an internet connected button of mine. Whenever the button is pressed, it wakes up, sends a message, then goes back to sleep. The indicator LED does not blink when it connects.

`imp.enableblinkup(false);
hardware.pin1.configure(DIGITAL_IN_WAKEUP);

if(hardware.wakereason() == WAKEREASON_PIN1) {
agent.send(“buttonPress”, time());
}

//imp.onidle(function() { imp.deepsleepfor(2419198); });
imp.onidle(function() { server.sleepfor(2419198); });`

Note - if it is waking from a cold boot (i.e. full power off) - the LED will still blink.

I just realized that my internet-connected sensor is blinking every time it wakes to write data. Even with imp.enableblinkup(false) right after wake from WAKEREASON_TIMER, I’m getting a brief orange flash before the LED goes dark and the imp goes back to sleep. Is there anything I can do to keep it completely dark while capturing a sensor value and sending it to the agent?

@epall That setting is used on the next state change (https://electricimp.com/docs/api/imp/enableblinkup/)

So for something like this…
if (hardware.wakereason() == WAKEREASON_TIMER) { imp.enableblinkup(false); }
…it won’t work the first time the imp wakes on timer, but it should be remembered and work for subsequent wakes. Are you setting it back to true anywhere else in the code?

Make sure that the enableblinkup(false) comes before the first call that brings up the wifi – before any server.log or server.connect.

The enableblinkup() takes effect immediately, except that blinkup is always enabled for the first 60s after a cold boot (power-on).

Is the flash you’re seeing really brief – basically momentary? It could be the polarity detection, I suppose…

Peter

Is this on an imp001 or imp002?

Peter