forked from dttaylo2/Sensor_Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnergy_Monitor
41 lines (21 loc) · 785 Bytes
/
Energy_Monitor
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
35
36
37
38
39
40
41
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2
line display
#include "EmonLib.h" // Include Emon Library
EnergyMonitor emon1; // Create an instance
void setup()
{
Serial.begin(9600);
lcd.init(); // initialize the lcd
lcd.backlight(); // Turn on LCD Backlight
emon1.current(1, 111.1); // Current: input pin, calibration.
}
void loop()
{
double Irms = emon1.calcIrms(1480); // Calculate Irms only
double I = (Irms/5); // Compensate for five loops
Serial.println(I); // Irms
lcd.setCursor(0,0); // Set LCD position
lcd.print("Current: ");
lcd.print(I);
}