Hi all,
I am trying to measure voltages from 2 pins, wall voltage into A1 and analog readings from a microphone into A4.
My code works separately in isolation (separately, I can accurately measure wall plug voltage and get variations of voltage from my microphone). However when I put the code together to try measure both sets of readings together, both readings are the same/i get 0 readings from both.
Below is the code, any help is very much appreciated!
#include "EmonLib.h" // Include Emon Library
#define VOLT_CAL 266.7
#define CURRENT_CAL 3.5
EnergyMonitor emon1; // Create an instance
void setup()
{
Serial.begin(9600);
Serial.println("CLEARDATE");
Serial.println("LABEL, DATE, TIME,Wall Voltage,Wall Current, Wall Power, Mic Voltage");
emon1.voltage(A0, VOLT_CAL, 1.7); // Voltage: input pin, calibration, phase_shift
emon1.current(A1, CURRENT_CAL); // Current: input pin, calibration.
emon1.voltage(A4, VOLT_CAL, 1.7);
}
void loop()
{
emon1.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out
float currentDraw = emon1.Irms; //extract Irms into Variable
float supplyVoltage = emon1.Vrms; //extract Vrms into Variable
float micVoltage = emon1.Vrms; //extract Vrms into Variable
Serial.println( (String) "DATA,DATE,TIME," + supplyVoltage + "," + currentDraw + "," + supplyVoltage*currentDraw + "," + micVoltage);
}