I've an attiny13a (9.6MHz, BOD 2.7V) put to sleep but it draws 20µA (without the LDO). I've connected nothing else but 3.3V power (HT7333). I find this really surprising because my Pro Minis waste 5-6µA while sleeping.
Here's how I put it to sleep:
#include <avr/sleep.h>
#include <util/delay.h>
void setup() {
DDRB = 0b000001; // all but PB0 INPUT, want to use PB0 ...
PORTB = 0b000000; // all LOW
}
void loop() {
sleepNow();
}
void sleepNow() {
{
// BODCR |= (1<<BODS)|(1<<BODSE); //Disable Brown Out Detector Control Register
ACSR |= (1<<ACD); //Analog comparator off
ACSR = ADMUX = ADCSRA = 0;
}
WDTCR |= (1<<WDP3) ; //Watchdog set for about 4 seconds
// Enable watchdog timer interrupts
WDTCR |= (1<<WDTIE);
sei(); // Enable global interrupts
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_mode();
sleep_disable();
}
Btw. the BOD-constants are not set (Arduino 1.6.9, MicroCore core by MCUdude) and I could not find the example, I stumbled upon some time ago, how to assign values to registers in C. I would like to define the constants myself BODCR is 0x30.
The register names are supposed to be supplied by the compiler. He can probably hack in the missing define, but it's curious that it's an issue.
You have the part where you disable the BOD commented out - it's wrong anyway, even if the register defines were in, though, see section 7.5.1 and 7.2 of the datasheet - there's a special sequence you need to use to write to that register.
terraduino, try changing this line to attiny13a, and do the power consumption measurements again. If the power consumption drops, I'll add this fix to the core
cli(); // No interrupts; timed sequence
BODCR = (1<<BODS) | (1<<BODSE);
BODCR = (1<<BODS);
sei(); // Enable global interrupts or we never wake
// Sleep now!
Thanks a lot for the update, it does work without the explicit definitions of BODCR and the like.
@CodingBadly Thank you for the code sample, it does work. The current while sleeping now is lower than what my DMM can measure
Btw. a second #define produces a warning only when the second #define is different from the first.
Hi @terraduino , can you post the final code you used for this. I am also trying to reduce the power consumption of ATTiny13A to near zero but I can only get ~ 2.3uA using WDT while ATTiny85 goes down till 0.2 uA while sleep.
I am not an expert on AVRs and hence did not understand the conversation on this thread properly.
Hi @terraduino, I tried your code but I still get a sleep current of 2.3 uA.
The code you posted isnt very different in what it does from what you originally asked here apart form disabling ADC, isnt it? Disabling ADC did not affect current consumption for me. Was there something you were able to do to bring down the consumption?
Well, I cant claim that my DMM is very accurate so if it is showing 4uA as 2.3 uA , it might be possible. But then on the same DMM I am able to get a 0.2 uA on ATTIny85. I tried that when I saw the post by a gentleman here . He also claims that the sleep current is of that order.
I'm sure my DMM isn't the most accurate. Everything below 20uA is "very low" for me
Btw. the datasheet supports @Smajdalf statement, see Table 18-1 on page 118.
@vks007
Note that most of my Attiny13a are used in combination with reed switch or PIR. Hence, the WDT is disabled and current consumption is lower.
Thanks @terraduino. You may be right on that. Although I haven't been able to get sleep working on my ATiny13A without WDT. I tired several times but maybe I am missing something. Although my current project does require WDT so its okay but do you mind posting a code for t13a without WDT?