 
 
 volatile long startMills ;
-volatile float revMills ;
+volatile long revMills ;
+long oldrevMills ;
+
 long sentMills ;
 
 volatile int IRSTATUS = LOW ;
 int OLDIRSTATUS ;
 
 float revValue ;
+float oldrevValue ;
 double VIrms ;
 
 //
 String clientName ;
 String payload ;
+
+// smoothing
+// https://www.arduino.cc/en/Tutorial/Smoothing
+// Define the number of samples to keep track of.  The higher the number,
+// the more the readings will be smoothed, but the slower the output will
+// respond to the input.  Using a constant rather than a normal variable lets
+// use this value to determine the size of the readings array.
+
+const int numReadings = 10;
+
+int readings[numReadings];      // the readings from the analog input
+int indexof = 0;                  // the indexof of the current reading
+int total = 0;                  // the running total
+int average = 0;                // the average
+
 
 void callback(const MQTT::Publish& pub) {
 }


void count_powermeter()
{
// if (( millis() - startMills ) < 600 ) {
  if (( millis() - startMills ) < ( revMills / 3 )) {
       return;
  } else {
    revMills   = (millis() - startMills)  ;
    startMills = millis();


// wifi
#ifdef __IS_MY_HOME
#include "/usr/local/src/ap_setting.h"
#else
#include "ap_setting.h"
#endif

// mqtt
