Electrical – Arduino solar panel watt meter values reading 0’s

arduinocircuit-designwatts

I've been building a Arduino Watt meter for the past few weeks for a solar panel, and have successfully measured voltage and current separately. However I need to know both to calculate watts but can't seem to get the circuit I have working. I've attached the circuit I've attempted to build as well as a picture of the schematic I've followed. I only get 0's coming from this setup, which isn't helpful. If someone can see what is wrong with my circuit setup or schematic and point me in the right direction, I would be ecstatic.

The only difference between my setup and the schematic is the voltage divider, where I divide the voltage by a factor of 5 to keep the Arduino from frying. I'm also using the acs712 instead of the acs715.

The red wire going out of the picture goes to the positive end of the solar panel, the white wire with black tape going off screen goes to the negative end of the solar panel.
enter image description here

Circuit Schematic

//#include SoftwareSerial.h
float sensorVals[] = {0};


void setup() {
  Serial.begin(9600);
}

void loop() {
  float sensorVolt = analogRead(A0);
  float sensorVolt2 = analogRead(A1);
  float sensorCurrent = analogRead(A5);

  float amp = sensorCurrent * (5.0 / 1023.0);
  float voltage = sensorVolt * (5.0 / 1023.0);

  sensorVals[0] = voltage;
  sensorVals[1] = amp - 2.51;

  // print out the value you read:
  Serial.print(sensorVals[0]);
  Serial.print(", ");
  Serial.println(sensorVals[1]);

  delay(1000);
}

Best Answer

Note that this declaration:

float sensorVals[] = {0};

actually declares an array of one float, while you want 2.
Change it to

float sensorVals[2] = {0};

or

float sensorVals[] = {0, 0};


Also, your 110K + 50K voltage divider might not be appropriate - 12V solar panels could easily output much higher voltage (I got one rated 12V but outputting 20+V with no load in good sunlight). Just to be safe, measure its open circuit no-load voltage under best sunlight and then adjust your voltage divider so it will drop that voltage (+ some safety margin) to a voltage < your VCC.
Speaking of VCC, unless it is regulated 5V your analog readings will be quite incorrect - (5.0 / 1023.0) is only correct if VCC is 5V (or to be precise, if AREF is 5.0V).
Also, do you have common ground between Arduino and the solar panel? I am a bit confused by the label "Arduino ground" in your schematic. I think they should share ground for your voltage readings to work properly.
And finally, at least in my experience, these hall-effect current sensors are quite unreliable at low currents (e.g. < 100ma). It might be just mine though. Just in case, measure their output with a multimeter or even better with an oscilloscope, just to make sure they work as you expect.