How to achieve lowest power consumption.

I am build a project and I would like to run it off a single Li Ion battery ( 3.7v 900ma) and have it last months or longer on a single charge. Basically I would like it to "wake up" every minute or so and check an input and then goto sleep if input is still low. If input is high then program would run for as long as required then shut down when input goes low again. I would also like to have an input that when ever pressed will wake it up.

So.. can an Arduino mini pro be put to sleep? ( so to speak) And how? If so how much current will it draw? If no how much current will it draw? ( I am more than happy to remove the "power" LED

Yes, Atmega328 can be put to sleep.
I don’t know about non-hardware wake ups, these bits will do a lot of the rest.
Make sure to set your unused inputs high or low, don’t leave them floating.

#include <avr/sleep.h> // powerdown library
#include <avr/interrupt.h> // interrupts library

Hardware interrupt to wake up
//***************************************************
// * Name: pin2Interrupt, “ISR” to run when interrupted in Sleep Mode
void pin2Interrupt()
{
/* This brings us back from sleep. */
}

//***************************************************
// * Name: enterSleep
void enterSleep()
{
/* Setup pin2 as an interrupt and attach handler. /
attachInterrupt(0, pin2Interrupt, LOW);
delay(50); // need this?
/
the sleep modes
SLEEP_MODE_IDLE - the least power savings
SLEEP_MODE_ADC
SLEEP_MODE_PWR_SAVE
SLEEP_MODE_STANDBY
SLEEP_MODE_PWR_DOWN - the most power savings
*/
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // setting up for sleep …
sleep_enable(); // setting up for sleep …

// Disable ADC
ADCSRA &= ~(1 << ADEN);

// Power down functions
PRR = 0xFF;

sleep_mode(); // now goes to Sleep and waits for the interrupt

/* The program will continue from here after the interrupt. */
detachInterrupt(0); //disable interrupts

// Power up functions
PRR = 0x00;

/* First thing to do is disable sleep. */
sleep_disable();

// then go to the void Loop()
}


// set up the pins as Inputs, Outputs, etc.
void setup()
{
/* Setup the pin directions, write inputs High to turn on internal pullups */
pinMode(pin2, INPUT); // our sleep interrupt pin
digitalWrite(pin2, HIGH);
}
void loop()
{
if (sleep_count>1000){ // check if we should go to sleep because of “time” → Try shorter versions of this
sleep_count=0; // turn it off for when we wake up
// Serial.println(“Sleep”); // for debug only

enterSleep(); // call Sleep function to put us out

// THE PROGRAM CONTINUEs FROM HERE after waking up in enterSleep()
} // end of checking to go to sleep

excellent

Thanks for that.

Will inspect and digest code later. So how much current will it consume?

If you are running the LiPo battery direct to the Vcc pin, bypassing the regular, and you remove the power LED, consumption will be pretty low:

Low Power Consumption at 1 MHz, 1.8V, 25°C for ATmega48PA/88PA/168PA/328P: – Active Mode: 0.2 mA – Power-down Mode: 0.1 ?A – Power-save Mode: 0.75 ?A (Including 32 kHz RTC)

A little higher at 8 Mhz (3.3V Promini). I have an RF Remote that I put in sleep mode. Kept the LED, has an RF Tx module that draws a little also, and a MAX1811 battery charge control chip that draws a little, charges it up from a 5V source. Flashes an LED when I press a button. 1000mAH LiPo goes about a month before I don't see an LED flash anymore.

I did some tests of low power mode here:

http://www.gammon.com.au/forum/?id=11149

I didn't exactly get such low figures though. However this was using a 16 MHz resonator.

I got about 25 ?A when asleep. However to wake it up you need the watch-dog timer (unless you have some external interrupt source).

According to the Atmega328 spec on page 381, using the watchdog timer significantly increases power consumption (eg. from about 0.1 ?A at 5V at 20 degrees to about 6 ?A under the same conditions).

Dropping the clock rate and the supply voltage looks like it would help somewhat.

So feeding power into VCC instead of RAW will bypass the on board regulator and the board will consume less power? But then the VCC will have to be 3.3volt? or can I still feed upto 4.2 volt into it?

While a months sounds like a long time I would prefer 6 months stand by time if not more.

I will also be using a LM 348 Op amp. Can I power this via one of the digital outputs so it does not draw current while asleep?

@Nick: Did you do anything to keep the unused pins from floating?

Thanks Nick. That looks promising. clock speed is not an issue at all.

[quote author=Coding Badly link=topic=69842.msg517541#msg517541 date=1313742226] @Nick: Did you do anything to keep the unused pins from floating? [/quote]

No, although I turned off the ADC in software.

Packhorse: I will also be using a LM 348 Op amp. Can I power this via one of the digital outputs so it does not draw current while asleep?

Certainly. I powered an entire clock board from a digital output to turn it on and off as required.

Avtel have a writeup on Pico Power Basics. I have written some stuff about power saving using sleep modes and the watchdog timer in my blog, but I'm still learning. So keep an eye on my Arduino notes :blush:

"So feeding power into VCC instead of RAW will bypass the on board regulator and the board will consume less power? But then the VCC will have to be 3.3volt? or can I still feed upto 4.2 volt into it?"

Yes. Board will run at 8 MHz from Vcc from ~2.5V up to 5.5V; see section 29 of the datasheet. I do not regulate it at all, just whatever the LiPo battery puts out.

Just be sure to research the Arduino BOD fuse setting and adjust as appropriate. Li-po useful discharge voltage range is 4.2 down to 3.5, under that cell can be damaged due to over discharge.

Lefty