Further to my post above, I have made some progress, which I’ll post here in case anyone’s watching!
-
I did find that in the sketch above that indeed the battery volatage is measured by A7, and that a " * 6 " added to the factor seemed to give sensable results. In my case 4.12 volts which is the same as measured on a multimeter on the board.
-
When connected to the USB 5 volts, the red led did come on, and after about an hour the red led extringusished and the green one let. The voltage reading on A7 was still 4.12 (The data sheet for the charging IC saiys it should keep charging until 4.2 volts, but whats .08 of a volt amongst friends.
-
The get the sketch to produce sensible results I had to invert the sense of the “Charged” output.
-
As a test I left the stalker running the sketch over night (8 hours) with no USB power and the voltage dropped from 4.12v o 4.06v. The RAW value fell from 212 to 210. (My battery is a 1000mAh, marked as 3.7v). When the USB power was removed the green LED extinuished, but the sketch continued to report “charged”.
When I have more time I would like to run the sletch for several days to discharge the battery further. I will also be trying to recharge the battery with a solar cell attached to the stalker, but thats perhaps another story (thread)
Here’s the output of the modified sketch. (The number at the start of each line is the time in mins from startup)
15 Battery voltage is 4.10V, ADvalue: 212, Pin#: 21, Charging: FALSE, Charged: TRUE
30 Battery voltage is 4.10V, ADvalue: 212, Pin#: 21, Charging: FALSE, Charged: TRUE
45 Battery voltage is 4.10V, ADvalue: 212, Pin#: 21, Charging: FALSE, Charged: TRUE
60 Battery voltage is 4.10V, ADvalue: 212, Pin#: 21, Charging: FALSE, Charged: TRUE
75 Battery voltage is 4.10V, ADvalue: 212, Pin#: 21, Charging: FALSE, Charged: TRUE
90 Battery voltage is 4.10V, ADvalue: 212, Pin#: 21, Charging: FALSE, Charged: TRUE
105 Battery voltage is 4.10V, ADvalue: 212, Pin#: 21, Charging: FALSE, Charged: TRUE
120 Battery voltage is 4.10V, ADvalue: 212, Pin#: 21, Charging: FALSE, Charged: TRUE
135 Battery voltage is 4.10V, ADvalue: 212, Pin#: 21, Charging: FALSE, Charged: TRUE
150 Battery voltage is 4.10V, ADvalue: 212, Pin#: 21, Charging: FALSE, Charged: TRUE
165 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
180 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
195 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
210 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
225 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
240 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
255 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
270 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
285 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
300 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
315 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
330 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
345 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
360 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
375 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
390 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
405 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
420 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
435 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
450 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
465 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
480 Battery voltage is 4.08V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
495 Battery voltage is 4.06V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
510 Battery voltage is 4.06V, ADvalue: 211, Pin#: 21, Charging: FALSE, Charged: TRUE
525 Battery voltage is 4.06V, ADvalue: 210, Pin#: 21, Charging: FALSE, Charged: TRUE
540 Battery voltage is 4.06V, ADvalue: 210, Pin#: 21, Charging: FALSE, Charged: TRUE
555 Battery voltage is 4.06V, ADvalue: 210, Pin#: 21, Charging: FALSE, Charged: TRUE
and here’s the sketch
const int batteryVoltagePin = A7; // Analog input pin battery voltage is connected to
const int chargedPin = 7; //Digital pin 0 == charged
const int chargingPin = 6; //Digital pin 0 == charging
int mins;
void setup ()
{
Serial.begin(57600);
}
void loop ()
{
int i = 0;
int charging = 1;
int charged = 1;
mins = mins +15;
float batteryVoltage = 0;
Serial.print (mins);
Serial.print(" Battery voltage is ");
Serial.print(analogRead(batteryVoltagePin) * 0.00322265625 * 6);
Serial.print("V, ADvalue: “);
Serial.print(analogRead(batteryVoltagePin));
Serial.print(”, Pin#: ");
Serial.print(batteryVoltagePin);
charging = digitalRead(chargingPin);
Serial.print(", Charging: ");
if(charging == LOW)
{
Serial.print("FALSE");
}
else
{
Serial.print("TRUE");
}
charged = digitalRead(chargedPin);
Serial.print(", Charged: ");
if(charged == LOW)
{
Serial.print("TRUE");
}
else
{
Serial.print("FALSE");
}
Serial.println("");
delay(900000);
}