There are times when your program needs to react to your device being turned off, for example to save the current state of an Arduino sketch to EEPROM before shutting down, or to disengage relays in a power module to ensure there is a clean shutdown. Usually, the power loss detector is designed as part of the power supply, so here I’ve put together an example power supply that we can study, note that this is not intended as an exemplar of power supply design, and is rather incomplete, but to serve as a crude model that we can study to see how to detect power loss.
There are some occasions when the amount you safely draw (assume 20mA) from an Arduino board pin is just not enough (and some Arduino boards have even lower current capability). In these cases the output needs to be buffered in order to provide more power. At this point there are several possibilities, including ready made buffer chips such as the ULN2003A. However, in this tutorial we are going to discuss single transistor buffers; which are simple to build, easily understood and good for a few hundred milli-amps.
I’ve got a side project of building a digitally Arduino controlled PSU that also includes an accurate component tester. In order to do this I’ll have to be able to monitor the current flowing through a circuit, so I’d need some way of monitoring this. Before continuing, I’d like to say that is not an exemplar of how to build a great current sensing circuit, it’s a prototype shown for example purposes only.