   boolean ret=false;
 
   for (int i=0;i<(sizeof(cntArr) / sizeof(struct cnt));i++) {
-    diff = abs(cntArr[i].measured.analog-cntArr[i].prevsnd.analog);
-    limit = cntArr[i].diff.analog * (1.0 + cntArr[i].measured.analog * cntArr[i].diff_factor.analog);
-    if (diff > limit) {
-      cntArr[i].flags |= FLAGS_DATACHANGE;
-      ret=true;
+    if (cntArr[i].irqno!=-1) {
+      diff = abs(cntArr[i].measured.analog-cntArr[i].prevsnd.analog);
+      limit = cntArr[i].diff.analog * (1.0 + cntArr[i].measured.analog * cntArr[i].diff_factor.analog);
+      if (diff > limit) {
+	cntArr[i].flags |= FLAGS_DATACHANGE;
+	ret=true;
+      }
     }
   }
   return ret;


  // counter build part
  for (int i=0;i<(sizeof(cntArr) / sizeof(struct cnt));i++) {
    if (cntArr[i].flags & FLAGS_DATACHANGE) {
      if (ts-cntArr[i].last_send > 30) {                   // value changed and there is more than 30 seconds after prev,
	iot.addValue(cntAvg(i),buildTime(ts-10,prevtime)); // so this time we'll send two samples.
      }
      currval=cntArr[i].measured.analog;
      added=true;
    }
    else if (cntArr[i].flags & FLAGS_TIMEOUT) { // no big changes, only timeout
      currval=cntAvg(i);
      added=true;
    }
    if (added) {
      iot.name(cntArr[i].name);
      iot.addValue(currval,chbuf);
      iot.next();
      cntPrepareForNext(i,ts);
    }
  }


      chkAdTimeouts(adArr,chcnt, ts, true);
    }
    calcAdChannels(adArr,chcnt);
    calcCnt();
    sendM2X(adArr,chcnt);
    resetAdChannels(adArr,chcnt);
  }
}


void calcCnt()
{
  unsigned int tmpCnt;

  for (int i=0;i<(sizeof(cntArr) / sizeof(struct cnt));i++) {
    if (cntArr[i].irqno!=-1) {
      noInterrupts();
      tmpCnt=_counters[i];
      interrupts();
      cntArr[i].prev.analog=cntArr[i].measured.analog;
      cntArr[i].measured.analog = (tmpCnt-cntArr[i].prev.digital) / (cntArr[i].scale.digital * cntArr[i].scale.analog); 
      if (cntArr[i].measured.analog > 20.0) {  // debug code. Sometimes during development a very big kw is sent to iot host.
	cntArr[i].measured.analog = 20.0;
      }
      cntArr[i].avg_counter+=tmpCnt-cntArr[i].prev.digital;
      cntArr[i].avg_samples++;
      cntArr[i].prev.digital=tmpCnt;
    }
  }
}

void checkEthernet()
