Understanding Interrupt

Why is there no documentation about Electric Imp’s interrupt?

I’m trying to attach interrupt to a pin on the imp so that it wakes up the device when there is a 3.3v or 0v on the pin( depends). There is no documentation anywhere except examples used with accelerometer that isn’t helping me.

Please i need help

Can interrupt wake the device from deep sleep?
how can i configure this?

All imps have at least one Wake pin for this task: check out the pin mux for the imp you’re using to find out which one — it’s usually pin W.

imp imp001 imp002 imp003 imp004m imp005 imp006 impC001
Wake Pin(s) 1 1 W W N/A V, W* W

The pin is not enabled for waking by default – not everyone needs it. You enable it using the hardware.pin.configure() imp API call to set it up as a digital input:

hardware.pinW.configure(DIGITAL_IN_WAKEUP, onPinStateChangeCallback);

onPinStateChangeCallback is reference to a function that may be triggered when the wake pin is asserted. Waking the imp from deep sleep restarts Squirrel afresh, so any callback registered with the method will not be called. However, if the pin is triggered while the imp is awake, the callback will be called.

You should note that this is not a true interrupt: on the event, the callback execution is queued and will be run when any current code finishes executing (and any previously queued callbacks complete).

In response to this question, I’ve uploaded an imp API Cookbook recipe to cover the Wake pin: Wake An imp From Deep Sleep

Ok thanks for this

So there is no way to have interrupts on other pins wake the imp device from sleep?
For example, i have a device on pin 3 and 5. I want the imp to go to deep sleep when the imp is idle for 10min. But when there is a change in state of either pin 3 or 5, I want the device to wake up from deep sleep

It sounds like you’re using imp001 (by the pin numbers); as @smittytone says the imp001 has only one wake pin, which is pin1, and it this pin needs to be normally low (high state will cause a wake from deep sleep).

Deep sleep is the lowest power state - taking ~6uA on imp001… but if you just want to reduce power significantly, you can instead just idle and disconnect from wifi. This will get you down to maybe 3mA

Newer imps have better idle modes, which mean that you can stay awake (all state change pins can trigger your code): eg imp003 is ~0.5mA and imp004/imp006 are more like 20-50uA in that mode.