3 phase meter combined graphs

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Post Reply
Abbadon
Posts: 40
Joined: Thursday 01 October 2015 8:25
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Poland, Wrocław
Contact:

3 phase meter combined graphs

Post by Abbadon »

Hello, i'v made a mysensor script to send values like Current power and voltage for each phase. i Tried to send for example 3 samples of current as one child id to get combined graph for them but result was.. none. Its possible to show few sented values in one chart? My code below:

Code: Select all

#include "EmonLib.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <MySensor.h>  
#define ONE_WIRE_BUS 4
const int LEDpin = 9;                                                 
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

#define NODE_ID 104
#define CHILD_ID_VOLTAGE 0
#define CHILD_ID_IL1 1 //phase 1
#define CHILD_ID_POW1 2
#define CHILD_ID_IL2 3 //phase 2
#define CHILD_ID_POW2 4
#define CHILD_ID_IL3 5 //phase 3
#define CHILD_ID_POW3 6
#define CHILD_ID_TEMP 7 // ds18b20

MySensor gw;
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
MyMessage msgVol(CHILD_ID_VOLTAGE, V_VOLTAGE);

MyMessage msgIL1(CHILD_ID_IL1, V_CURRENT);
MyMessage msgPOW1(CHILD_ID_POW1, V_WATT);
MyMessage msgPOWK1(CHILD_ID_POW1, V_KWH);

MyMessage msgIL2(CHILD_ID_IL2, V_CURRENT);
MyMessage msgPOW2(CHILD_ID_POW2, V_WATT);
MyMessage msgPOWK2(CHILD_ID_POW2, V_KWH);

MyMessage msgIL3(CHILD_ID_IL3, V_CURRENT);
MyMessage msgPOW3(CHILD_ID_POW3, V_WATT);
MyMessage msgPOWK3(CHILD_ID_POW3, V_KWH);

EnergyMonitor ct1,ct2,ct3, ct4;
float tabela_pomiarow[4][5];
int k =0;
float srednia[4];
void bubblesort(){
   int i, j, l;
   float temp[4];
   for (l = 0; l<=4; l++){
  for (i = 0; i<4; i++){
    for (j=0; j<4-i; j++){
      if (tabela_pomiarow[l][j] > tabela_pomiarow[l][j+1]){
        temp[l] = tabela_pomiarow[l][j+1];
        tabela_pomiarow[l][j+1] = tabela_pomiarow[l][j];
        tabela_pomiarow[l][j] = temp[l];
      }
    }
  }
}
}

void setup() {
  ct1.current(1, 60.606);
  ct2.current(2, 59.606);                                     
  ct3.current(3, 60.606);
  ct4.current(4, 60.606); 
  ct1.voltage(0, 242, 1.7);                                
  ct2.voltage(0, 242, 1.7);                                
  ct3.voltage(0, 242, 1.7);
  gw.begin(NULL, NODE_ID, false);
  gw.sendSketchInfo("Power meter", "2.0");

gw.present(CHILD_ID_VOLTAGE, S_MULTIMETER);
gw.present(CHILD_ID_IL1, S_MULTIMETER);
gw.present(CHILD_ID_POW1, S_POWER);
gw.present(CHILD_ID_IL2, S_MULTIMETER);
gw.present(CHILD_ID_POW2, S_POWER);
gw.present(CHILD_ID_IL3, S_MULTIMETER);
gw.present(CHILD_ID_POW3, S_POWER);
gw.present(CHILD_ID_TEMP, S_TEMP);

pinMode(LEDpin, OUTPUT); 
}
void faza1(){
     for (int l = 0; l<=3; l++){
      switch (l) {
    case 0:
//      Serial.println("Pomiar Irms fazy nr I");
      break;
    case 1:
  //    Serial.println("Pomiar Irms fazy nr II");
      break;
      case 2:
  //    Serial.println("Pomiar Irms fazy nr III");
      break;
      case 3:
  //    Serial.println("Pomiar Vrms");
      break;
  }     
  for (int a = 0; a <= 4; a++){
    if (l == 0){
    ct1.calcVI(40,2000);  
    tabela_pomiarow[l][a] = ct1.Irms;
 //   Serial.print(tabela_pomiarow[l][a]);
 //   Serial.print(" ");
  }else if (l == 1){
    ct2.calcVI(40,2000);  
    tabela_pomiarow[l][a] = ct2.Irms;
 //   Serial.print(tabela_pomiarow[l][a]);
  //  Serial.print(" ");
    }else if (l == 2){  
    ct3.calcVI(40,2000);  
    tabela_pomiarow[l][a] = ct3.Irms;
 //   Serial.print(tabela_pomiarow[l][a]);
 //   Serial.print(" ");
    }else if (l == 3){   
      ct1.calcVI(40,2000);  
    tabela_pomiarow[l][a] = ct1.Vrms;
   // Serial.print(tabela_pomiarow[l][a]);
  //  Serial.print(" ");
    }
    }
 //   Serial.println(" ");
    bubblesort();

  for (int k = 0; k <= 4; k++){
 //   Serial.print(tabela_pomiarow[l][k]);
   // Serial.print(" ");
}

  //wyliczenie sredniej poza najmniejszym i najwiekszym pomiarem
//Serial.println(" ");
    
   srednia[l] = (tabela_pomiarow[l][1] +tabela_pomiarow[l][2] + tabela_pomiarow[l][3])/3;

  //Serial.print("Srednia z dobrych pomiarow: ");
 // Serial.println(srednia[l]);
  delay(1000);
  }
}
  
 
void loop() {
  int z;
for (int z = 10; z <= 10; z--){
if (z == 0){
for (int g = 1; g <= 2; g++){
faza1();
sensors.requestTemperatures();
//  Serial.println(g);
if ( g == 1){
float temp = sensors.getTempCByIndex(0);
gw.send(msgTemp.set(temp, 2));
  digitalWrite(LEDpin, HIGH);  
  if (!ct1.powerFactor){ct1.powerFactor = 0;}
Serial.println("F1 "  + String(srednia[0])+ ',' + String(srednia[3]) + ',' + String(ct1.powerFactor));
float moc1 = srednia[0] * srednia[3] * ct1.powerFactor;
Serial.println(moc1);
gw.send(msgIL1.set(srednia[0], 2));
gw.send(msgPOW1.set(moc1, 2));
gw.send(msgPOWK1.set(moc1, 2));
if (!ct2.powerFactor){ct2.powerFactor = 0;}
Serial.println("F2 " + String(srednia[1])+ ',' + String(srednia[3]) + ',' + String(ct2.powerFactor));
float moc2 = srednia[1] * srednia[3] * ct2.powerFactor;
Serial.println(moc2);
gw.send(msgIL1.set(srednia[1], 2));
gw.send(msgPOW2.set(moc2, 2));
gw.send(msgPOWK2.set(moc2, 2));
if (!ct3.powerFactor){ct3.powerFactor = 0;}
Serial.println("F2 " + String(srednia[2])+ ',' + String(srednia[3]) + ',' + String(ct3.powerFactor));
float moc3 = srednia[2] * srednia[3] * ct3.powerFactor;
Serial.println(moc3);
gw.send(msgIL1.set(srednia[2], 2));
gw.send(msgPOW3.set(moc3, 2));
gw.send(msgPOWK3.set(moc3, 2));

Serial.println(srednia[3]);
gw.send(msgVol.set(srednia[3], 2));
Serial.println(" --------------------------------------- ");

  digitalWrite(LEDpin, LOW);  
  }
}
z = 1;
}else{
  Serial.print("kalibrowanie: ");
  Serial.println(z);
  ct1.calcVI(40,2000);        
  Serial.print(ct1.Irms);   
  Serial.print("  ");
  ct2.calcVI(40,2000);
  Serial.print(ct2.Irms);
  Serial.print("  ");
  ct3.calcVI(40,2000);
  Serial.print(ct3.Irms);
  Serial.print("  ");
  Serial.println(ct1.Vrms);
  }}}


Abbadon
Posts: 40
Joined: Thursday 01 October 2015 8:25
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Poland, Wrocław
Contact:

Re: 3 phase meter combined graphs

Post by Abbadon »

bump
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest