 
 int sendM2X(struct ad *ad,int cnt)
 {
-  const char *streamNames[4];
-  int counts[4];
-  const char *ats[4]; 
-  double values[4];
+  const char *streamNames[5];
+  int counts[5];
+  const char *ats[5];
+  double values[5];
   int m2xpos=0;
   String timebuf;
   char chbuf[22];
   int response;
- 
+  static float prevkw=0.0;
+  static int cntLastSend=0;
+  bool timeout=false;
+  int ts;
+
   timebuf=String(year())+"-"+
     len2(month())+"-"+
     len2(day())+"T"+

      m2xpos++;
    }
  }
  if (m2xpos) {
    if (feedId[0]==0) {
      Serial.println("feed id not known");

    resetAdChannels(adArr,sizeof(adArr) / sizeof(struct ad));
  readAdChannels(adArr,sizeof(adArr) / sizeof(struct ad));
  cnt++;
  if ((cnt % AD_SAMPLECNT)==0) {
    sched.oscillate(13,150, LOW,2);
    calcAdChannels(adArr,sizeof(adArr) / sizeof(struct ad));
    sendM2X(adArr,sizeof(adArr) / sizeof(struct ad));
    resetAdChannels(adArr,sizeof(adArr) / sizeof(struct ad));
  }
  if ((cnt % (AD_SAMPLECNT * 3))==0) {
    calcKw();
  }
}


void calcKw()
{
  static unsigned int prevCnt=0;

  if (prevCnt!=0) {
    kw=(_kwCounter-prevCnt) / (digvalue * analogvalue);
  }
  prevCnt=_kwCounter;
}

void checkEthernet()
{
