0
\$\begingroup\$

First off here is the code I have tested on both Attiny13A and Attiny85V:

#include <avr/sleep.h>

void doSleep(){  

    GIMSK |= (1<<PCIE);                     // Enable Pin Change Interrupts
    PCMSK |= (1<<PCINT3);                   // Use PB3 as interrupt pin
    ADCSRA &= ~(1<<ADEN);                   // ADC off

    WDTCR |= (1<<WDP3 )|(0<<WDP2 )|(0<<WDP1)|(1<<WDP0); // 8s
    WDTCR |= (1<<WDTIE);
    sei();
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);    // replaces above statement
    sleep_mode();

} 
ISR(WDT_vect) { }

void setup(){

    pinMode(PB0, OUTPUT);
    pinMode(PB1, OUTPUT);
    pinMode(PB2, OUTPUT);
    pinMode(PB3, OUTPUT);
    pinMode(PB4, OUTPUT);
    // Flash twice on boot
    digitalWrite(PB4, HIGH);
    delay(100);
    digitalWrite(PB4, LOW);
    delay(100);
    digitalWrite(PB4, HIGH);
    delay(100);
    digitalWrite(PB4, LOW);
    delay(100);
}//main

void loop(){
    // one long flash after waking up
    digitalWrite(PB4, HIGH);
    delay(2000);
    digitalWrite(PB4, LOW);
    doSleep();   // go to sleep and wait for interrupt...
}

For wiring:

  • 3v VCC from battery.
  • Ground
  • LED connected on PB4 through a resistor to ground. But I'm turning it off before sleep mode, so that shouldn't affect it.

This code on an Attiny85V consumes 0.1uA according to my multimeter. The same code on Attiny13A is pulling 100uA.

Am I missing something in the code? Is the t13A really 1/1000th as power efficient in sleep mode as the 85 alternative? Or am I the victim of counterfeit T13As?

Edit: Shortened code a bit

\$\endgroup\$
0
\$\begingroup\$

The ATtiny13 is spec'ed to draw ~0.2uA without WDT and ~4uA with WDT @3V @25C so if you are seeing 100uA then something else is going on here.

There is a lot happening in the above code. I'd scale it back to just the minimum code needed to put the chip into power down mode and then measure how much current that uses without anything connected to the chip besides power (no LEDs, inputs, not even programmer). You should see something close to the above numbers. Then start adding in more code and hardware, checking the power usage after each iteration so you can find the issue.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Simplified the code a bit, but I'm getting the same results, 100uA while sleeping \$\endgroup\$ – user2145184 Jun 7 at 20:24
  • \$\begingroup\$ With nothing connected to chip but power? No LEDs and no programmer connected? \$\endgroup\$ – bigjosh Jun 8 at 21:10
  • \$\begingroup\$ no, just a 3V battery. I'm gonna order some Attiny13a from a reputable seller and see if there's a difference. I'm getting a creeping suspicion they might actually be Attiny13 and not 13a. \$\endgroup\$ – user2145184 Jun 9 at 22:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.