Hi to all the Arduino Guru's,
I think I have a simple question, but I am unable to solve it.
I am using the Emonlib from openenergymonitor.org to read out a CT and 9VAC powersupply to measure power consumption of my PC.
I have been able to get this working, but I would like to output some of the data to a SerLCD, All the calculations are being done inside Emonlib.h and I can't find how to write this data to the SerLCD.
The first sketch outputs Vrms, Irms, Power Factor, Apparent and Real power to the Serial monitor.
But I need Vrms, Irms and Real Power to be outputted to the display.
Here are the 2 sketches I have made.
// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3
#include "EmonLib.h" // Include Emon Library
EnergyMonitor emon1; // Create an instance
void setup()
{
Serial.begin(9600);
emon1.voltage(2, 212.670, 1.7); // Voltage: input pin, calibration, phase_shift
emon1.current(1, 10.7); // Current: input pin, calibration.
}
void loop()
{
emon1.calcVI(20,2000); // Calculate all. No.of wavelengths, time-out
emon1.serialprint(); // Print out all variables
}
// SparkFun Serial LCD example 2
// Format and display fake RPM and temperature data
// This sketch is for Arduino versions 1.0 and later
// If you're using an Arduino version older than 1.0, use
// the other example code available on the tutorial page.
// Use the softwareserial library to create a new "soft" serial port
// for the display. This prevents display corruption when uploading code.
#include <SoftwareSerial.h>
// Attach the serial display's RX line to digital pin 2
SoftwareSerial mySerial(3,2); // pin 2 = TX, pin 3 = RX (unused)
void setup()
{
mySerial.begin(9600); // set up serial port for 9600 baud
delay(1000); // wait for display to boot up
mySerial.write(254); // cursor to beginning of first line
mySerial.write(128);
mySerial.write("U= V AC Power"); // clear display + legends
mySerial.write("I= A W");
mySerial.write("U= V DC Power");
mySerial.write("I= A W");
}
void loop()
{
mySerial.write(254); // cursor to 4th position on first line
mySerial.write(131);
mySerial.print(Vrms); // write out the VAC value
mySerial.write(254); // cursor to 4th position on second line
mySerial.write(195);
mySerial.write("bla"); // write out the AAC value
mySerial.write(254); // cursor to 4th position on second line
mySerial.write(204);
mySerial.write("bla"); // write out the AAC value
delay(1000); // short delay
}