Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tablatronix/3f67764d1bb565ff81c5e8be723ad765 to your computer and use it in GitHub Desktop.
Save tablatronix/3f67764d1bb565ff81c5e8be723ad765 to your computer and use it in GitHub Desktop.
A small Arduino program to measure AC voltage using a voltage transformer
// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3
#include "EmonLib.h" // Include Emon Library
#define VOLT_CAL 148.7
EnergyMonitor emon1; // Create an instance
void setup()
{
Serial.begin(9600);
emon1.voltage(1, VOLT_CAL, 1.7); // Voltage: input pin, calibration, phase_shift
}
void loop()
{
emon1.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out
float supplyVoltage = emon1.Vrms; //extract Vrms into Variable
Serial.println(supplyVoltage);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment