I am trying to reduce current consumption on my project. Right now it is using ~1.28mAh, it should be possible to get it much lower (I am using AA batteries as the power source).
The ATtiny85 has its fuses set to run at 1MHZ, with BOD disabled.
I am using this board to mount the CPU. I desoldered the power LED and the regulator, feeding power directly from the batteries to the 5V input.
Nothing was connected to any other pins while measuring, just 5V and GND. The code was running in debug mode, so every 8 seconds it flashed a debug LED. I don't know for how much this could account.
Full code:
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>
#define DEBUG (true)
#define INT_PIN (0)
#define OUT_PIN (2)
#define LED_PIN (1)
/***************************************************
* Name: ISR(WDT_vect)
*
* Returns: Nothing.
*
* Parameters: None.
*
* Description: Watchdog Interrupt Service. This
* is executed when watchdog timed out.
*
***************************************************/
EMPTY_INTERRUPT(WDT_vect);
EMPTY_INTERRUPT(PCINT0_vect);
/***************************************************
* Name: enterSleep
*
* Returns: Nothing.
*
* Parameters: None.
*
* Description: Enters the arduino into sleep mode.
*
***************************************************/
void enterSleep() {
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sleep_cpu();
sleep_disable(); /* First thing to do is disable sleep. */
#if DEBUG
digitalWrite(LED_PIN, HIGH);
for (uint16_t dbg = 0; dbg < 65535; dbg++);
digitalWrite(LED_PIN, LOW);
#endif
}
/***************************************************
* Name: setup
*
* Returns: Nothing.
*
* Parameters: None.
*
* Description: Setup for the serial comms and the
* Watch dog timeout.
*
***************************************************/
void setup() {
pinMode(INT_PIN,INPUT);
pinMode(OUT_PIN,OUTPUT);
pinMode(LED_PIN,OUTPUT);
ADCSRA &= ~_BV(ADEN); // ADC off
power_all_disable();
}
/***************************************************
* Name: enterSleep
*
* Returns: Nothing.
*
* Parameters: None.
*
* Description: Main application loop.
*
***************************************************/
void loop() {
digitalWrite(OUT_PIN, LOW);
digitalWrite(LED_PIN, LOW);
/*** Setup the WDT ***/
wdt_reset();
/* In order to change WDE or the prescaler, we need to
* set WDCE (This will allow updates for 4 clock cycles).
* WDTCR on ATTINY85 / WDTCSR on ATMEGA
*/
WDTCR |= (1<<WDCE) | (1<<WDE);
/* set new watchdog timeout prescaler value */
WDTCR = 1<<WDP0 | 1<<WDP3; /* 8.0 seconds */
/* Enable the WD interrupt (note no reset). */
WDTCR |= _BV(WDIE);
// sleep for 8 seconds x 43200 = 96 hours = 4 days
for (uint16_t i = 0; i < 43200; i++)
enterSleep();
wdt_reset();
wdt_disable();
GIMSK |= _BV(PCIE); // Enable Pin Change Interrupts
PCMSK |= _BV(PCINT0); // Use PB0 as interrupt pin
enterSleep();
#if DEBUG
digitalWrite(LED_PIN, HIGH);
#else
digitalWrite(OUT_PIN, HIGH);
#endif
enterSleep();
PCMSK &= ~_BV(PCINT0); // Turn off PB0 as interrupt pin
}
1.28mAh
; I assume thath
at the end is just a typo. Are you sure your multimeter is accurate in this low range?