-
Notifications
You must be signed in to change notification settings - Fork 11
Energy consumption
An ATTiny running at 8MHz needs around 4-5 mA. The LED takes another 5mA when lit, but since we are turning it on for only very short times it doesn't really factor in (maybe another 0.1-0.2mA averaged over the active time). If we don't communicate over I2C then we can go back to sleep after a maybe 30-40 ms. If we communicate with the RPi (i.e., normal operation), then we can add a few milliseconds, which means we can assume around 50 ms of active time on average.
If we look at an ATTiny in sleep mode, then we can get to a sleep current of around 350uA at 4V, and with a few tricks we can get to something like 30uA at 3V. Since at 4V we are in the normal operating range, there is nothing to worry about. And the reduction at 3V is very nice, because this means that with a lower voltage the ATTiny needs a lot less energy.
The following measurement of the current of the board shows this at 3V (this includes the voltage divider, which adds another 15-20uA). Under normal circumstances the power consumption is even a little better, because the device under test was not connected to a Raspberry Pi, which means some of the pins were left floating and thus produced additional power consumption (floating input pins tend to oscillate, which leads to switching in the input gates and thus additional energy needed).
![](attiny_daemon%20full%20board%203000mV.png)
This means that with waking every second we get to an average power consumption of less than 600uA, and when we are below warn voltage this goes down even further to 175uA.
Keeping in mind that a Raspberry Pi normally takes between 700m-1.000mA, I think that we are ok.
If you want to reduce the energy consumption then either choose a larger resistor value or do not solder the LED and resistor at all. But, even though the LED needs roughly the same current as the ATTiny when not sleeping, it is flashed only for short amounts of time (around 50ms) every second. Furthermore, when the voltage goes down to warn level the LED is flashed only every other second and at shutdown level only every 8 seconds. Thus even with an LED we have an average power consumption of less than 500 uA (meaning that with a 2.500mAh battery the ATTiny will run for another 1.000 hours before the battery protection circuit turns everything off).
Going further than that is problematic. We might be able to reduce the deep sleep energy a little bit more, because we have the switch pin and the LED/button pin, which are both pulled high with the pull-up resistor.
The switch pin is connected to the EN pin of the of the ETA1096. Its data sheet (or at least its Google translation from the chinese original) states that the current flowing through this pin will not exceed around 5nA. Additionally we have two resistors in series pulling this to 0V, and at the same time the resistor we soldered onto the HAT that pulls it toward battery voltage. Thus in all normal case there will be next to no current flowing through this pin. The exception is when we have reached the shutdown voltage and the ATTiny is configured to actively shut down the UPS. In this case we have the current from battery through our pin to GND. This leads to a current of a bit more than 20uA. Not really a game changer.
The LED/button pin either lights the LED, in which case it is pulled to GND. This leads to 5-10mA of current depending on LED and resistor value. The much larger part of time it is configured as an input with pull-up resistor only connected to the LED (through which no current flows). This should lead to less than a 1mA current, since the internal pull-up is in the range of 10K. But without this we would lose the ability to directly react to button presses. And measurements suggest that the actual power consumption is very low.
So, for the time being I‘m more than happy with the result and with the ATTiny continuing to run for 40 days off the remaining charge when the shutdown voltage has been reached.
And as a reward for having read this to the end, here‘s a thought: When your ATTiny dies 40 days after power loss, it might be the last thing on Earth to die after the Zombie-Apocalypse.