(Line numbers are my original sketch - it appears that Glyn has changed things, so they are probably wrong, but somewhere near.)
You (?) should be able to get the sketch to tell you frequency - subject of course to the accuracy of your oscillator. I found I could calibrate that by comparing my record of frequency against the published value.
It is calculated at line 739, printed to your serial monitor, but not sent by radio. (While I remember, the constant 16000000
in there is the nominal oscillator frequency - that’s the number you change to calibrate frequency.)
So what you need to do is, in line 278, add “frequency”. This includes it in the packet of information sent to emonHub:
typedef struct { int power1, power2, power3, power4, Vrms,
frequency,
temp[MAXONEWIRE] = {UNUSED_TEMPERATURE,UNUSED_TEMPERATURE, UNUSED_TEMPERATURE,UNUSED_TEMPERATURE,UNUSED_TEMPERATURE,UNUSED_TEMPERATURE}; unsigned long pulseCount; } PayloadTx;
After line 804: emontx.Vrms=(int)(Vrms*100+0.5);
add a new line to write the value into that data packet:
emontx.frequency=(int)(frequency*100+0.5);
this will send frequency as an integer ×100, e.g. 5000, giving you a value to within ± 0.005 Hz.
Compile the new sketch and load it into your emonTx. It will stop reporting in your emonBase. You must edit emonhub.conf to tell it what to expect.
Find the entry for your emonTx - it should look like this, taken from the top of the sketch:
[[11]]
nodename = emonTx_three_phase
firmware = three_phase
hardware = emonTx V3.2/V3.4/Shield
[[[rx]]]
names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulsecount
datacodes = h, h, h, h, h, h, h, h, h, h, h, L
scales = 1,1,1,1,0.01,0.01,0.01,0.01,0.01,0.01,0.01,1
units =W,W,W,W,V,C,C,C,C,C,C,p
In the same place in each line, you must add the information emonHub needs:
names = powerL1, powerL2, powerL3, power4, Vrms,
frequency, temp1, temp2, temp3, temp4, temp5, temp6, pulsecount
datacodes = h, h, h, h, h,
h, h, h, h, h, h, h, L
scales = 1,1,1,1,0.01,
0.01, 0.01,0.01,0.01,0.01,0.01,0.01,1
units =W,W,W,W,V,
Hz, C,C,C,C,C,C,p
Save the file.
You should then be able to select “frequency” as an input to a graph, or a dial or a feedvalue.
I have not done this, but it ought to work. DO keep a copy of the original sketch, in case it all goes wrong.