This short instructable presents a very simple way of auto powering off your microcontroller. I'm using an Arduino, but it should work for others in the very same way. I've searched myself for this for a while and found the solution in this application note: http://www.onsemi.com/pub_link/Collateral/AND9093-... . The solution presented here is simpler than others I found, and it works for higher voltages than the 5V used out there. What you need:
The following figure shows the circuit:
Build the circuit as shown in the diagram. It is important to use the Vin pin of the arduino as the 9V need to go through its 5V converter.
The example shows the code required to turn D7 (any other will do as well) HIGH after powering on the Arduino. Then, after 5 seconds, D7 is set to LOW, thus powering off the device.
Replace the 5 seconds delay with your code.
I've measured ~55mA when the Arduino is on, including the display, and I could not measure any current when it was off.