Thanks jremington for you reply. I have read until I am blue in the face. I know about voltage dividers and how they work. The problem occurs with the analogRead giving a integer not a voltage. So in the code you have to handle things like resistor values, tolerances, and conversion to a float voltage value to test against. My divider gives me a 2.38v to 3.78v input to the (a2) pin. The battery voltage at the divider is 11.56v to 13.7v. my code
float checkBattery() {
sensorValue = 0;
for (int i=0; i < 5; i++){
sensorValue = analogRead(batteryVoltage);
sensorValue1 = sensorValue1 + sensorValue;
Serial.print(sensorValue);
Serial.print(" -- ");
Serial.println(sensorValue1);
}
sensorValue1 = sensorValue1/5;
voltage = ((sensorValue1 * 12.0)/1023);
return voltage;
}
the line
voltage = ((sensorValue1 * xxxxx)/1023);
is the problem is what value to use in place of the xxxxx