Auto-Off Circuit Options
A common need in battery-powered DIY gadgets is an auto-off feature; after you turn the device on, a timer starts and shuts the device off a set amount of time. You might use long durations for things like lamps or heaters, or short durations, for things like IOT sensors, that just need to wake up for 10 seconds to send a message.
There are a bunch of ways an auto-off circuit can be accomplished, and it really depends on your needs. This are kind-of in order from simplest / fewest components, to more complex:
Auto Off Circuit - RC + Transistor
- You can't get much more simple than this; you just need a diode, resistor, capacitor, and a transistor (ideally a suitably powerful P-Channel MOSFET)
- Operation is simple: Turning on the device (e.g. pressing a button) flips the transistor on (by pulling down on the gate), and also allows the capacitor to quickly charge to full charge and voltage. Once the on trigger is released, the RC part immediately starts discharging across the resistor, and eventually the voltage drops low enough and the transistor flips off
- Could be made adjustable in-place by using a variable resistor
- Pros: Few components, almost non-existent quiescent current draw, simple
- Cons: Inaccurate (due to variance in R & C), many transistors do not instantaneously flip off (aka slow close), not adjustable on-the-fly, larger components (especially capacitor) take up more space, could be issues with debounce without more components
- The "slow close" effect can be remedied with more components, such as by adding a relay. The difference is very notable; checkout the two videos from this page - A Simple Time Delay Circuit. Of course, adding more components raises the question of maybe it would be worth evaluating a different tool (such as an MCU) anyways...
- Examples:
RC + Transistor Auto Off Demo
Here is a neat demo of this kind of auto-off RC-transistor circuit in action:
The red line is the voltage at the drain side of the MOSFET (allowed through), and the blue line is the voltage at the gate. Once the gate voltage reaches the shutoff point of the MOSFET, you see it close and current stops being allowed through.
Auto Off Circuit - 555 Monostable ("One-Shot")
- There is a reason why the 555 is called a Timer IC - it is perfect for time based applications, like this. The monostable mode of the 555 uses an RC circuit to set the delay time (similar to the above method), and then a separate voltage for the trigger.
- WARNING: Like the MCU option below, you might still need a separate transistor or relay to do the actual switching; make sure to read your 555's data sheet for the specific max current it can handle.
- Pros: More precise than the above (RC + Transistor) method, simple
- Cons: Still susceptible to variance in RC circuit, large quiescent current (even with lower draw CMOS designs), requires more components (especially if trying to design zero-draw-while-off configuration) not always cheaper than microcontrollers
- The high current draw is a real drawback, since the main point of an auto-off feature is usually to conserve power. This alone is a common reason to recommend microcontrollers over 555s, even though they add some complexity. Or, although it adds a lot more components, design a secondary transistor circuit to be used to shut off power to the 555 itself after the delay has passed.
- For comparison, a run of the mill non-CMOS 555 will pull about 3-6mA for operational current on a 5v supply. In comparison, a ATtiny85 will pull about the same while in full operation, but in sleep mode, can pull as little as 200-400 nanoamps.
- Examples:
- homemade-circuits: 1 Minute Porch Light Timer
- Elonics: Adjustable Auto On Off Delay Timer Circuit Using 555 IC
- Make - Charles Platt: 555 Timer approach that uses zero current draw between timings
Auto Off Circuit - Cheap Microcontroller (MCU)
- This seems like the standard approach now, and for good reason. Microcontrollers are extremely inexpensive (especially in bulk), provide precise timings, require very few external parts, and come in many varieties.
- Warning: You are probably going to still want to use a transistor or relay of some kind to do the actual switching (either on high or low side), since pretty much every MCU cannot source that much current (for example, the ATtiny25, 45, and 85, all have a max output current of just 30mA per IO pin!)
- Pros: Inexpensive, small, low quiescent current options, low active current options, precise, few external components required, adjustable and reprogrammable, can be used for many functions beyond the timer at the same time
- Cons: Often require a more precise input voltage
- Examples:
- YourITroncis: Adding Auto Off to a multimeter using an ATtiny25
- Related Hackaday post
- Danny Chouinard: Low quiescent current auto off with ATtiny85
- Random Nerd Tutorials: Auto Power Off for ESP8266
Auto Off Circuit: Timer specific IC
- This is pretty similar to just going the micro-controller route, since you are adding a complex IC to replace many individual components. However, the advantage is that an integrated circuit that is specially designed for timed power control circuits is likely to have much lower quiescent current draw, as well as easier configurability in hardware (e.g. resistor selectable time interval)
- Pros: Can be found with extremely low current draws, flexible input voltage range, configurable with hardware, fewer external components
- The low quiescent current draw is a huge selling point for ultra low power devices (such as "parasitic" power devices). The average "powered down" / "idle" current draw on an ATtiny85 is around 400 nanoamps (0.4 ยตA), and with tweaks or using a different ATtiny, you might be able to get it down to 100 nanoamps (0.1 ยตA). In comparison, the TI TPL5111 (a specialized timer IC), while fully on and operational only draws 35 nanoamps!
- Cons: Higher price, harder to source
- Examples:
- Digikey: Clock/Timing ICs
- TI TPL5111
- TI TPL5010