Inconsistent readings via voltage divider

Hi,

I have setup a simple Voltage divider. I worked on 24Vin(max) and 5 Vout(max) with a current of 100uA. I worked out R1 = 47 kohm and R2 = 220 kohm. I measures the resistance of the resistors so the actual values are R1 = 45 kohm and R2 = 193 kohm.

The Vin is supplied by a solar panel, currently the voltage is 14.3V, Vout is 2.53, so the voltage divider is working fine.

I connect the Duemilanove, I have connect pin 0 to Vout. My sketch is as follows:
int SensorPin = 5;
int LEDPin = 13;
int reading = 0;

void setup ()
{
Serial.begin(9600);
pinMode(LEDPin, OUTPUT);

delay(500);
}

void loop ()
{
digitalWrite(LEDPin, HIGH);
reading = analogRead(SensorPin);

float voltage = (reading * 0.0048828125);
float SolarVoltage = (voltage * 4.8);

Serial.print ("Reading = ");
Serial.println (reading);
Serial.print ("Voltage = ");
Serial.println (voltage);
Serial.print ("Solar Voltage = ");
Serial.println (SolarVoltage);

delay (100);

Serial.println ("");
digitalWrite(LEDPin, LOW);

delay (5000);
}

The readings I get vary drastically, yet the voltage as displayed by the voltage meter does not, it remains constant. So I am rather perplexed how the Duemilanove is reading such extreme readings. Example of the reading are, the voltage meter is displaying 14.31 to 14.36 :

Reading = 1023
Voltage = 5.00
Solar Voltage = 23.98

Reading = 69
Voltage = 0.34
Solar Voltage = 1.62

Reading = 893
Voltage = 4.36
Solar Voltage = 20.93

Reading = 687
Voltage = 3.35
Solar Voltage = 16.10

Reading = 524
Voltage = 2.56
Solar Voltage = 12.28

Reading = 873
Voltage = 4.26
Solar Voltage = 20.46

Reading = 0
Voltage = 0.00
Solar Voltage = 0.00

Reading = 861
Voltage = 4.20
Solar Voltage = 20.18

Reading = 394
Voltage = 1.92
Solar Voltage = 9.23

Reading = 702
Voltage = 3.43
Solar Voltage = 16.45

Can someone please point me in the correct direction ?

Regards
Gregg

I connect the Duemilanove, I have connect pin 0 to Vout. My sketch is as follows:

int SensorPin = 5;

Shouldn't it be connected to (analog in) 5?

Hi,

I have tried pin 5 and pin 1. They all give me the same inconsistent readings.

Gregg

Is the voltage divider ground connected to the Arduino's ground?

yep, be sure your grounds are connected - something to check for.

I'm not sure how important this is but I have read the Arduino likes a max of 10K impedance on the Analog inputs. I see you have over 200K?

Just as a test, try R2 (voltage to ground) as 2.1K with R1 (series) as 7.87K - or somewhere in those ranges.

Of course the 4.8 would have to be recalculated.

Just something to check - good luck.

Ken H>

Hi,

If I connect the voltage divide to the Ground of the arduino, then the voltage divide does not seem to work Vin = Vout = 6.46V. If the Voltage divide is connected to the ground of the pannel Vin = 6.46V and Vout = 1.35V.

I tried using 6.8K and 1.8K for the voltage divide, but it does the same. Readings:
Reading = 218
Voltage = 1.06
Solar Voltage = 5.11

Reading = 959
Voltage = 4.68
Solar Voltage = 22.48

Reading = 44
Voltage = 0.21
Solar Voltage = 1.03

Reading = 1023
Voltage = 5.00
Solar Voltage = 23.98

Reading = 128
Voltage = 0.63
Solar Voltage = 3.00

Reading = 305
Voltage = 1.49
Solar Voltage = 7.15

I think I got it working. I connected the two grounds together (Ground of the arduino and Ground of the Panel) , then connected that to the "Bottom" of the voltage divide. So far it seems that it is working. So now the question is why: Why does it work when the two grounds are connect together ? Why does it not work using only the ground of the panel or the ground of the arduino only ?

Why does it not work using only the ground of the panel or the ground of the arduino only ?

This is quite fundamental. A voltage potential is seen only when there is a complete circuit path between the positive and ground ( I like the term common better then ground) terminals from the voltage source.

In your case the solar panel is the voltage source and the voltage divider must be wired to both the positive and ground terminals from the solar panel. This makes a complete circuit and you can then measure the voltage output of the resistor divider string by measuring from the center node of the resistors to the bottom connection (solar ground). However the Arduino also requires a complete circuit to measure this divided voltage source, so just having one wire from the center of the voltage divider to the Arduino analog input pin does not make a complete circuit without also a wire from the Arduino ground pin to the bottom of the voltage divider.

It would be like trying to wire a single cell battery to a small lamp with just one wire and expecting the lamp to light up. :wink:

Lefty

Hi Gregg,

Can you share the circuit diagram and the final sketch for the same.

Thanks
dufferdev

Why does it work when the two grounds are connect together ?

See the diagram at:-
http://www.thebox.myzen.co.uk/Tutorial/Power_Supplies.html