Power Analyzer (3PCS) How to read and display data.

Power Analyzer 2 from egizmo Philippines

Help! We can now read and display the data coming from one of the power analyzer that we have but when we connect/needed another power analyzer we don’t know how to put them into codes … these are the working codes that we have for our power analyzer …
Thanks in advance those who will help us …

int i, j;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial1.begin(9600);
Serial1.write(0x02);
Serial1.print(“M2”);
Serial1.write(0x03);
i = 0;
j = 0;
}

#define C_STX 0x02
#define C_ETX 0x03

char data[10];
float Vrms;
float Irms;
float Preal;
float WattHour;

void ParseData(void)
{
String sdata(data);

switch (j) {
case 13:
WattHour = atof(data);
Serial.print("WattHour = ");
Serial.println(WattHour);
break;
}
}

void loop() {
// put your main code here, to run repeatedly:
while(Serial1.available())
{
char c = Serial1.read();
switch (c) {
case C_STX:
i = 0;
j = 0;
break;
case C_ETX:
ParseData();
j++;
i = 0;
data = 0;

  • Serial1.println("");*
  • break;*
  • case ‘,’:*
  • ParseData();*
  • j++;*
  • i = 0;*
    _ data = 0;_
    * break; *
    * default:*
    * data[i++] = c;*
    * if (i>=sizeof(data))*
    * i=0;*
    _ data = 0;
    * break;
    }
    }
    }*_