3 Phase Voltage Monitoring Using ESP32 and 2 or more ZMPT101B

Hi there, I’m totally new here.
I am attempting to build 3 phase voltage monitoring with ZMPT101B sensors. The issue is that i can not write the code to make it read 2 or more analogue sensors.
I am using the ESP32 .

This is the code needed for the Voltage sensor

#include <Filters.h>

float testFrequency = 50;                     // signal frequency (Hz)
float windowLength = 40.0/testFrequency;     // how long to average the signal, for statistist

int Sensor = 0;                 

float intercept = -0.04;  // adjust untuk kalibrasi
float slope = 0.0964;   // adjust untuk kalibrasi
float current_Volts;      

unsigned long printPeriod = 1000;     //Refresh rate
unsigned long previousMillis = 0;

void setup() {
  Serial.begin( 9600 );
  Serial.println("AC Voltmeter");
  //delay(5000);
}

void loop() {
  
  RunningStatistics inputStats;               
  inputStats.setWindowSecs( windowLength );
   
  while( true ) {   
    Sensor = analogRead(A0);                // read the analog in value:
    inputStats.input(Sensor);                   // log to Stats function
        
    if((unsigned long)(millis() - previousMillis) >= printPeriod) {
      previousMillis = millis();                // update time every second
      
      current_Volts = intercept + slope * inputStats.sigma(); //Calibartions for offset and amplitude
      current_Volts= current_Volts*(49.3231);                //Further calibrations for the amplitude     
      
      Serial.print( "Voltage: " );
      Serial.println( current_Volts );
      
    }
  }

}

And this is i’m trying to do to read 2 analogue sensors

#include <Filters.h>


float testFrequency = 50;                     // signal frequency (Hz)
float windowLength = 100.0/testFrequency;     // how long to average the signal, for statistist

int Sensor1 = 0;                 
int Sensor2 = 0;                 

float intercept = 0;  // adjust untuk kalibrasi
float slope = 0.01245;   // adjust untuk kalibrasi
float Tegangan1;      
float Tegangan2;      


unsigned long printPeriod = 1000;     //Refresh rate
unsigned long previousMillis = 0;

void setup() {
  Serial.begin( 9600 );
  Serial.println("AC Voltmeter");
  //delay(5000);
}

void phase1() {
  RunningStatistics inputStats;               
  inputStats.setWindowSecs( windowLength );
  while( true ) {   
    Sensor1 = analogRead(34);                // read the analog in value:
    inputStats.input(Sensor1);                   // log to Stats function
        
    if((unsigned long)(millis() - previousMillis) >= printPeriod) {
      previousMillis = millis();                // update time every second
      
      Tegangan1= (intercept + slope * inputStats.sigma())*(49.3231); //Calibartions for offset and amplitude

      Serial.print( "Tegangan 1: " );
      Serial.println( Tegangan1 );
    }
  }
  delay(700);
}
void phase2() {
  RunningStatistics inputStats;               
  inputStats.setWindowSecs( windowLength );
  while( true ) {   
    Sensor2 = analogRead(35);                // read the analog in value:
    inputStats.input(Sensor2);                   // log to Stats function
        
    if((unsigned long)(millis() - previousMillis) >= printPeriod) {
      previousMillis = millis();                // update time every second
      
      Tegangan2= (intercept + slope * inputStats.sigma())*(49.3231); //Calibartions for offset and amplitude

      Serial.print( "Tegangan 2: " );
      Serial.println( Tegangan2 );
    }
  }
  delay(700);
}
void loop() {
  phase1();
  phase2();
  delay(1000);
}

Anyone can help?

Hi,
Can you read ONE sensor with the ESP32?
What controller is the first code for?
Have you tried the first code in the controller it was meant for?

I can see your have made two functions which is what I would do, but have you just got one to work?
What result do you get with your second code?

Can I suggest you also change the Serial.begin to 115200, its so much faster and 9600 is an old industrial standard.

Tom... :smiley: :+1: :coffee: :australia:

1 Like

Can you read ONE sensor with the ESP32?
Yes i can, i use first code and modified it with my preference

What controller is the first code for?
I use esp32 in all this project
Have you tried the first code in the controller it was meant for.
I did and it works

I can see your have made two functions which is what I would do, but have you just got one to work?
On the second code, it only read the first sensor
What result do you get with your second code?
It only read 1 sensor, the second sensor isn't appear

Pada tanggal Sab, 21 Mei 2022 12.32, TomGeorge Believes in the Lucas Smoke Theory. via Arduino Forum <arduino@discoursemail.com> menulis:

I see the ZMPT101B gives you the voltage
if you also require current I have found a SCT-013 current clamp suitable to monitor the three phase grid supply to the house

I assume you are using the ZMPT 101 B Module to offset the AC voltage so it is suitable for sampling with an Arduino ADC?

1 Like

Hi,
Can you please post a circuit diagram of your circuit?
Please include the 3phase supply, and component manes and pin labels.

Thanks.. Tom.... :smiley::+1: :coffee: :australia:

Hi guys, my code already working. Thank you for your help. But i don't know if it can working to measuring 3 phase voltage. i have not try yet. Here is my code.

#include <Filters.h>

float testFrequency = 50;                     // signal frequency (Hz)
float windowLength = 40.0/testFrequency;     // how long to average the signal, for statistist

int Sensor = 0;                 
int Sensor2 = 0;
int Sensor3 = 0;                 
int Sensor4 = 0;   
int Sensor5 = 0;                 
int Sensor6 = 0;                    

float intercept = 0;  // adjust untuk kalibrasi
float slope = 0.25731;   // adjust untuk kalibrasi
float A;      
float B;      
float C;      
float D;
float E;      
float F;
unsigned long printPeriod = 1000;     //Refresh rate
unsigned long previousMillis = 0;

void setup() {
  Serial.begin( 115200 );
  Serial.println("3 Phase Voltage Monitor");
  //delay(5000);
}

void loop() {
  
  RunningStatistics inputStats,inputStats2,inputStats3,inputStats4,inputStats5,inputStats6;               
  inputStats.setWindowSecs( windowLength );
   
  while( true ) {   
    Sensor = analogRead(34);                // read the analog in value:
    inputStats.input(Sensor);                   // log to Stats function
    Sensor2 = analogRead(35);                // read the analog in value:
    inputStats2.input(Sensor2);                   // log to Stats function 
    Sensor3 = analogRead(32);                // read the analog in value:
    inputStats3.input(Sensor3);                   // log to Stats function
    Sensor4 = analogRead(33);                // read the analog in value:
    inputStats4.input(Sensor4);                   // log to Stats function
    Sensor5 = analogRead(25);                // read the analog in value:
    inputStats5.input(Sensor5);                   // log to Stats function
    Sensor6 = analogRead(26);                // read the analog in value:  
    inputStats6.input(Sensor6);                   // log to Stats function
     
    if((unsigned long)(millis() - previousMillis) >= printPeriod) {
      previousMillis = millis();                // update time every second
      
      A = intercept + slope * inputStats.sigma(); //Calibartions for offset and amplitude
      B = intercept + slope * inputStats2.sigma(); //Calibartions for offset and amplitude
      C = intercept + slope * inputStats3.sigma(); //Calibartions for offset and amplitude
      D = intercept + slope * inputStats4.sigma(); //Calibartions for offset and amplitude
      E = intercept + slope * inputStats5.sigma(); //Calibartions for offset and amplitude
      F = intercept + slope * inputStats6.sigma(); //Calibartions for offset and amplitude    
        
      Serial.print( "Tengangan R-S: " );
      Serial.println( A );
      Serial.print( "Tengangan S-T: " );
      Serial.println( B );      
      Serial.print( "Tengangan R-T: " );
      Serial.println( C );
      Serial.print( "Tengangan R-N: " );
      Serial.println( D );      
      Serial.print( "Tengangan S-N: " );
      Serial.println( E );
      Serial.print( "Tengangan T-N: " );
      Serial.println( F );      
    }
  }
}

Hi,
Can you post an image of a hand drawn circuit of how you propose to connect your project to 3phase circuit?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Maybe like this

Pada tanggal Min, 22 Mei 2022 14.13, TomGeorge Believes in the Lucas Smoke Theory. via Arduino Forum <arduino@discoursemail.com> menulis:

Hi,

What is the voltage spec of the ZMPT101B?

What is your phase to phase voltage, hence what is your phase to neutral voltage?

Do you want to measure phase to phase voltage or phase to neutral voltage?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

I want to measure both phase to phase voltage and phase to netral voltage. I want to apply it at the distribution substation. Is it possible to use the zmpt101b sensor?

Phase to phase voltage is related to phase to neutral
One is root 3 times the other, so no need to measure both .

That sensor is not for “ industrial “ use , it’s a hobby part . I would not use for anything other than hobby use , and then take precautions .
Buy a proper 3ph voltmeter and get a qualified person to install it . You can then use any output it may have .
The phase to phase voltage will exceed its rating if it’s a” 240v “ setup .
If it’s 415v then it’s definite not usable

Examples

Hi,

Have you looked at the specs for the ZMPT?
I think you will find it is 240Vac.

What is your phase to phase voltage?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.