How to calculate the energy and extract into variable on EmonLib?

I’m trying to calculate the energy in KWh on emon and extract this value into variable…

Emon gives each loop the power value, right? But what is the time passed each loop? how could I implement the time value in this code to get the energy?

realPower = V_RATIO * I_RATIO * sumP / numberOfSamples;
apparentPower = Vrms * Irms;
powerFactor=realPower / apparentPower;
realEnergy = realEnergy +(realPower ???);

Any help will be welcome!

What do you mean by “Emon”? It is the name we give to everything here: emonTx, emonTH, emonCMS, etc.

And which sketch are you quoting? Have you looked at emonTxV3_4_continuous_kwhtotals on GitHub?

Oh yeah, forgot to mention

I’m using this library on arduino Uno