Calculating Real Power On An Arduino
Calculating Real Power On An Arduino
{
// inst_current calculation from raw ADC input goes here.
squared_current = inst_current * inst_current;
sum_squared_current += squared_current;
}
mean_square_current = sum_squared_current / number_of_samples;
root_mean_square_current = sqrt(mean_square_current);
Apparent power
apparent_power = root_mean_square_voltage * root_mean_square_current;
As RMS voltage is generally a fixed value such as: 230V (+10% -6%
in the UK). It's possible to approximate apparent power without
making a voltage measurement by setting the RMS voltage to 230V.
This is a common practice used by commercially available energy
monitors.
Power factor
power_factor = real_power / apparent_power;
EmonLib
We have packaged these calculations into an Arduino library called
EmonLib to simplify Arduino energy monitor sketches. The library
can be found on github
here: https://github.com/openenergymonitor/EmonLib
Next: AC Power Theory - Advanced maths - The code snippets
on this page are expressed in strict mathematical terms.