You are reading a single comment by @user121340 and its replies. Click here to read the full conversation.
  • Hi, I've set up a puck with an LDR to read the flashes on my electricity meter.

    It's mostly working very well but I seem to be missing counts of flashes
    From 8:42 until 14:57 today my meter advises that I've used ~3kWh but I've captured 2320 flashes, ie 2.32kWh.

    There will be a little inaccuracy as the Puck stores the count every 5 minutes (surprisingly exactly on the 5 minute intervals from the o'clock) and I've obviously read the meter at 42 and 57 but that only accounts for maybe a max of 50-70 flashes.
    Then the meter is like the one in the image. There will be an element of inaccuracy there as well as it's not really possible to be 100% accurate where the counter is within the 1/10. That said even if I assume a 10% inaccuracy then that's still in the region of 0.5kWh that hasn't been captured.

    var config = {seconds:300,aryLen:1000};
    // log counter
    var c=0;
    var historyC = new Int16Array(config.aryLen);
    var lastSetT = 0;
    
    //main flash counter
    var cElec = 0;
    var MainCounter = 0;
    // Set up pin states
    D30.write(0);
    pinMode(D31,"input_pullup");
    
    // Watch for pin changes
    setWatch(function(e) {
     cElec++;
     console.log(cElec);
     digitalPulse(LED,1,50); // show activity
    }, D31, { repeat:true, edge:"falling" });
    
    // A function to store the data in the history
    function log() {
      c++;
      // move all history values back by one
      historyC.set(new Int16Array(historyC.buffer,2));
      // set the last history value
      historyC[historyC.length-1] = cElec;
      lastSetT = Math.floor(getTime()*1000);
    // int16 array max is 32k so reset and add to main counter.
      if (cElec>30000)  {cElec = 0;MainCounter++;}
      console.log(historyC);
      console.log('c: ' + c);
      console.log('MainCounter: ' + MainCounter);
    }
    
    function setT(nt,tz)
    {
      echo(1);
      print('setT nt ' + nt);
      setTime((new Date(nt)).getTime()/1000);
      E.setTimeZone(tz);
      print(Date());
    }
    
    function returnData(what)
    {
      var Elec = what==1?0:historyC;
      var time = what==1?Math.floor(getTime()*1000):lastS­etT;
      echo(0);
      var o = {
      'config':config,
      'count':c,
      'latestElecCount': cElec,
      'lastRecorded':time,
      'battery':Puck.getBatteryPercentage(),
      'MainCounter':MainCounter,
      'items':{
      'elec':Elec}
      };
      var output = JSON.stringify(o);
      for (var i=0;i<=output.length;i+=384) console.log(btoa(output.substr(i,384)));­
    }
    
    
    function setRecInterval()
    {
      var currentI = config.seconds;
      var l = [15,30,60,120,180,300,600,1800];
      var index = l.indexOf(currentI);
      index = index+1>=l.length?0:index+1;
      config.seconds = l[index];
      historyC=Int16Array(config.aryLen);
      c=0;
      clearInterval(logInt);
      log();
      logInt = setInterval(x=>log(), config.seconds*1000);
      console.log(config.seconds);
    }
    
    var logInt = setInterval(x=>log(), config.seconds*1000);
    

    The issue could be

    1. the flashes anen't 100% reflective of consumption on a meter
    2. The Puck perhaps can't accurately count over time.
    3. I've got a bug in my code that I haven't spotted.
    4. Interference from the meter / distrubution box.

    Also, out of interest, I've got a Pixl in the back of my campervan and Bluetooth coverage has never been an issue. I've only started using the Puck for this project and Bluetooth coverage is very much more tempramental, both with failures to connect and also I need to be in a very particular location to get a connection.
    I guess a lot of that may be the noise around the meter cupboard as the distrubution box is also very close.

    Has anyone got any ideas or come across a similar issue?

    Thanks


    1 Attachment

    • Annotation 2022-01-23 152840.png
About

Avatar for user121340 @user121340 started