AnalogRead() gives the half of the voltage that the multimeter gives

Hi everyone,

I want to measure the amount of power provided by a solar panel by this circuit. I'll break the 20V voltage of panel to about its fifth to become less than 5 volts and then, try to read it with analogRead() but, the number that the code shows is somehow the exact half of the number that the multimeter shows. How can I find the real voltage that the multimeter shows by Arduino analogRead()?

The two resistors that break the whole voltage of the panel are R and 4R and the - port of the panel is connected to the Arduino's GND. Port A14 Reads the voltage of a point between R and 4R. The order of the circuit is as follows: Port "-" of the panel -----> resistor R -----(A14)----->resistor 4R------> Port "+" of the panel.

The Arduino that I use is Arduino Mega 2560.

You need to condition the value of analogRead() by appropriate gain and offset factors which must be determined by two-point measurements known as calibration.

What value are the voltage divider resistors and how much current flows through them ?

Please post the program that you are using to measure the voltage

(deleted)

isn't R/ (R+4R) 1/5. so wouldn't your 20V be dropped to 4V?

and the max analogRead() value will be the voltage at the Aref pin. it may not be 5V

Post your code.

Are your R values so small that they are overloading and dragging the voltage of your PV cell down?
What is the short circuit current rating of said cell?

UKHeliBob:
What value are the voltage divider resistors and how much current flows through them?

Please post the program that you are using to measure the voltage

R=80 ohms and consequently the 4R=320 ohms
the current is about 0.65 amps.
the code is long so I would mention a shortened version of it:

int i;
float v1,V1;

void setup () {
Serial.begin(9600);
}
void loop () {
float v1t=0;

for(i=0;i<500;i++){ //// I reread the value for 500 times to minimize any error

v1=analogRead(A14);
delay(5);

v1t=v1t+v1;
}

v1=v1t/500.0;

V1=v1/1023.0*5.0;

}

now the V1 value is contradictory with multimeter value and is about half its size.

spycatcher2k:
Put a know voltage across your voltage divider : E.G. 5V 10V 20V and post the raw analogRead value you get for each. This will give you the actual reading for each, it's very basic maths when you have these values.

I have done that with Arduino's 5v port. It gave me the right numbers and equal to the multimeter.

JCA34F:
Are your R values so small that they are overloading and dragging the voltage of your PV cell down?
What is the short circuit current rating of said cell?

I have chosen them to cause the maximum power provided by the panel. Isc is about 1 amp.

GolamMostafa:
You need to condition the value of analogRead() by appropriate gain and offset factors which must be determined by two-point measurements known as calibration.

I have added the code. would you give me an example of what you mean?
I have tested the code by connecting the circuit to the 5v port of Arduino and it resulted in the right numbers and equal to the multimeter but I do not understand why the code result becomes half of the multimeter when it is connected to the solar panel.

gcjr:
isn't R/ (R+4R) 1/5. so wouldn't your 20V be dropped to 4V?

and the max analogRead() value will be the voltage at the Aref pin. it may not be 5V

yes, I would be dropped to 4 volts and as I have mentioned "less than 5". sometimes the PV voltage would exceed 20v (based on the resistors implemented on the board) so the dropped voltage would exceed 4v too.

I have connected nothing to Aref port so wouldn't it be 5v?

Seems like a good reference to your project. Pay particular attention to the difference in R values.

In your setup with just 400ohms of resistance to ground, your wasting a lot of power for a power monitor circuit.

Post your schematic

Your circuit diagram doesn't show Arduino Ground connected to Panel Minus. It should be,

Hello johnwasser

johnwasser:
Your circuit diagram doesn't show Arduino Ground connected to Panel Minus. It should be,

Strange : I can see it.

Regards,
bidouilleelec

Hello danial_borooghani

danial_borooghani:
the current is about 0.65 amps.

The courant across what ?

Regards,
bidouilleelec

Without going too far, into it, I do the same measurement of a 25V circuit with 47K / 10K to get the divider with minimal source current wasted.

You can't get it wrong
vSense.jpg
4 mA burden on the source
No tricks,just a simple analogRead().

I also average the readings over time to get a stable value wrt the source.

vSense.jpg

I tried your code with a 3.3V input on A14 and it showed ~3.29V on the serial monitor. Are you "doubly-sure" about your meter readings and the ground reference?

bidouilleelec:
Post your schematic

I have it as an attachment on my first post.