I am trying to minimize battery drain after putting the microcontroller to sleep. I am using this thread:
http://www.gammon.com.au/forum/?id=11497which shows that after powering down the ADC and brown out detector, and then entering SLEEP_MODE_POWER_DOWN, the mega328 should draw about .355uA. I am using this schematic:
Version5_Sch by
jg1996business, on Flickr
but I don't have anything connected to the ISP6 header or the SD Card connector, and I don't have the GPS Module soldered in yet. In addition, I dropped the 8MHZ resonator when I was trying to solder it in and it is lost so I burned the arduino bootloader for an 8MHZ internal oscillator breadboarded mega328. The 3.3V buck/boost converter and the LiPo charging circuit are soldered up. This is my test sketch:
#include <avr/sleep.h>
byte mode = 1;
volatile boolean switchPress = false;
volatile boolean lastSwitchPress = false;
unsigned long modePress;
void setup()
{
//Serial.begin(115200);
pinMode(6, OUTPUT);
pinMode(9, OUTPUT);
digitalWrite(2, HIGH); //enable pull up
attachInterrupt (0, buttonPress, LOW);
sleepCPU();
}
//function to put everything to sleep
void sleepCPU()
{
// disable ADC
ADCSRA = 0;
set_sleep_mode (SLEEP_MODE_PWR_DOWN);
sleep_enable();
// will be called when pin D2 goes low
attachInterrupt (0, buttonPress, LOW);
// turn off brown-out enable in software
MCUCR = _BV (BODS) | _BV (BODSE);
MCUCR = _BV (BODS);
sleep_cpu ();
}
void loop()
{
}
Doing the math for everything that should be working on the board, it would be .355uA for the mega328, 50uA for the 3.3V converter, and it looks like about 2 - 5uA for the charge controller. In addition, with a battery voltage of 4.2V and VCC of 3.3V, I believe about 90uA((4.2 - 3.3)/10000) should be passing through resistor R8 and there is probably some current flowing through resistor R3 but I am not sure about that. Regardless, the amount of battery drain should be around 140uA or so but when I plug everything into my multimeter it reads 4.6mA when running the above sketch. Can anyone spot on my schematic or sketch where I may be draining the battery faster than expected?