Currently i am investigating ways to wakeup an Arduino out of deep sleep mode with an IRQ Event. If you think of low power standalone measurement applications, this can be very interesting, because the board can sleep with very low power-consumption (less than 10 milli-amps) until something happens.
It works that way (see code example below): After starting the Arduino you call the function sleepNow() which does two things. Define an interrupt for waking up and attach him and then put the device to sleep. For waking up different patterns can be defined, “LOW”, “RISING” and “FALLING”. If the according event is being observed on the wakeup pin the device will wakeup, proceed with the wakeup function (in this case wakeUpNow()) and then execute the loop again.
In my example i am using a tiny solar cell that can output up to 4volts under full sunlight to trigger the RISING-Event on PIN2. The interesting detail about that is that this sensor can power itself obviously, therefore the Arduino could even shut down it’s PINs during sleep and would still wakeup. This setup could be used to turn on a sensor if a box is opened for instance (think of a intrusion detection in your house or a smart geo-cache for instance). In combination with our ArduFona Board this could then trigger a GSM action or call a WEB-API etc.
In my future research i will try to identify more sensors that can be put to work like this – which is not as trivial as you might think because most sensors are working with a more complex output like I2C or do not provide the right output by other means in the first place. But i think many cases can indeed work like this, ultrasonic-sensors for distance, acceleration sensors with analog outputs etc. – i’ll keep this blog posted.
See it in full operation here:
Here is the code for the above example:
#define buzzer 9
#define led 13
int wakePin = 2; // pin used for waking up
void wakeUpNow() // here the interrupt is handled after wakeup
attachInterrupt(0, wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function
sleepNow(); // sleep function called here
void sleepNow() // here we put the arduino to sleep
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
sleep_enable(); // enables the sleep bit in the mcucr register
attachInterrupt(0,wakeUpNow, RISING); // use interrupt 0 (pin 2) and run function
sleep_mode(); // here the device is actually put to sleep!!
sleep_disable(); // first thing after waking from sleep:
detachInterrupt(0); // disables interrupt 0 on pin 2 so the