If you have a programmer and loaded the sketch yourself (or you can load the sketch yorself), then the best place is the sketch. You can do the full calibration there.
If you don’t have a programmer, the you can change the “scales = …” parameters in emonhub.conf
These are not designed for that purpose, you cannot adjust the phase error correction there.
and
that is indeed correct (power is calculated in the emonTx, not in emonHub)
Instructions for both methods are in Learn → Electricity Monitoring → Current & Voltage → Calibration Procedure.
Yes there is. It means editing the sketch in the emonTx and changing the definition for that node in emonhub.conf.
Take care: you must keep the length of the data packet to 66 bytes or less. This is a JeeLib limitation. Integers are 2 bytes, longs are 4 bytes. You don’t need to send values you don’t use (e.g all 6 temperatures if you only use one).
The values are already calculated, but not sent. You must add statements to extract the values and add them to the data packet sent by radio. Look at the standard sketch (get it from Github).
In src.ino, look at line 403
ct1.calcVI(no_of_half_wavelengths,timeout);
This does the calculation. If you look at emonLib (emonlib.h), you’ll find a list of all the values available to you. They are:
double realPower,
apparentPower,
powerFactor,
Vrms,
Irms;
So to use any or all of those, you add lines like the next two, 404 & 405, inventing names like “emontx.current1” etc. Do this similarly for all four c.t’s. You might want to multiply the currents by 10, 100 or 1000 because they will be sent as integers - multiplying by 100 here allows you to send 2 decimal places and you multiply by 0.01 with “scales” in emonhub to restore it; and you must do that for the power factor. The number range you can send this way is -32768 to
32767.
Then you must add the new values to the data packet. This is in lines 144 - 147:
typedef struct {
int power1, power2, power3, power4, Vrms, temp[MaxOnewire];
unsigned long pulseCount;
} PayloadTX; // create structure - a neat way of packaging data for RF comms
Add the new names in there.
Finally, you must add the new variables in emonhub. The “names”, “datacodes”, “scales” & “units” map 1:1 to PayloadTX
The full details of emonhub.conf are here: emonhub/configuration.md at emon-pi · openenergymonitor/emonhub · GitHub
If the node definition in emonhub.conf does not match the length of the data you are sending, it fails and you get nothing. If the data types and positions do not match, your data will be totally mixed up.