Puck Smart Meter

Posted on
  • 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
    // Watch for pin changes
    setWatch(function(e) {
     digitalPulse(LED,1,50); // show activity
    }, D31, { repeat:true, edge:"falling" });
    // A function to store the data in the history
    function log() {
      // 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('c: ' + c);
      console.log('MainCounter: ' + MainCounter);
    function setT(nt,tz)
      print('setT nt ' + nt);
      setTime((new Date(nt)).getTime()/1000);
    function returnData(what)
      var Elec = what==1?0:historyC;
      var time = what==1?Math.floor(getTime()*1000):lastS­etT;
      var o = {
      'latestElecCount': cElec,
      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];
      logInt = setInterval(x=>log(), config.seconds*1000);
    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?


    1 Attachment

    • Annotation 2022-01-23 152840.png
  • I'd say first port of call is probably checking that the LDR is right over the meter LED - and you could also check the voltage from GND to pin D31 when everything is in place.

    It's possible that the LDR you have is of a resistance that's a bit too 'on the edge' for the voltage change to always be counted, in which case you might need to disable the internal pullup and then add your own of a higher value.

    But... I've never really seen that style of meter before - I guess it's possible (although unlikely) that the LED blink is not calibrated (but you hope the dial movement is!)

  • Thanks @Gordon. I've got 2 solar panels due to be delivered with a meter to monitor production and also a couple of MDBT42Q so I can have a play and try to find out where the issue is.

    That said indicative consumption is still a lot better than I have now.

    Thanks again

  • I think you're capturing the flashes just fine, you aren't calculating the units correctly.
    The writing on the meter says 800 Imp/kWh, so you should be dividing by 800, not 1000.

    2320 / 800 = 2.9 kWh, which is pretty close to what you estimated your usage to be.

  • Ha ha ha @myownself,

    If I had a brain I would be dangerous. That photo was just one I lifted from the internet but you are dead right.
    What a muppet I am.

    Thanks so much.

  • Great! That's crazy - never seen one like that before!

  • My MDBT42Q arrived yesterday so I'm going to see if readAnalog(LED2) is sensitive/accurate to be used instead of adding an LDR.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Puck Smart Meter

Posted by Avatar for user121340 @user121340