Electronic – arduino – Separate voltage and current from regulated DC power supply

arduinocurrent measurementmpptvoltage measurement

I am currently doing a MPPT(Maximum Power Point Tracking) using Arduino UNO.
So far I have pretty much almost finished the coding. When I was about to test my program using a regulated DC power supply, it suddenly occurred to me that I had done things wrongly. How was my circuit going to detect/read the voltage and current values?

Regarding this, I do not know how I can let my Arduino circuit detect the current and voltage values separately on each analog input. I would be using the current and voltage value (pv_I and pv_Vnew) to multiply them together to obtain the power value.

My problem is that I need help with the hardware, getting the voltage and current values into the ADC I hope someone can help me with this problem.

If it helps, this below is a part of my code where i do the multiplying and stuff.

float pv_I; //input current
float pv_Vnew; //input voltage

void reading(void)
{
  pv_I = analogRead(A0);     //This is the area that is in question
  pv_Vnew = analogRead(A1);  //This is the area that is in question

  reading_value[0] = pv_I;
  reading_value[1] = pv_Vnew;

  Serial.print("Current, Voltage: "); //Start of string

  for(int i = 0 ; i < 2 ; i++)
  {  
    Serial.print(reading_value[i]);  
    Serial.print(", "); // Seperate each value with ',' to identify them seperately
  }

  Serial.println(" END"); // End of string
  delay(500);

}

void PowerCalculation(void)
{
  tempPower = pv_I * pv_Vnew;
  pv_NewP = tempPower;

  Serial.print("Calculated Power: ");
  Serial.println(pv_NewP);
}

Best Answer

As alluded to in the comments, your code implicitly assumes both a voltage representing the load voltage and a voltage representing the load current.

Assuming that the load voltage is less than the UNO input maximum, your circuit can look like

schematic

simulate this circuit – Schematic created using CircuitLab

If you make RSense at least 100 times smaller than RLoad, the error introduced will to "Voltage" will be less than 1%. This means, of course, that you wil have to pick R3 and R4 to give adequate gain so that "Current" is usable small. You will also have to keep careful track of stray ground resistances so that you correctly read the current-induced voltage, since RSense will be small and small errors in the ground resistance will make a difference.

If it is important to you that your load be grounded, then

schematic

simulate this circuit

is what you want. Note that the op amp is replaced with a differential amp with a fixed, known gain. The biggest problem that you will probably face is that the load voltage may well be too high for the UNO, and this will also cause problems with providing appropriate supply voltages to the diff amp so that you don't overdrive the inputs (common mode voltage too high).