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:-
Can any expert have any guidance on this
Thanks in advance
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
Thanks in advance