Trying to match utility meter and emoncms

I am trying to add an integer 72000.6 (my existing Utility meter reading to “Power to KWh” and I can’t.

I am using the emon Shield with CTs and a Leonardo to upload to emoncms. The power readings are quite precise according to my ammeter.

Any ideas where I am going wrong ?

Firstly that’s a float(ing point number) integers are whole numbers only eg int(72000.6) = 72000.

I can see several things not quite right so I will just run through them and then you can use what you can from that.

  • best practice would be to put the “log to feed” at the top of the processing to log the input in it’s rawest form and it make easier reading, it’s a little more logical.

  • name that first “log to feed” something with “power” in the name,

  • The allow positive followed by an allow negative translates to “zero everything” because each of those processes blocks everything above or below zero.

  • so the “+72000” line will always result in a value of “72000”.

  • the value fed into the “power to kWh” process is always 72000, only the time interval between input updates can effect the output of this process now.

The normal arrangement here would be

log to feed “xyz_power”
power to kWh “xyz_kwh”
power to kwhd “xyz_kwhd”

and then if you wanted to have a feed that tracks your meter, you could use the input api to “correct” the kwh total by setting up a separate input, lets call it “adjust”

to that new input add one new process “log to feed” and select your kwh feed you want to correct.

then pause your other inputs for a moment (to avoid conflicting inputs trying to save different values at the same time)

then wait a few seconds (about the same length of time as the fixed interval of the feed you are editing)

and post the current meter reading to the new input

then wait a few seconds again (about the same length of time as the fixed interval of the feed you are editing)

and restart your original input, it should add it’s energy used to the 72000

It would be wise to delete the “adjust” input when you have finished with it to avoid any accidents

alternatively you could add

reset to zero
+feed p2kw
+ 72000
log to feed “meter reading”

to the end of the processing above, but this results in 2 feeds to be maintained (ie twice the disk space and double the input processing (probably not a real concern)

However be aware that emoncms uses 32bit floats and therefore generally accurate to 7 digits, by syncing you meter reading you are going to loose some resolution 123.456Kw used + 72000 = 72123.460 (not 72123.456, again not a big concern when viewing but when you have a small load it might not register. 72012.460 + 4Wh = 72123.460. At a 10 sec update interval (4Wh every10s) that’s 1440watts, anything less than 1440watts might not register. My rough maths might be out here but I hope it at least demonstrates the potential issue.

[edit - having said all that, the “2 feed approach” would get around the resolution because the energy would be calculated on the smaller running total and then that gets increased to the meter reading value by simply adding the 72000]

[edit2 - you can also use a virtual feed for the second feed instead of a conventional phpfina as the apps module etc will work equally well with the first feed as it uses the delta between points not the total]

1 Like

Thank you Paul for your detailed response.
I understand what you mean about the 32 bit precision, but I am not concerned about that yet.
I followed your directions but use of addition has me baffled.

I liked your idea of an “adjust Feed” and I tried that and also your suggestion of +72000.

I just want the sum of line 5 and line 6.

Yes that way will work too.

I think the bit you are missing is at line 5 you need a “+feed” so that the “reset to zero” (0) +feed (eg 123.45) +input (72000) = 72123.45 which is then “log to feed” in line 7.

What you currently have there is the result of “reset yo zero” (0) is being fed into the “power to kwh” process, So 0 Watts for X secs, always equals 0kWh’s, it doesn’t matter how long the interval, it will always equal 0.
0 +input (72000) = 72000, it will not change until the “adjust” input changes.

Drop the “power to kWh” in line 5 and dreplace it with a “+feed” and select your “power1_Kwh” and it should work.

Note I put an underscore in “Power1 KwhDay”, spaces in names is something that can easily comeback and bite you, so it’s good practice to get in the habit of using underscores.

Thanks Paul for your suggestions.
I believe I did what you suggested but there must be something I am missing.
It isn’t mission critical, just thought it would be handy if it was easy.

Not to worry,

That is almost there, you just shouldn’t of deleted the power to kwh that was in position 2.

What you are doing is saving the energy used to a feed (via the power to kwh process) and then using that total (zero +feed processes) to add your adjustment to before saving it as a meter reading. So put the power to kwh “power1_kwh” back into position 2 without making any other changes and it should work as expected.

Don’t give up when you are this close :slight_smile:

Hi Paul, I was getting confused because when I tried to add in _kWh to line 2 I got “ says ERROR: Feed is already being written to, select create new”. I didn’t cop that you can create a new feed with the same name, However working now. Thanks for your help.