read the icon electric smart meter

using the detector from the RadioShack #276-0142

had lot’s of issues with sunlight - as it get’s full sun about noon!

here are my results so far:

Billed MyReading %Delta
1029 1024.286 0.46%
1023 1017.331 0.55%
1212 1197.293 1.21%
1969 1964.973 0.20%
2133 2140.187 -0.34%

I call the arduino every 5 minutes (actual twice) via Ethernet that I also poll some two lines of onewire Dallas Temperature sensors.

So I think I lose a watt/blink or more (i.e. 1 watt) in that time frame…

#define power_input 0
void loop()
{
  PowerLoop();
}

unsigned long powerCount = 0;
unsigned long powerCountLast = 0;
unsigned long powerLastBlink = 0;
unsigned long powerK5count =0;
unsigned long powerW1=0;
unsigned long powerW2=0;
unsigned long powerW3=0;
unsigned long powerW4=0;
unsigned long powerW5=0;

float powerBlinkLength = 80;
float powerBlinkRate = 200;
int powerBlinkFlag = 1;
float powerFilterR = 600;
float powerFilterH = 600;
float powerFilterC = 600;
float powerMaxL = 1;
float powerMaxH = 0;
int powerReading = 0;

void PowerLoop() {
  
  powerReading = analogRead(power_input);
  powerFilterR += .55 * (powerReading-powerFilterR);
  powerFilterH += .01 * (powerReading-powerFilterH);
  powerFilterC += .9 * (powerReading-powerFilterC);
  
  if (powerFilterC/powerFilterH < powerMaxL) powerMaxL = powerFilterC/powerFilterH;
  if (powerFilterC/powerFilterH > powerMaxH) powerMaxH = powerFilterC/powerFilterH;
  
  serialPrint();
  
  if ((powerFilterC/powerFilterH <.9 && powerBlinkFlag ==1 && millis()-powerLastBlink > 50) || powerLastBlink > millis())
  {
      powerBlinkFlag = 0;
      powerCount++;
      float rate = millis()-powerLastBlink;
      if(rate>0) powerBlinkRate += .05 *(rate-powerBlinkRate);
      powerLastBlink = millis();   
  }
  else if (powerFilterC/powerFilterH > 1.01 && powerBlinkFlag == 0)
  {
    if ( millis()-powerLastBlink > 30|| powerLastBlink > millis()){
      float rate = millis()-powerLastBlink;
      if (rate>0) powerBlinkLength +=  .05*(rate-powerBlinkLength);
      powerBlinkFlag = 1;
    }
  }
 unsigned long w = millis() - lastconnect;
 
 if ( w < 60000) { powerW1 = powerCount; }
 else if (w < 120000) { powerW2 = powerCount; }
 else if (w < 180000) { powerW3 = powerCount; }
 else if (w < 240000) { powerW4 = powerCount; }
 else if (w < 300000) { powerW5 = powerCount; }
}

electric_meter_cut.JPG