I am currently working on a project in which a Duemilanove arduino and a variety of sensors measure various characteristics about the system it is attached to. Once this data is measured, it is sent wirelessly to another arduino using an xbee module. The Duemilanove arduino is in a confined space and is powered with a 7.2V Lipo battery pack. This system is left running for a few days without attendance and over discharging the batteries is a major concern.
The current stage of my project is I need to implement a battery management or monitoring system to measure the voltage of the battery that is powering the arduino and turn off the arduino if the voltage gets too low. I am quite new to using arduinos and I am looking for any suggestions on how to do this.
Any assistance would be greatly appreciated.
Over the 2 resisitors there is 7.2 volts so the Arduino will measure approx 3.6 volt as the resistors are equal => divide the voltage in two.
3.6Volt is ~~735 on the scale 0..1024
When the LIPO drops to say 6 volt, The arduino reference is still its internal 5 Volt, but the halfway voltage will drop to 3 volt.
3.0 volt is ~~614 on the scale 0..1024
When the LIPO drops to 5.5 volt, The arduino reference is still its internal 5 Volt, but the halfway voltage will drop to 2.75 volt.
2.75 volt is ~~563 on the scale 0..1024
#define R1 100200L // measure the value of the Resitors to be exact as possible
#define R2 99700L // add an L for Long values
float battery()
{
int raw = analogRead(A0);
float val = 5.0 * raw/1024.0; // convert to voltage halfway
return val * (R1 + R2)/R2; //calculate the battery voltage; if you don;t need to be exact just: return val * 2;
}
you can compress the code to a oneliner as the voltage = analogRead(A0) * C; with C = 5.0 / 1024 * (R1+R2) / R2; // C is of the type float.
You may also want to consider to replace the linear regulator with a switching regulator. Once this is done you may want to put you device into sleep mode as often as possible. This may reduce your power consumption significantly.