This is a power monitor project for my off-grit solar panel and battery setup.
The solar panel if of the 200W class and specs are given with
- max. V = 18,1V
- max. Current = 11,06A|
The solar panel will go to a solar charge controller EcoFlow Delta 2. As I am interested in voltage and current on the panel side, i think this might be not that important.
I am aware that there are more elegant ways to do this, as far as components are concerned, but these are the parts I have. I got:
- Nano board
- ACS712
- 0-25V DC Voltage Sensor Module
My schematics is like this:
- Of course, the 9V battery is just a place holder for the power station. Moreover, the power station has a panel where one can see the input power in Watt (without decimal places) for comparison.
- I read here in this post about combining the grounds in case of differences between the common leads and Arduino's ground. As there are none (at least not detectable by my multimeter) I leave it as it is.
This is the code:
//Globals
///DC-Measuring
int offset = 0;// set the correction offset value
//float volts = 0.00;
float volts = 0.00;
///Current-Measuring
const int nSamples = 1000;
const int adcMax = 1023;
const float vcc = 5.0;
float current = 0.0;
//const float sens = 0.185; // 5A
const float sens = 0.100; // 20A
//const float sens = 0.66; // 30A
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Avering multiple current meassurings from Sensor
float avg_current(){
float val = 0;
for (int i = 0; i < nSamples; i++) {
val += analogRead(A0);
delay(1);
}
return val / adcMax / nSamples;
}
void readingCurrent(){
current = (vcc / 2 - vcc * avg_current()) / sens;
}
void readingVoltage(){
int volt = analogRead(A2);// read the input
double voltage = map(volt, 0, 1023, 0, 2500) + offset; // map 0-1023 to 0-2500 and add correction offset
voltage /= 100; // divide by 100 to get the decimal values
volts=voltage; // found no other way to get this variable out of this funktion (making "voltage" global results in 0.
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
Serial.begin(115200);
Serial.println("Starting up PVMonitor_ErnaDash version: 0_2");
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
readingCurrent();
Serial.print("Current: ");
Serial.print(current);
Serial.println(" A");
readingVoltage();
Serial.print("Voltage: ");
Serial.print(volts); //print the voltge
Serial.println(" V");
Serial.print("Watt: ");
Serial.print(volts*current); //print the watt
Serial.println(" W");
}
The readings I observed are the following (roughly averaged):
- Reading Mulitmeter ~ 18.3 V
- Reading Sensor via Nano: ~19.1 V
- Reading ACS712 via Nano: ~2.8 A
- Calculated Watt via Nano: ~ 53,5W
- Reading Powerstation: ~45W
As can be seen, the values between the different methods are off. I am aware that the achievable precision is limited, but, I want at least try to bring down the differences as far as possible. I assume the most accurate instrument is the multimeter.
What can I improve here??
Thank you!!
1 post - 1 participant