Skip to content

Instantly share code, notes, and snippets.

@ItKindaWorks
Created July 31, 2017 15:05
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ItKindaWorks/b5339cc122e029b85dcc1d1a465cd27b to your computer and use it in GitHub Desktop.
Save ItKindaWorks/b5339cc122e029b85dcc1d1a465cd27b 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