Auto power off is must have feature for battery powered device to help extend battery life. These days, many modern battery powered devices has an automatic power off function. But, if you have battery driven device with no auto-shutoff you can add auto power off using simple circuit designed by Kyle Wengenroth below.
This project uses ATtiny85 microcontroller to trigger a port pin when powered on and turning it off after the time has elapsed. Besides MCU, the project uses 2 transistor (NPN & PNP) for switching, 2 capacitor, and 1 resistor for limit the current.
The project’s firmware is simple: enable port pinX as output low & start the timer. When timer is up, make port pin input high impedance (HiZ). The project uses interrupts, sleep modes, and the watchdog clock source to keep power usage minimal. Even with it written in C, the code size is only 200 bytes, which can be substantially reduced further with assembly.