We have the electronic to control the battery discharge, but what happen when the battery hit the threshold?
At the electronic level, the comparator rise up the output, but what will do the micro controlled attached to that comparator pin?
The deep sleep mode, is a mode of all micro controller to get it in a very low power consumption.
In most of cases we use the Arduino micro controller, and it has some appropriate commands to jump in a deep sleep mode: https://goo.gl/VCsgSU
I advise you to use this good library, Sleep_n0m1 : https://goo.gl/pH2Snf
According with this library, i show you a simple example:
#include <Sleep_n0m1.h>
Sleep sleep;
// attachInterrupt: https://goo.gl/DGR2bH for the single Arduino
// for the ONE we only have the pins 2 and 3 attached to the interrupts
#define intPin 2 // i use the pin 2
void setup()
{
Serial.begin(9600);
// attachInterrupt: https://goo.gl/DGR2bH
// When the comparator go HIGH, the Arduino will go to the deep sleep mode
attachInterrupt(digitalPinToInterrupt(intPin), deep_sleep, HIGH);
delay(100); ////delays are just for serial print, without serial they can be removed
Serial.println("The battery is ok.");
}
void loop()
{
// some interesting code
}
void deep_sleep() {
Serial.print("Battery under 3V ! I'm going to sleep! Bye!");
sleep.pwrDownMode(); //set sleep mode
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.