Would it be possible to log the ac frequency using the emonTx?

I am interested in monitoring the output frequency of a generator, could the emontx or the emonpi possibly do that job?


EmonLibCM makes it available, it simply isn’t normally sent with the rest of the data. Look at the documentation for emonLibCM:


Does that require any calibration? I’m getting some negative readings, like -15.54

I just changed the emontx firmware to send EmonLibCM_getLineFrequency() * 1000 as F1, and then I I configured emonhub like this:

   names = MSG, Vrms, P1, P2, P3, P4, E1, E2, E3, E4, T1, T2, T3, pulse, F1
   datacodes = L,h,h,h,h,h,l,l,l,l,h,h,h,L,h
   scales = 1,0.01,1,1,1,1,1,1,1,1,0.01,0.01,0.01,1,0.001
   units = n,V,W,W,W,W,Wh,Wh,Wh,Wh,C,C,C,p,n 
   whitening = 1

What is your nominal line frequency?

Then multiply that by 1000, and assign it to a signed integer? I think that’s where your problem lies.

D’oh. I haven’t touched C in a while. I was overflowing the int probably. Got it working now


I’m certain you were - 60 Hz * 1000 > 32767. Had you used an unsigned int decoded as H, then you’d have been OK up to 65.535 Hz. But 3 figures is a bit excessive anyway - I wouldn’t guarantee it to more than two.