devinaconley/arduino-plotter

How to Add arduino plotter sketch with another sketch

jamipraveeen opened this issue · 11 comments

I want to monitor electrical parameters in real time. I have the following code with emon arduino sketch, I want to plot graph with the data from it usig arduino plotter, How to do that. The following code is below.
`#include <EmonLib.h>

// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3

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

void setup()
{
Serial.begin(250000);

emon1.voltage(2, 10000, 1.7); // Voltage: input pin, calibration, phase_shift
emon1.current(1, 500); // 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 (realpower, apparent power, Vrms, Irms, power factor)

float realPower = emon1.realPower; //extract Real Power into variable
float apparentPower = emon1.apparentPower; //extract Apparent Power into variable
float powerFActor = emon1.powerFactor; //extract Power Factor into Variable
float supplyVoltage = emon1.Vrms; //extract Vrms into Variable
float Irms = emon1.Irms; //extract Irms into Variable
}`

Check out some of the examples using multiple graphs and multiple variables.

You can't do any printing because the plotter relies on the serial port.

No, I want to use this code in your plotter sketch.Can you link both the sketches to get graph?

Yes, you just need to use the energy monitor values as your graphing variables.

Yes,but am not getting graph

Are you able to run the examples?

Yes, I am able to run your examples but how to integrate with my sketch

Please help me out how to integrate my sketch with your plotter sketch... I will add credits in my project

You can try something along these lines (Note this is untested):

// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3

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

#include "Plotter.h"
Plotter p;
float realPower;

void setup()
{
  emon1.voltage(2, 10000, 1.7); // Voltage: input pin, calibration, phase_shift
  emon1.current(1, 500); // Current: input pin, calibration.

  p = Plotter(); // create plotter
  p.AddTimeGraph( "Real power vs time", 500, "real power", realPower ); // add any graphs you want
}

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

  realPower = emon1.realPower; //extract Real Power into variable

  p.Plot();
}

graph is not visible i mean its not plotting

Can you post the output from the serial monitor? Baud rate needs to be 115200 and listener needs to be closed

Closing this. Feel free to reopen if you still need help.