analogRead() value doesn't change connected/disconnected

I’m trying to figure out how to use analogRead to read a voltage on a lipo battery so I can monitor it’s charge state. I also have one connected to a solar panel I’m using to charge it. While the battery only gets up to 4.1v, the solar panels can push up above 7v so to make things easier and to minimize any current drain, I connected both of them to 2x22k voltage dividers. (I’m hoping to monitor a battery pack and it’s solar charger used to power a Raspberry pi A+)

I have already tested it on another device with a voltage divider and got it working fine on it, but since I added a couple of ACS712 current monitors to other parts of the system, and a DHT11 just for chits and giggles, I figured I would try moving the voltage monitors over to the arduino analog pins as well.

But it seems that no matter what I try, I can’t seem to get a good read on the voltage on either of the two pins. The values even seem to not change if I connect or disconnect the pins. I’ve narrowed my code down to the bare minimum and while I would be expecting values back in the 500 range, I realized it wasn’t working because the solar will fluctuate considerably when the light on it changes - and it doesn’t.
So I started connecting different voltages to each, plugging and unplugging, but the values returned never really vary much from 500 give-or-take 30.

I now have the code down to a bare minimum to make sure I had everything right and still no luck:

void setup()
  pinMode(A0,INPUT); // battery divider
  pinMode(A1,INPUT); // solar divider
  pinMode(A2,INPUT); // benchmark (not connected)
  pinMode(A3,OUTPUT); // benchmark (not connected)


void loop()
  for(int i = 0; i<4; i++) {

void readAnalogVolts(int pinNum)
  Serial.print("Reading analog pin ");

  int val = analogRead(pinNum);
  Serial.print(" : value = ");

  float volts = val * 4.92 / 1024; // vcc measured with meter at 4.92v
  Serial.print("\tvolts = ");

the floating values on the other pins are similar to the values on 0 and 1 and unplugging seems to make no significant change to the values. As mentioned, I know the dividers work because they were already connected on another system (pi plate) and I’ve double checked with the meter to make sure they are still working as designed. (22k per side output to ground, 44k across the two output pins, 0 from ground to ground)

I’ve tried it on both a pro-mini and on a leonardo. (I have an uno here also, but have been doing most of the testing on the leonardo as I hope to now connect it to the pi via USB. Any help is greatly appreciated.

The program works OK on my Uno and gives the expected results but I am confused by the description of your circuit. Can you please provide a drawing or photo of it.

I ended up getting it working but I'm still not entirely sure what I did differently. There's not really a lot complex of what I'm doing. I'm just using a voltage divider across the battery and solar +/- in parallel (as per many examples on the net) using 22kohm per side on the divider to keep drain to a minimum. Then I'm using an ACS712 in series with each high side to read the amperage.

Again, I'm not sure what I did wrong the first time but in the process of testing I replaced some of my connectors so maybe I just had really bad luck and ended up somehow with two separate 'open' lines on each lead just to confuse the crud out of me.

just using a voltage divider across the battery and solar +/- in parallel

I am still not clear how your circuit is wired.

Generally speaking people use a voltage divider to scale voltages going into the arduino pin since an analog pin can only read up to or just below the Vcc input voltage within the tolerance of the hardware. (read: 0-5v on a normal arduino, 0-3.3v on the 3.3v pros)
Thus if you want to read a voltage above 5v, you want to use ohm's law with resistors to 'scale' the voltage down to between 0-5v for whatever the actual range is of the circuit being tested. This is also a useful thing to do for other reasons though. While there is some loss in precision of the measurement when you scale down due to the number of decimals available on the analog pin readings, adding a voltage divider has two other immediate benefits: 1) it limits the amount of current used by the voltage testing since it is pretty much going to be an 'always on' part of the circuit, and 2) it provides a protection for your arduino pins themselves to avoid damage from over-voltage.
There are plenty of examples of voltage dividers on the internet. It basically creates a 'loop' between the + and - with two resistors of varying sizes depending on how much you want to scale and how much you want to limit the current. The sensor pin is attached between the two resistors. I found 22k resistors two suit my needs creating a shorted loop between + and - that was 44k ohms total from the arduino/power perspective, and 22k ohms from the sensor pin's perspective. This scaled my 0-18v range down to somewhere between 0-4v on the pin.
I used a combination of variable power supplies and battery packs to test it from 1.5v through 18v to get an idea of the 'scaling' value. Testing across the range is helpful because sometimes the arduino hardware and/or whatever you are testing may require an 'offset' due to some resistance being in that portion of the circuit as well. (i.e. you may get a 2.1 ratio at lower voltages and 1.8 ratio at higher just as an example. I don't have the formula in front of me for testing the offset, but I recall it wasn't hard to derive and there are examples of that on the net as well)