EmonLib Question

Good day all,

I have the volt and current monitor working on an arduino outputting the values on the serial port of the AT328 using EmonLib.

What I need is a 'tag'' value output on the serial port before the measured value,

for example instead of the real power, apparent power, rms voltage, rms current and power factor values being sent

consecutively I need  D2166 power value D2167 apparent power D2168 RMS voltage etc.

Is this possible and if so how do I configure this in the arduino sketch ?

Thanks for any help

Dave

Robert Wall's picture

Re: EmonLib Question

That's nothing to do with emonLib itself - you'd do that in the main body of the sketch. Where you have something like "Serial.print(emontx.power1);", you change this to:

Serial.print("D2166 power: ");
Serial.print(emontx.power1);

etc.

daveps's picture

Re: EmonLib Question

Thanks Robert for the reply,

I understand what you say but could you please clarify the following or point me to a wiki....

Are presently using this line to print values in sketch :    emon1.serialprint();            // Print out all variables

Serial.print(emontx.power1); will print print the power value variable ,what do I use to get the emon lib to print the power,current,power factor,etc variables ?

Will the command be    Serial.print(emontx.apparent power1);

 Serial.print(emontx.voltage1);

Serial.print(emontx.current1);

Serial.print(emontx.power factor1);  etc

Hope you understand the question :)

Thanks

Dave

Robert Wall's picture

Re: EmonLib Question

If you look in emonlib.h, in the class EnergyMonitor you will see a list of "public" methods & properties. It is these that are accessible to the outside world. The ones of interest to you are realPower, apparentPower, powerFactor, Vrms & Irms.

Assuming you have not changed the library, the way you are trying to access these is wrong. The names of the properties stay the same, but they are prefixed by the name of the instance of EnergyMonitor that you are interested in. You named those when you did something like "EnergyMonitor emon1, emon2, emon3;" in your sketch. (The syntax is exactly equivalent to "int x, y, z;".)

Therefore, if you have called your instances of EnergyMonitor Tom (tag "D1234") and Dick (tag "D4567"), and you want the power factor of the first and apparent power of the second, your print statements are:

Serial.print("D1234 ");Serial.print(Tom.powerFactor);
Serial.print(" D4567 ");Serial.println(Dick.apparentPower);

and that will print something like:

D1234 0.95 D4567 1350

Note println(...) causes the next print to start on a new line.

If it is more convenient for you, you could name the instances of EnergyMonitor D1234 etc (it's legal provided it starts with a letter), then you'd have

Serial.print("D1234 ");Serial.print(D1234.powerFactor);

etc.
 

 

daveps's picture

Re: EmonLib Question

Thanks

Should come right now,thanks for helping a noob !

Dave

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.