-
Notifications
You must be signed in to change notification settings - Fork 0
/
energy_monitor.ino
34 lines (24 loc) · 977 Bytes
/
energy_monitor.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3
#include "EmonLib.h" // Include Emon Library
#define VOLT_CAL 333.1
#define CURRENT_CAL 61.6
EnergyMonitor emon1; // Create an instance
void setup()
{
Serial.begin(9600);
emon1.voltage(1, VOLT_CAL, 1.7); // Voltage: input pin, calibration, phase_shift
emon1.current(0, CURRENT_CAL); // Current: input pin, calibration.
}
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
Serial.print("Voltage: ");
Serial.println(supplyVoltage);
Serial.print("Current: ");
Serial.println(currentDraw);
Serial.print("Watts: ");
Serial.println(currentDraw * supplyVoltage);
Serial.println("\n\n");
}