ARDUINO CODE FOR ZMPT101B AC VOLTAGE SENSOR CALIBRATION FOR THREE PHASE POWER SUPPLY VOLTAGE MEASUREMENT
- Get link
- X
- Other Apps
This video shows the Arduino programming used in calibration of you ZMPT101B for three phase power supply voltage measurement
ARDUINO CODE DESCRIPTION
#include <Filters.h> //Easy library to do the calculations
#include <SPI.h> //Libraries for display
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
float testFrequency = 50; // test signal frequency (Hz)
float windowLength = 40.0 / testFrequency; // how long to average the signal, for statistist
int Sensor1 = 0; //Sensor analog input, here it's A0
int Sensor2 = 0; //Sensor analog input, here it's A1
int Sensor3 = 0; //Sensor analog input, here it's A2
float intercept = -0.04; // to be adjusted based on calibration testing
float slope = 0.0405; // to be adjusted based on calibration testing
float current_Volts1; // Voltage1
float current_Volts2; // Voltage2
float current_Volts3; // Voltage3
unsigned long printPeriod = 2000; //Refresh rate
unsigned long previousMillis = 0;
// Create lcd object of class LiquidCrystal_I2C:
LiquidCrystal_I2C lcd = LiquidCrystal_I2C (0x27, 16, 4);
void setup() {
Serial.begin( 9600 ); // start the serial port
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
delay(1000);
}
void loop() {
lcd.setCursor(0, 0);
lcd.print("INNOVATIVE MIND");
lcd.setCursor(0, 1);
lcd.print("VOLT_PHASE 1:");
lcd.setCursor(0, 2);
lcd.print("VOLT_PHASE 2:");
lcd.setCursor(0, 3);
lcd.print("VOLT_PHASE 3:");
RunningStatistics inputStats1; //Easy life lines, actual calculation of the RMS requires a load of coding
inputStats1.setWindowSecs( windowLength );
RunningStatistics inputStats2; //Easy life lines, actual calculation of the RMS requires a load of coding
inputStats2.setWindowSecs( windowLength );
RunningStatistics inputStats3; //Easy life lines, actual calculation of the RMS requires a load of coding
inputStats3.setWindowSecs( windowLength );
while ( true ) {
{
Sensor1 = analogRead(A0); // read the analog in value in phase 1:
inputStats1.input(Sensor1);
} // log to Stats function
{
Sensor2 = analogRead(A1); // read the analog in value in phase 2:
inputStats2.input(Sensor2); // log to Stats function
}
{
Sensor3 = analogRead(A2); // read the analog in value in phase 3:
inputStats3.input(Sensor3); // log to Stats function
}
if ((unsigned long)(millis() - previousMillis) >= printPeriod) {
previousMillis = millis(); // update time every second
Serial.print( "\n" );
current_Volts1 = intercept + slope * inputStats1.sigma(); //Calibartions for offset and amplitude
current_Volts1 = current_Volts1 * (78.30); //Further calibrations for the amplitude
Serial.print( "\tVoltage1: " );
Serial.print( current_Volts1 ); //Calculation and Value display is done the rest is if you're using an OLED display
lcd.setCursor(14, 1);
lcd.print(current_Volts1);
lcd.setCursor(14, 2);
lcd.print(current_Volts2 );
lcd.setCursor(14, 3);
lcd.print(current_Volts3);
current_Volts2 = intercept + slope * inputStats2.sigma(); //Calibartions for offset and amplitude
current_Volts2 = current_Volts2 * (78.30);
Serial.print( "\tVoltage2: " );
Serial.print( current_Volts2 ); //Calculation and Value display is done the rest is if you're using an OLED display
current_Volts3 = intercept + slope * inputStats3.sigma(); //Calibartions for offset and amplitude
current_Volts3 = current_Volts3 * (78.30);
Serial.print( "\tVoltage3: " );
Serial.print( current_Volts3 ); //Calculation and Value display is done the rest is if you're using an OLED display
}
}
}
Hi guys if you run the code above and is show "RunningStastitics not declare" you can download the Filter-Master from that links, it is .zip file. Add it to your list of library on arduino IDE and it will solve the problem.
Regards please follow me on youtube
- Get link
- X
- Other Apps
Comments
you did it well sir, can i have your arduino library sir? i have problem while running it "RunningStatistics is not declare". What arduino libs you include so it can work?
ReplyDeletehttps://github.com/JonHub/Filters you can download the library through that link
Delete