Arduino (AtMega 328) sleep mode current consumption

Thread Starter

yatindeshpande77

Joined Dec 20, 2015
38
Hello guys I am using atmega 328 for my NRF24L01 project which I have to use with battery so I need to reduce current!
I did power down in NRF module and it works fabulous!
Now turn to reduce current through atmega328!
Data sheet says on 1Mhz crystal I can reduce consumption upto 0.1uA but currently I am using 16Mhz as I am coding it using Arduino!
But in the following code in sleep mode uC consumig 1mA as I checked on Ammeter, I am confused and dont no where I did wrong!
My code is as follows:-
Code:
#include <avr/sleep.h>

int counter =0;

void setup()
{
 
Serial.begin(9600);
digitalWrite (3, HIGH);  // pull-up

//pinMode (13, OUTPUT);
//digitalWrite (13, HIGH);  // awake

Serial.println ("But does it get goat's blood out?");
 
}  // end of setup


void loop()
{
  delay(1000);
  if (++counter % 5 == 0)
    sleepNow();
}  // end ofloop


// interrupt service routine
void wake()
{
  sleep_disable();         // first thing after waking from sleep:
  detachInterrupt (1);     // stop many many interrupts
}


void sleepNow()
{
 
  Serial.println("SET_SLEEP_MODE");
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here
  Serial.println("SLEEP_ENABLE");
  sleep_enable();          // enables the sleep bit in the mcucr register
 
  Serial.println("SLEEP_MODE"); 
  digitalWrite (13, LOW);  // asleep

  attachInterrupt(1, wake, LOW);
  sleep_mode();            // here the device is actually put to sleep!!
 
  //digitalWrite (13, HIGH);   // awake

  Serial.println("MCU is back in business");
 
}  // end of sleepNow
Can any expert have any guidance on this
Thanks in advance
 

Papabravo

Joined Feb 24, 2006
14,248
The difference in operating frequency is huge when it comes to current consumption. You also need to turn off the peripherals you are not using. Just because the processor is asleep says nothing about the peripheral devices like timers, and the A/D subsystem.
 

Thread Starter

yatindeshpande77

Joined Dec 20, 2015
38
When we use maximum power saving (power down is maximum power saving mode in arduino) is peripheral still remain on?
When we use power down I thought we also bypass external oscillator!!! So is it still make affect and evem if it is does it that high as I am expecting curent in few micro Amp and getting 1 mA?
 

Papabravo

Joined Feb 24, 2006
14,248
Modern processors have more than one oscillator, and you need to read the datasheet very carefully to understand what is and is not running in low power modes. Something has to continue to run if you ever hope to wake up from sleep mode. Did you ever think about that?
 

Thread Starter

yatindeshpande77

Joined Dec 20, 2015
38
sailorjoe,
I tried with the given link but still I am on 1mA!
@Papabravo:- I am trying to find something from datasheet, hope I will get something new!
 

Papabravo

Joined Feb 24, 2006
14,248
So you changed the crystal from 16 MHz. to 1 MHz. and your still measuring the same power consumption?
Are you still using the external oscillator?
 

Thread Starter

yatindeshpande77

Joined Dec 20, 2015
38
Ok I finally able to reduce my atmega328 current consumption to 16uA with 16Mhz oscillator and 3.3V,
The problem wasnt the code actually, its strange one, I used a 1n4007 after 3.7V battery to reduce the voltage to 3.3 which was increasing my current to 1mA, As when I tested without diode it consume 16uA and with 4007 it consume 1mA! Strange, and I didnt understand why so!
@Carlmikael:- I am using Arduino UNO for coding and testing is done on breadboard with munimum ckt, as on arduino it has regulator and other ckt which consumes current!
 
Ok I finally able to reduce my atmega328 current consumption to 16uA with 16Mhz oscillator and 3.3V,
The problem wasnt the code actually, its strange one, I used a 1n4007 after 3.7V battery to reduce the voltage to 3.3 which was increasing my current to 1mA, As when I tested without diode it consume 16uA and with 4007 it consume 1mA! Strange, and I didnt understand why so!
@Carlmikael:- I am using Arduino UNO for coding and testing is done on breadboard with munimum ckt, as on arduino it has regulator and other ckt which consumes current!
What is the diod connected to? Is it the radio? Can you put the radio to sleep?
 

Papabravo

Joined Feb 24, 2006
14,248
Ok I finally able to reduce my atmega328 current consumption to 16uA with 16Mhz oscillator and 3.3V,
The problem wasnt the code actually, its strange one, I used a 1n4007 after 3.7V battery to reduce the voltage to 3.3 which was increasing my current to 1mA, As when I tested without diode it consume 16uA and with 4007 it consume 1mA! Strange, and I didnt understand why so!
@Carlmikael:- I am using Arduino UNO for coding and testing is done on breadboard with munimum ckt, as on arduino it has regulator and other ckt which consumes current!
I don't doubt your observations, but I'm not sure I understand how the diode can consume current unless it is your claim that it converts 0.4V*.001A into 0.0004 watts of heat. Had you provided us a schematic diagram at the outset the solution might have been more obvious. Why didn't you do that?
 

Papabravo

Joined Feb 24, 2006
14,248
So the 16 MHz. is not even connected to the processor. It must be running off of the internal oscillator. So it appears that even your description was misleading. Your schematic has three missing pins (7, 8, & 22) on the processor and there are no obvious connections to power and ground. This is IMHO a pretty misleading schematic. Also you have no bypass capacitors.
 

Thread Starter

yatindeshpande77

Joined Dec 20, 2015
38
Sorry I didnt have any good software so I made this schematic in proteus!
In that software we doont get Vcc and other obvious pins!
Vcc is connected to 7 ( terminal vcc in that picture), 8,22 to ground XTAL1 and XTAL2 to 9,10 respectively!
 

Papabravo

Joined Feb 24, 2006
14,248
The next problem is that you have a CMOS device with floating pins. This is almost guaranteed to increase power consumption. Good practice would be to tie unused pins high or low. I'm not sure what conclusions to draw from your schematic and your observations. I don't consider your setup to be a reliable one for making measurements of any kind. You have too many things which are uncontrolled.
 
Top