# ADS1115 to measure 12v SLA

I want to measure between 11V - 14V using an ADS1115 4-channel ADC. In order to keep it's input voltage within limits, I'm dividing the SLA voltage by 5 using a potentiometer. Currently it's 500K. It isn't working very well - wth around 2V errors and inconsistently so, and I'd appreciate any help you can offer.

I'm using a 500K pot because this is across the supply all the time and it's a solar application and I want tiny current drain. I considered switching it in and out under program control but it might be very inaccurate. I started with a 2M pot but came down to 500K becuase of this problem. Is there a better way to do this?

1. The input impedance of this ADC is about 6M. Is the 500K pot causing a problem here? I can't see how to do the analysis.

2. I am using the ADS1115 in its default gain mode, where one count = 0.1875mV, so I'm converting the raw integer returned as Vout = ADCcount x 5 x 0.1875 / 1000 Volts. x5 is because the pot divides the real voltage by 5. Does that seem correct?

3. On the 'scope I'm seeing some noise on the ADC input pin, around 50KHz @ 0.2mV - which correlates with Serial output, but I think this cannot account for the problem I'm seeing.

4. With constant input voltage the ADC count is around 17000 +/- 3 for most of the time, but +60 about 20% of the time. I can't find the cause of this. It's not regular. Any ideas? Even so, I could tolerate that error - but not the 2V I'm seeing. And yes, I can fudge the code to get the right answer but that only works over a small range of voltages and is in any case, a cop-out.

Perhaps of relevance, is that my 'scope probe, when applied to the ADC pin, drops the measured voltage which the ADC reports dramatically. I assume my (old, analog) scope has a high input impedance, and I suppose this is telling me something, but I'm not sure what.

Thanks

An A/D needs to see a “solid” (= low impedance) source to sample from.
Try a 100n cap from A/D input to ground.

http://jeelabs.org/2013/05/16/measuring-the-battery-without-draining-it/

Arduino’s A/D with 1.1volt Aref enabled and a bit of oversampling is good enough for lead/acid battery voltage measurements. Voltage only is not a very good indicator of SOC (state of charge).
You need a coulomb counter for that. An INA219 breakout board could be a good start.
Don’t go overboard with too high resistor values. Lead/acid batteries have a high self-discharge current.
Try this sketch.
Leo…

``````/*
0 - ~16volt voltmeter for 3.3volt and 5volt Arduinos
uses the stable internal 1.1volt reference
6k8 resistor from A0 to ground, and 100k resistor from A0 to +batt
100n capacitor from A0 to ground for stable readings
(100k + 6k8) / 6k8 = 15.70588 | used in formula
*/
float Aref = 1.075; // ***calibrate here*** | change this to the actual Aref voltage of ---YOUR--- Arduino
unsigned int total; // can hold max 64 readings
float voltage; // converted to volt

void setup() {
analogReference(INTERNAL); // use the internal ~1.1volt reference  | change (INTERNAL) to (INTERNAL1V1) for a Mega
Serial.begin(9600); // set serial monitor to this value
}

void loop() {
for (int x = 0; x < 64; x++) { // multiple analogue readings for averaging
total = total + analogRead(A0); // add each value to a total
}
voltage = (total / 64) * 15.70588 * Aref / 1024 ; // convert readings to volt
// print to serial monitor
if (total == (1023 * 64)) { // if overflow
Serial.print("voltage too high");
}
else {
Serial.print("The battery is ");
Serial.print(voltage);
Serial.println(" volt");
}
total = 0; // reset value
delay(1000); // one second between measurements
}
``````

Hello Leo and thanks for your very helpful response. I used to know the capacitor trick but I get dumber as the years roll by. Some interesting other possibilities too, from the links you sent me.

Thanks once again, Chris