All Power Labs energy monitoring setup
This is an implementation of the mains AC energy monitoring arduino code to monitor the output of the All Power Labs 10kW power pallet, which is a 2 Leg single phase system.
Download the library EnergyMonitor2CT.tar.gz (analogRead version)
Download the library AllPowerLabsEnergyMonitor2CT.tar.gz (ADC_ReadChanSync version)
Browse software in repository : software repository
All Power Labs Power pallet code at github : KS_Engine3
Stand alone example sketch
#include <EnergyMonitor2CT.h> // Energy monitoring library EnergyMonitor emon; // Create instance of energy monitor #define ANA_V 5 // Voltage pin defenition #define ANA_CT_LEG1 3 // Current Leg 1 pin #define ANA_CT_LEG2 4 // Current Leg 2 pin void setup() { //--------------------------------------------------------------------------------- // Setup the energy monitoring //--------------------------------------------------------------------------------- emon.setPins(ANA_V, //Set Voltage analog input ANA_CT_LEG1, //Set CT analog input 1 ANA_CT_LEG2 //Set CT analog input 2 ); //Calibration coeficients (ref/calculated * calib. coefficient) emon.calibration(1.744746, //Voltage calibration 0.103164, //CT Leg 1 calibration 0.103256, //CT Leg 2 calibration 2.3 //Phase offset- add two for I1 and I2. found by matching w/code. //shifting value and hitting calibrated power factor. ); //--------------------------------------------------------------------------------- Serial.begin(9600); } void loop() { //---------------------------------------------- // Do the energy monitoring //--------------------------------------------- emon.calc(1, // number of wavelengths to sample 45, //minimum frequency 55 //maximum frequency ); //---------------------------------------------- // Print away //--------------------------------------------- Serial.print(emon.frequency); Serial.print(' '); Serial.print(emon.Vrms); Serial.print(' '); Serial.print(emon.Irms1); Serial.print(' '); Serial.print(emon.Irms2); Serial.print(' '); Serial.print(emon.realPower1); Serial.print(' '); Serial.print(emon.realPower2); Serial.print(' '); Serial.print(emon.apparentPower1); Serial.print(' '); Serial.print(emon.apparentPower2); Serial.print(' '); Serial.print(emon.powerFactor1); Serial.print(' '); Serial.println(emon.powerFactor2); delay(50); }