I have many inputs that I want to sum together into a "combined" input

I have 10 current clamps, one per house-circuit, giving me 10 separate “inputs”. From each of these inputs I’ve created 2 feeds… one for straight logging, and one for kWh logging ( so 20 feeds total ).

What I’d like is to have a cumulative input that is the sum of all of the inputs, so I can get a “whole house usage” value without needing to add another clamp.

I currently have a “virtual feed” that is the sum of all the relevant feeds, and this “works” in that I can see the data it collects, and graph it… but I can’t seem to then do anything interesting to it… like pipe the results from that “feed” into further calculation/s in other feeds.

Maybe what I’m after is an “input” that gets it data from the calculated output of a selected “feed” or “virtual feed”…?

Ok, I’ll start with the details:
Is it self-hosted? Yes.
What hardware is it running on? Raspberry Pi.
If self-hosted, is it a Pre-built emonSD image? No. a self-built install…? Yes.
What version is it? 9.7.8 | 2016.11.10
What Operating System is it running on? Linux. specifically: Linux minibian 4.4.34+
Have you made any changes to the code? No. Not to the emoncms install.
If so, what did you change? Data is fed into emoncms from Due+esp8266 over wifi+http, into the input/post.json? etc

A 10-input system with 10 current clamps, one for each circuit in my house, built with an Arduino Due, and an esp8266, kinda like Home Energy Monitoring System ( but with esp8266 instead of RFM12B ) . The hardware/firmware side is all working well-enough… :slight_smile:

Please include screen grabs if possible:

more screenshots:

more screenshots:

Hi,
you can make the sum of the inputs in the arduino due emonesp sketch by adding a new line with Serial.print(",Psum:"); Serial.print(realPower1+realPower2+ …realPower10); It will result in a new real input in emoncms with the sum of the active power. In order to have a correct summation and balance of power in the same time period I modified emonlib to calculate in one instance 2 voltages and 3 currents for my own purpose( balance of power from grid,pv inverter and diversion power. I think you have to do also for the 10 inputs, otherwise you need about 10 emon instances(20s) to read again first input.
Best regards

Probably not that long, if all 10 inputs read by the one Due.

The ‘standard’ measurement period for emonLib is 20 crossings, if that is used, it equates to 200 ms (or 166.6 ms on a 60 Hz system, which you’re not). Ten times that is 2 s, not 20, although there is a little overhead on each measurement to calculate the final values and to wait for the next crossing - about 10 ms, so about 2.1 s in total.

Stefan… thanks for the suggestion to add the “summation” to the firmware inside the “Due”, but the problem is that is inside my meter-box and terribly inconvenient to get to and re-program … and it means that every time I need to change-around the “mix” of channel/s, then I have to re-program the firmware in the powerbox, again.

eg… I was thinking of relocating one of the clamps from a circuit in the house that’s essentially unused so that I can use it to measure something dedicated ( like a aircon, for exampl )… but if I do that, then I’d have to re-flash the firmware again, and remove that channel from the “summation” data. … as you case see, each time I try moving something around, its a re-work of the the firmware, etc… when it need not be… I’m sure it could be done with something like a “virtual input”…?

Hi Robert,
please help me to understand how emonlib works. In emonesp sketch I have the following lines:
EnergyMonitor ct1; // Create an instance
EnergyMonitor ct2; // Create an instance
EnergyMonitor ct3; // Create an instance
EnergyMonitor ct4; // Create an instance

Also in the sketch I have:
ct1.calcVI(20,2000);
ct2.calcVI(20,2000);
ct3.calcVI(20,2000);
ct4.calcVI(20,2000); each instance with a timeout of 2000ms
All four instances are running in the same time or one after the other is finished?
I connected to my arduino due a display to show all four power calculated and it shows one power after the other with 2 seconds delay between them


Maybe I did something wrong in my sketch and i want to understand if is emonlib the cause or not.
Thank you

Have you looked at the code inside emonLib?

If your method is not returning until 2 s later, then I suspect that you have set totally wrong parameters to initialise each instance. “Timeout” is exactly what it says - it is a timeout that forces the method to time out and return after 2 s, if it fails to detect the voltage wave correctly either as it starts, or while it is running. “20” is the number of zero crossings (of the voltage wave) that it counts while recording the samples (at a rate of about 2500 per second, or about 50 sample pairs - voltage and current - per whole cycle. ‘Crossings’ of course counts half-cycles.

So my first guess is, you don’t have the correct “voltage” pin inPinV specified in
ct1.voltage(unsigned int _inPinV, double _VCAL, double _PHASECAL)

The instances exist concurrently, but the statements/methods execute consecutively.

Hi Robert,
thanks for your reply. InPinV are correct allocated since the correct voltage and powers are displayed in the screen. I will have a look in my sketch and try with different values for timeout and no of zero crossings to see what will be outcome.
For David I have a suggestion to use Nodered to aggregate all inputs in one flow and send back to emoncms. You have to manage nodered palette and use
node-red-contrib-aggregator which is not installed by default.
Best regards

Hi @David_Buzz sorry if I’m a bit late or I’m missing a vital point here but it seems to me you just need to NOT use a virtual feed.

What you have done in the virtual feed using the “+feed” process is exactly what you need but you need to do it in the processing of last input of the input api request, it is essential it is the last to be processed to ensure the “+feeds” use the latest values (ie if you did it in the first updated input only the first input would be “current” all the rest would be stale as you would be summing the feeds before they’ve been updated).

thanks pb66, your suggestion is what I needed to hear. it wasn’t at all obvious to me that I could use a single input as the “source” for feed that actually accumulates all my inputs. I’ve done that now and it seems to be doing the right thing.

Hi, I have a similar issue here, only different in that I have 4 consumer units all fed from fused feeds in the garage, so I have 4 x 100A CT’s on an emonTX located in the garage and I want to also have a cumulative value for the whole house consumption.

I too created these as virtual feeds using sfeed + sfeed + sfeed + sfeed and the same with a kWh output, which appear to output the correct values, but as @David_Buzz indicated, you can’t do much further processing on this, in particular, it’s not available to use in the “My Electricity” app.

I had gone down the path of logging to an additional feed in the same way that @pb66 described, I had made the mistake of putting it on the first feed which explained why the total value was slightly different to the sum of the 4 CT’s in each pass, I’ve corrected that now and it’s spot on. However, this only works for logging the “Watts” at that time, and the Power to kWh conversion appears incorrect using the +feed method on the inputs. I’ve attached a screenshot showing the two different outputs where you can clearly see the Virtual kWh value is a sum of the 4 individual feeds, yet the input driven one is significantly higher.

Any help with this would be appreciated!

Also on another note, anyone got any idea why my storage for each feed is still stuck at 0KB? They were adding up previously, but I removed all the feeds at one point and started again, and whilst they appear to be working and I have history in the graphs, the indicated storage space isn’t increasing?

Thanks
Barry


Ok, I’ve managed to answer this for myself so thought I would share it here…

Instead of trying to re-convert the combined figure to kWh, I’ve taken the approach of resetting the output value to 0 and then summing the existing kWh feeds, this seems to work as expected and matched the virtual figure, meaning I can ditch the virtuals and use the applications and have more flexibility with the feed data.

Scratch that… Although this looks correct on the feeds screen, no output values are being shown in the data feed (much like an issue I had in the virtual where I had to use sfeed rather than feed even though I don’t know the difference), unfortunately, sfeed isn’t available in the input configuration…

Stuck again…