# Electrical – How to make 1uA consumption on Attiny13a

atmegaatmelavr

I'm measuring my standalone Attinty13a (internal 128kHz) current consumption with li-ion accumulator (3.7v, 220mAh). Here is my schema

and code:

#include <avr/interrupt.h>
#include <avr/sleep.h>

ISR(WDT_vect) {
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
delay(1000);
}

int main(void) {
DDRB = 1<<DDB4;
WDTCR |= (1<<WDP3);
WDTCR |= (1<<WDTIE);
sei();
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
for (;;) {
sleep_mode();
}
}


Everything works fine: when it sleeps ammeter shows 5uA, and when digital pin 4 comes "on" ammeter shows more than 40mA. Nothing is connected to the chip, all pins are empty outside. I wonder could i reduce "pin on" state to 1uA?

Update:

I succeed with current reduction by setting all ports as outputs by using this code.

#include <avr/interrupt.h>
#include <avr/sleep.h>

ISR(WDT_vect) {
PORTB ^= 1<<PB4;
PORTB ^= 0<<PB4;
}

int main(void) {
for (byte i = 0; i <= 20; i++)
{
pinMode (i, OUTPUT);    // changed as per below
digitalWrite (i, LOW);  //     ditto
}
WDTCR |= (1<<WDP3);
WDTCR |= (1<<WDTIE);
sei();
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
for (;;) {
sleep_mode();
}
}


I do not quite sure how everything works now, but I added a LED with 1M ohm to pin 4, and 150 ohm resistance to Reset pin <-> Vcc, and my ammeter on scheme now shows 5uA in sleep state, and ≈7uA when pin turns on.
ps:

https://www.gammon.com.au/power not all function of this tutorial works with Attiny13a, probably because its for Atmega328

http://brownsofa.org/blog/2011/01/10/the-compleat-attiny13-led-flasher-part-3-low-power-mode/ i used this tutorial to make my Attiny use power down mode.

#### Best Answer

Typical consumption of the ATtiny13A in the Power-Down mode with WDG timer enabled is between 4 and 5 uA according to the datasheet (see page 131), namely:

Your measured value of 5 uA matches pretty well. Additional 2 uA with pin high are quite expected current for LED and 1 MOhm resistor to the ground.

So with the changes you made measured current is what would be expected (note below: the second line, xor with zero, in your ISR has no effect on pin state or anything).

If you want to achieve even lower current consumption with this particular MCU, there is not much more options.

Disabling the WDG timer should leave you with 0.3 uA typical in the power off mode, but then only available wake-up source are external pin change interrupts (see page 30 in the datasheet), but no time-based wakeup. Probably only reasonable option remaining if such low consumption is really necessary would be adding an external low-power RTC circuit with alarm function and routing its alarm signal to AVR pin.

As an example, M41T6x ICs by ST should be able to do timekeeping at less than 0.5 uA. There are for sure other RTC ICs with similar performance. So in theory this is a possibility to reduce current under 1 uA and to have time-based wake-up. If it is a practical solution in your situation is another question.

Note that 1 uA will (neglecting any self-discharge) discharge your accumulator in about 25 years, so 5 uA is still good for 5 years theoretically. So you should carefully check if the MCU power-down current is critical part of your power budget at all.