Arduino question read values

Hello,

Right now i'm working with the Pi directed connected to the arduino (usb/ serial connection) and that works fine.

But i want to send the values separately (comma) to the Pi.

But right now the output is: 

209.34 216.03 20.93 10.32 0.97
208.92 215.51 20.89 10.31 0.97
212.95 219.54 21.11 10.40 0.97
209.44 216.10 20.94 10.32 0.97
211.10 217.70 21.02 10.36 0.97

With this code:

#include "EmonLib.h"             // Include Emon Library
EnergyMonitor emon1;             // Create an instance

void setup()

  Serial.begin(9600);
 
  emon1.voltage(2, 234.26, 1.7);  // Voltage: input pin, calibration, phase_shift
  emon1.current(1, 111.1);       // Current: input pin, calibration.
}

void loop()
{
  emon1.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out
  emon1.serialprint();           // Print out all variables
}

Where can i find more info?

Thank you.

Rob

RobV's picture

Re: Arduino question read values

I think i have to use:

mySerial.print(emon1.Vrms, emon1.Irms); etc?

Robert Wall's picture

Re: Arduino question read values

The easy answer is to ignore serialprint. Write your own set of output statements like this:

Serial.print(emon1.realPower);                //   The 1st value
Serial.print(", ");                                            //   a comma

Serial.print(emon1.apparentPower);       //   The 2nd value
Serial.print(", ");                                            //   a comma

etc, and make the last one on the line

Serial.println(emon1.powerFactor);

Which will print something like:

209.34, 216.03, 20.93, 10.32, 0.97
208.92, 215.51, 20.89, 10.31, 0.97

which I think is what you want. More details of Serial are in the Arduino IDE help (e.g. you can control the number of decimal places).

The complicated answer is you write your own new version serialprint( ), but if you only have the values from one class instance (emon1), there's no point.

RobV's picture

Re: Arduino question read values

Hey,

 

Thanks! Yes i mean that, the problem is i needed a comma separated file.

But i already edited the EmonLib.CCP :)

Comment viewing options

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