Stadsverwarming

From Frack - Hackerspace Friesland
Jump to navigationJump to search
Project: Stadsverwarming
Kamstrup energiemeter.jpg
Status lopend
Betrokkenen
Afbeelding Anoniem.png Martijn
Martijn (Martijn) Rol: deelnemer Deskundig met: Digitale Fabricatie, Elektronica, Hydroponics, Robotica, Software, Solderen, Stappenmotor Werkt aan: Geen projecten :(
Kennisgebied(en) Stadsverwarming
, Arduino
ProjectoverzichtProject toevoegen

Kamstrup warmte/flow meter uitlezen

Pics

Code

#include <SoftwareSerial.h>
 
const int LEDPIN   = 5;
const int DIODEPIN = A1;
 
SoftwareSerial mySerial(DIODEPIN, LEDPIN); // RX, TX
 
long d;
 
void setup() {
  pinMode(LEDPIN, OUTPUT);
  pinMode(DIODEPIN, INPUT);
  digitalWrite(DIODEPIN, LOW);
  Serial.begin(9600);
  d = millis() + 5000;
}
 
char ch;
boolean rx;
 
void rx300() {
  boolean done=false;
  mySerial.begin(300);
  mySerial.println("/?!");
  while (!done) {
    if (mySerial.available()) {
      ch = mySerial.read() & 0x7F;
      if (ch == 2) rx = true;
      else if (ch == 3) {
         rx = false;
         done = true;
      }
      else if (rx == true) 
        Serial.print(ch);
        //Serial.write(ch);
    }
  }
}
 
void rx1200(char k, long* val, char n) {
  boolean done=false;
  char str[12];
  char i=0, j=0;
  String req = "/#";
  req += k;
  mySerial.begin(300);
  mySerial.println(req);
  mySerial.begin(1200);
  while (n>0) {
    if (mySerial.available()) {
      ch = mySerial.read() & 0x7F;
      if (ch != 0x7F) {
        if (ch == 13) ch == 32;
        //Serial.print(ch);
        if (ch == 32) {
           str[j] = 0;
           *val = atol(str);
           j = 0;
           val++;
           i++;
           n--;
        } else str[j++] = ch;
      }
    }
  }
}
 
void loop() {
  long vala[10];
  if (d < millis()) {
    rx300();
    rx1200('1', vala, 10);
    Serial.print("energy [GJ]: ");
    Serial.println(vala[0]/100.0);
    Serial.print("water [m3]: ");
    Serial.println(vala[1]/100.0);
    Serial.print("hourcounter [j]: ");
    Serial.println(vala[2]);
    Serial.print("Tin [.C]: ");
    Serial.println(vala[3]/100.0);
    Serial.print("Tout [.C]: ");
    Serial.println(vala[4]/100.0);
    Serial.print("deltaT [.C]: ");
    Serial.println(vala[5]/100.0);
    Serial.print("power [kW]: ");
    Serial.println(vala[6]/10.0);
    Serial.print("flow [l/h]: ");
    Serial.println(vala[7]);
    Serial.print("peak power/flow [?]: ");
    Serial.println(vala[8]);
    Serial.print("info: ");
    Serial.println(vala[9]);
    while(1);
  }
}

voorbeeld output

met verwarming uit:

0.0(00005161295)
6.8(00273.71*GJ)
6.26(03057.91*m3)
6.31(0050889*h)!
energy [GJ]: 0.00
water [m3]: 3057.91
hourcounter [j]: 50889
Tin [.C]: 80.68
Tout [.C]: 57.68
deltaT [.C]: 23.00
power [kW]: 0.00
flow [l/h]: 0
peak power/flow [?]: 180
info: 0

met verwarming aan

0.0(00005161295)
6.8(00273.71*GJ)
6.26(03057.92*m3)
6.31(0050889*h)!
energy [GJ]: 0.00
water [m3]: 3057.92
hourcounter [j]: 50889
Tin [.C]: 81.05
Tout [.C]: 49.59
deltaT [.C]: 31.46
power [kW]: 26.90
flow [l/h]: 759
peak power/flow [?]: 180
info: 0

bronnen

MULTICAL® Energy meter (soort folder) MULTICAL® TYPE 66-CDE Technical Description MULTICALâ III & ULTRAFLOW II Technical Description English