Intro: Arduino Device With Zero Standby Power
The problem: onboard devices for vehicles (cars) typically draw some standby power.
I hate that (yes indeed, it's more than just "dislike"): my car is used very little and I frequently have the battery depleted.
So my own designs should do it right: zero standby power.
Zero as in nil, zilch, nothing; not "very little" or "almost nothing" but actual zero.
And it is simple, too!
Step 1: Standby Mode
Consider the schematic (I publish this in SVG only, its so simple, you can quickly redraw it in KiCAD).
The device is a PWM modulator for a 30W light in my car. Since it uses up to 30 watts when powered on, I do not care about power consumption while the device is operating.
But I wanted zero consumption while it is waiting to be turned on.
To achieve zero power, the Arduino (an Arduino Nano in my case) must not be powered, neither can the Buck converter be powered on during standby.
This means, we only have onboard voltage available while in standby; this is the battery voltage somewhere between 10V (almost empty) and 14.1V (generator running, battery charging).
this is a voltage that must never reach the AVRs pins, it would fry the chip immediately.
That is where the relays come in.
Please ignore that they have 2 changeover contacts each in the schematic: its the only relay I found in the KiCAD lib and I was to lazy to draw a single-contact device :-)
During standby the relay contact are in the position as drawn.
K2 passes on the input power (marked as 15V) to K1 through the normally-closed contact.
K1 does not feed the rest of the device through the normally-open contact.
Result: zero power because there is zero current.
Step 2: "It Works Better If You Switch It On"
So lets switch it on.
We press SW3 to do that.
Now a base current flows from the base of the PNP transistor Q1 (limited by R1) through the pushbutton to ground.
Q1 starts to conduct and feed power to the relay coil: the relay is activated.
This closes the contact and the power from the input is fed to the rest of the device.
And also to the relay coil, so the relay is providing its own activation power: the device stays on when the pushbutton is released.
Step 3: Power-off Under Software Control
Once the device is powered, the firmware in the Arduino is in control.
In my case it is a PWM modulator for an LED lamp.
SW1 and SW2 are actually the A and B phase of an rotary encoder, SW3 is the pushbutton integrated to that encoder.
The firmware reads the rotary encoder to control the PWM output D5, which drives the gate of Q3.
The direct gate drive is not "the right way" to drive a Power-MOSFET, but it still works quite well :-)
(The "right" way includes some current limiting resistor and usually a higher diving voltage; the higher voltage would turn the FET on more quickly and such reduce switching losses in the transistor.)
The firmware can also read the pushbutton just fine.
If SW3 is pressed, pin D6 is pulled to ground and reads as LOW, just like a button not connected to the 12V domain.
D3 makes sure the deadly 12V does not harm our AVR chip.
To turn the device off, the software sets pin D12 to HIGH.
This sends a current to the base of the NPN transistor Q2, it conducts and thus activated the coil of K2.
Now K2s contact opens and cuts the power going to the device.
Without power, K1s coil is deactivated and the contact opens.
So when K2s coil is deactivated, the device is still cut off from power - we are back to standby.
C1 is crucial for this operation. Without C1, the whole device will not turn off.
The reason is simple: When K2 activates, the entire device looses power. The power loss is big enough for the AVR on the Arduino to reset.
When in reset state, all pins are switched to input mode, so nothing drives Q2, so the coil is deactivated and the normally-closed contact closes again quickly.
All this happens too fast for the coil in K1 do become demagnetized, so that one stays on - and so the devices stays on.
Unless we add C1, that is.
When Q2 becomes conductive, it discharges C1 very quickly.
When Q2 turns off again, C1 is still discharged and the current through the relay coil continues for a split-second, charging the capacitor.
This time is sufficient for the coil in K1 to become demagnetized and the relay to fall off - thus cutting power to the device.
The actual value for C1 depends on the relays you are using.
For the Finder relays I use here, the 470 uF provided just enough lag to let K1 fall off.
When you experiment with this method, you want to use the smallest capacitor value that is big enough to keep K2 active long enough for K1 to fall off.
The reason is simple: the energy stored in C1 (which is 0.5 times capacity times voltage squared, by the way) must be dissipated by Q2 every time the cap is discharged.
Too large a capacitor => too much for a small NPN like the trusty BC547 to handle.
Step 4: What If I Do Not Have Access to European Semiconductors?
From the BCxxx type all-purpose small signal transistors you could already tell: I am from Europe. Germany to be more precise.
Not to worry: the actual transistor type is not really important.
In 1970ies publications these transistors were marked as TUN or TUP - for "transistor universal NPN" and "transistor universal PNP" respectively.
Just use any small signal transistor that can handle the approximately 120-150 mA current of your relay coil and has a breakdown voltage above 30V.
There is many types that fit the bill.
Adjust R1 and R2 according to the transistors current gain, but even the crappy old models from the 60ies will switch all the way on with a base current of 10 times the collector current :-)
And what is that "Buck module" thingy up there in the schematic?
I recently started to use pre-made regulator modules I buy off ebay.
These come from China for a price at which I can not even buy the components (actually: even the coils alone are more expensive in single-piece quantities than the entire module).
They are not always really well designed, but for simple digital devices they get the job down: convert from one voltage to another with not-too-shabby efficiency.
In theory, an Arduino can be powered directly from onboard voltage: the 14.5V you'll frequently find in a cars power supply is still within the specified limits for the Arduino Nano, Uno, Dicemilia, Duemilanove etc.
Still: they only have a linear regulator on board.
Linear regulators (like the famous 7805 or LM317) are great, do not create the typical Buck-regulator ripple nor any ground noise.
But they have to convert all excess energy to heat.
So when running at 10V, the regulator will burn as much power as the Arduino (an all attached devices like LEDs) combined, at 15V it accounts for two thirds of the overall power consumption.
In the intro I said, I do not care about power consumption while the device is active, and that is true.
But I do care about the heat generated, and a linear regulator on an Arduino Nano gets simply too hot when running from onboard power.
The switching regulator therefore is used to feed the Arduino at 7.9V: still 2.9V for the linear regulator to drop (which results in good, stable operation), and still much less heat produced.
So, that is it, hope you get an idea for saving some power in one of your next projects :-)
In the mean time I'll think about a variant using only one relay and semiconductors otherwise...