I'm working on a battery powered Arduino Nano project. I really need it to save power for hours on end, so I turned to Arduino LowPower Library and avr/sleep.h to do the job.
However, whatever I do, it doesn't look like the board isn't going to sleep. I have a sample sketch that tries to put the board to sleep and then toggles a relay when it wakes up, but it always toggles the relay instantly after booting, so that means it hasn't gone to sleep.
I also measured the current going into the board, and it's drawing 14mA consistently. I would expect to see a much lower draw whilst it's asleep.
Here are the two pieces of code that I've tried, one with LowPower and the other one with avr/sleep.h
void setup(){
pinMode(relayPin, OUTPUT);
}
void loop(){
// This call doesn't seem to do anything
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
toggleRelay(); //This gets executed continuously, with no indication of sleep time
}
Here's the other one with LowPower
void setup(){
pinMode(relayPin, OUTPUT);
}
void loop(){
// This call doesn't seem to do anything
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
//This gets executed continuously, with no indication of sleep time.
//I would expect it to see it toggle only every 8s
toggleRelay();
}
I'm probably doing something stupid, but I can't figure out what... Any help? Thanks a lot!