Current measurement with emonTx

Good morning,
I am writing to seek advice regarding the current-only measurement with an emonTx (V3).
In order to obtain the current measurement, I tried to modify the firmware changing these lines

ct1.calcVI(no_of_half_wavelengths,timeout); emontx.power1=ct1.realPower
emontx.power1 = ct1.calcIrms(no_of_samples)*Vrms


ct1.calcVI(no_of_half_wavelengths,timeout); emontx.power1=ct1.Irms
emontx.power1 = ct1.calcIrms(no_of_samples)

as was suggested for the emonPI in this link , but it doesn’t work. I have no measument at all: it’s always set to zero. Did I miss anything? Do I have to change some other parameters?

Thank you for your attention.
Kind regards,

If you do not have an a.c. adapter, your emonTx sketch will automatically switch to measuring current only, and will report apparent power (volt-amperes) based on the assumed, fixed value of voltage.

The code you have changed is not the best - there is no need to use calcVI( ) and ct1.Irms because you immediately overwrite the value, so you only need the second line. It might not “work” if the current is less than 1, because emontx.power1 is an integer value, so a current less than 1 A will be truncated to zero.

The “right” way will be to (optionally) change the name of power1 to current1 and then (necessarily) multiply the return value of calcIrms( ) by 100 before assigning it. That will give you units of 10 mA, divide by 100 again (or multiply by 0.01) in emonHub or emonCMS when you use the number.
(For an example, look at how temperature is handled - it’s exactly the same.)