Hello FEllow Arduinites,
I've been trying for the past several days to come up with a LIPO cell voltage monitor, but failing to do so. I've read a lot of posts and borrowed some code, I'm close but not quite there yet. For example using my multi-meter I measure the voltage at the divider and I get 4.06v ,but when the arduino tells me the voltage on that cell it is 4.71. I know it's erroneous since the maximum voltage any single cell can have is 4.2v only. I'm only monitoring one cell until I figure out what's wrong, or somebody tells me where's my error.
BTW: I'm powering the Arduino with the same 2S Lipo battery.
Here's my code with the schem.
Schem for a 2S LIPO (7.4v/8.4v max):
LIPO (MAIN +) ------- 7.4v -------------------------------(Arduino pwr socket +)
----(Arduino pwr socket -)
LIPO (Cell 2+) ----- 4.2v max ----(Arduino Pin A1) |
|
10K ohms 10K ohms |
LIPO (Cell 1+) -----vvvv--|--vvvv---------------------|
| |
|--4.2v---(Arduino Pin A0) |
LIPO (GND-) ------------------------------------------|
Code: */
#include <SparkSoftLCD.h> // library to manipulate the SparkFun LCD backpack v2.5
#define CELL_1_PIN 14 // Analog Pin A0
#define CELL_2_PIN 15 // Analog Pin A1
#define LED_PIN 13 // Digital Pin 13
#define LCD_PIN 2 // Digital pin 2 to LCD
SparkSoftLCD LCD = SparkSoftLCD(LCD_PIN);
void setup(){
pinMode(CELL_1_PIN, INPUT);
pinMode(CELL_2_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
pinMode(LCD_PIN, OUTPUT);
LCD.begin(9600);
LCD.clear();
// delay(1500);
}
void loop(){
cellVolts();
digitalWrite(LED_PIN,HIGH);
cellVolts();
digitalWrite(LED_PIN,LOW);
}
void cellVolts(){
int cell1Volt, cell2Volt;
LCD.cursorTo(1,1);
LCD.print("Cell 1 voltage: ");
LCD.cursorTo(2,1);
cell1Volt = (analogRead(CELL_1_PIN)*5);
LCD.print(cell1Volt / 1024, DEC);
LCD.print(".");
LCD.print(cell1Volt % 1024, DEC);
delay(1000);
}
Any help, as always greatly appreciate it.