Solar Panel Voltage Reading

I'm a beginner with electronics, and thus if the question seems idiotic, I apologize. But, assuming the voltage will be less than 5v, how do I hook a solar panel to the analog input pin to read its voltage? I'm attempting to log the data and efficiencies of different brands/types of solar panels for a project. Thanks for any help!

Connect the negative lead to GND on the Arduino.
Connect the positive lead to Analog Input 0 (or another open input).

Given what you are trying to do it would be best to connect each one to a different input so they could be read nearly simultaneously under identical conditions.

Also you should connect each to an identical load (a resistor or small dc motor). Merely comparing voltages isn’t the best way. You need to compare output power (watts) as that tells you how much work you can do with energy from the solar cell.

For example, if you hook two cells in parallel their voltage will be the same yet they can do twice the amount of work.

All that was very good advice and exactly what I was looking for. Thank you both for your responses.

Hi, I was also doing a similar experiment recording voltage from solar panels with an Arduino Duemilanove. I was wondering what I would need to change if trying to record with the digital inputs rather than the analog inputs.

) You can use an external Analog to Digital Converter (ADC). It is not clear why anyone would want to do this, since the ADC function is built-in to the Arduino.

I was wondering about the digital input because I might be using up all of the available analog inputs and would therefore have to use the digital inputs. I will look into ADCs then.

So I have now for my experiment recording voltage with solar cells an Arduino Duemilanove with a microSD shield and a 16 channel multiplexer breakout board. This is the code for it so far. When testing the digital pins with a voltmeter for if the voltage is alternating high/low correctly digital pin 2 is alternating high/low voltage as it should, but digital pin 3 is just staying low when theoretically it should be alternating every two seconds. It is not the pin itself so I’m not sure what is wrong with the programming. Here is the code.

#include <SdFat.h>
#include <SdFatUtil.h> 
#include <ctype.h>

int r0 = 0;
int r1 = 0;
int r2 = 0;
int r3 = 0;
int r4 = 0;
int row = 0;
int count = 0;
int bin [] = {00000, 00001, 00010, 00011, 00100, 00101, 00110, 00111, 01000, 01001, 01010, 01011, 01100, 01101, 01110, 01111};

Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;

char name[] = "Test.txt";
char contents[32];
char contents2[32];
char contents3[32];
char in_char=0;
int index=0;
int voltage=0;

void setup(){
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(10, OUTPUT);

void loop(){
  for (count=0; count<=15; count++)  {
    row = bin[count];
    r0 = (row>>0) & 0x01;
    r1 = (row>>1) & 0x01;
    r2 = (row>>2) & 0x01;
    r3 = (row>>3) & 0x01;
    r4 = (row>>4) & 0x01;
    digitalWrite(2, r0);
    digitalWrite(3, r1);
    digitalWrite(4, r2);
    digitalWrite(5, r3);
    digitalWrite(10, r4);
    voltage = analogRead(0);
    //Serial.println(voltage);, name, O_CREAT | O_APPEND | O_WRITE);
    sprintf(contents, "%d   ", millis());
    sprintf(contents2, "%d  ", voltage);
    sprintf(contents3, "%d  ", count);
    strcat(contents, "\t");
    strcat(contents3, "\t");
    strcat(contents2, "\r");
    strcat(contents, contents3);
    strcat(contents, contents2);

Scottft, I'd also move the and close() outside of the for loop..

int bin [] = {00000, 00001, 00010, 00011, 00100, 00101, 00110, 00111, 01000, 01001, 01010, 01011, 01100, 01101, 01110, 01111};

Can you explain what you’re doing with these octal constants, please?

[edit]Oh! I get it.

const byte ledPin [] = {2,3,4,5,10};
for (int i = 0; i < (sizeof (ledPin) / sizeof (ledPin[0]; ++i) {
  pinMode(ledPin [i], OUTPUT);
for (int i = 0; i < (sizeof (ledPin) / sizeof (ledPin[0]; ++i) {
  digitalWrite (ledPin [i], (count >> i) & 1);