// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3 #include "EmonLib.h" // Include Emon Library EnergyMonitor emon1; // Create an instance int led = 8; void setup() { Serial.begin(9600); pinMode(led, OUTPUT); emon1.current(1, 111.1); // Current: input pin, calibration. }
void loop() { double Irms = emon1.calcIrms(1480); // Calculate Irms only Serial.print(Irms*230.0); // Apparent power Serial.print(" "); Serial.println(Irms); // Irms //delay(1500); if (Irms*230 > 60) { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) } else { digitalWrite(led, LOW); // turn the LED on (HIGH is the voltage level) } }