7
\$\begingroup\$

I am creating a project that uses an ATTINY85. Most of the time, the circuit should be off and consume as little power as possible. According to the data sheet, in power-down mode, the microcontroller consumes 0.1 μA at 1.8V. I am powering the circuit using two AAA batteries in series, which gives around 3V, so I expect an higher power consumption, but still on the same order, but so far I am getting 300 μA in power-down mode.

I have removed everything from my code except for the power management code to try to isolate the problem:

#include "Arduino.h"
#include <avr/sleep.h>
#include <avr/power.h>

void setup()
{
  cli();  // Disable interrupts

  // Reduce the clock frequency to conserve power
  clock_prescale_set(clock_div_128);

  // Disable all modules
  power_all_disable();
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);

  // Configure all ports as output
  // (does not seem to make any difference)
  DDRB = 0b0011111;
  PORTB = 0;
}    

void loop()
{
  sleep_enable();
  sleep_bod_disable();
  sleep_cpu();
}

As can be inferred from the code, I am using the Arduino library to program because it was quicker to setup, but I do no think that this would make any difference. Am I wrong?

The fuses are E:FF, H:DF, L:62, so I am using the internal 8MHz oscillator, divided by 8. I further use the clock prescaler to divide it by 128, because it seems that it should reduce the power consumption.

My circuit is as follows:

Circuit diagram

This diagram does not show it, but the resistors are connected the anodes of four LEDS, whose cathodes are connected to ground (so the leds turn on when the pins are high).

I am measuring the current with a multimeter whose lowest scale setting is 200 μA, so I believe that I should be able to measure this current with reasonable accuracy.

What am I missing here? Why is my current consumption higher than expected?

\$\endgroup\$
17
  • \$\begingroup\$ What do the output ports attached to the 4 resistors go to when in power-down mode i.e. maybe you have them set as weak pull-ups? Is your unused input set as an output? Why have you got a pushbutton directly across the supply? Any decoupling capacitors you forgot to show on the circuit? \$\endgroup\$
    – Andy aka
    Commented Jan 11, 2018 at 17:28
  • \$\begingroup\$ Have you carefully read the charts and tables in the datasheet? The ONLY way you achieve anything near \$1\:\mu\text{A}\$ is if you shut down ALL of the oscillators, including the RC oscillator and watchdog. See page 178, Figure 22-11. If you enable the watchdog, but keep the main oscillator off, this rises to multiples of \$1\:\mu\text{A}\$. All this also assumes there's nothing attached to the MCU that might alter these figures. The RC alone, if 128 kHz, will chew up \$60\:\mu\text{A}\$ or so. \$\endgroup\$
    – jonk
    Commented Jan 11, 2018 at 17:35
  • \$\begingroup\$ If you want extremely low current, you can be under \$1\:\mu\text{A}\$ while keeping a tuning fork oscillator running at \$32\:\text{kHz}\$ with the MSP430. (Absolute guarantee over all temps is higher, though.) It has a special crystal oscillator inverter designed for tuning fork crystals, which themselves only require well under \$1\:\mu\text{W}\$ to operate properly. MSP430, adding DCO at \$1\:\text{MHz}\$ (for two oscillators running at once) is \$22\:\mu\text{A}\$ typical. Atmel devices cannot come anywhere near that. \$\endgroup\$
    – jonk
    Commented Jan 11, 2018 at 17:48
  • \$\begingroup\$ @andy aka, I tried to disable the internal pullups, but that did not make any measurable difference. The unused pin is set as output. Regarding the button, that's a mistake in the diagram. It connects reset to ground instead. There are no decoupling capacitors for now. \$\endgroup\$ Commented Jan 11, 2018 at 19:06
  • 1
    \$\begingroup\$ what about adc_disable() \$\endgroup\$
    – user16222
    Commented Jan 11, 2018 at 21:01

2 Answers 2

13
\$\begingroup\$

What was missing was that the ADC needs to be disabled before powering it off:

ADCSRA &= ~ bit(ADEN); // disable the ADC
power_all_disable();

This reduced the power consumption to ~16 μA. Since there are other components on the circuit, I don't expect to achieve the 1 μA advertised by the datasheet.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ This is a perfect case for answering your own question!! Glad to hear you tracked it down. It's almost always something like this, in my experience. \$\endgroup\$
    – jonk
    Commented Jan 16, 2018 at 18:54
4
\$\begingroup\$

To achieve Microchip's low power numbers, you need to configure all pins as inputs, and have each pin's voltage at ground or VCC (not allowing them to float between VCC and GND). Add pull-downs or pull-ups on the pins, and even add pull-downs in parallel with your LED's.

\$\endgroup\$
3
  • \$\begingroup\$ I'll try that and report back here. \$\endgroup\$ Commented Jan 11, 2018 at 22:58
  • \$\begingroup\$ I've tried adding pull-downs, but this did not make any measurable difference. \$\endgroup\$ Commented Jan 15, 2018 at 21:37
  • 1
    \$\begingroup\$ I don't use this exact part, but I have to configure all of the ports as inputs before you go to sleep, then re-configure them when you wake up. Also be sure brown-out detect is disabled. \$\endgroup\$ Commented Jan 15, 2018 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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