115 Volt AC current sensing sketch
Ruddog Nov 28th, 2018 (edited) 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- // R Trujillo
- // 11/28/2018
- // Monitoring current draw on a 115VAC line.
- #include "EmonLib.h" // Include Emon Library
- EnergyMonitor emon1; // Create an instance
- void setup()
- emon1.current(A0, 111.1);// Current: input pin, cal
- double Irms = emon1.calcIrms(1480); // Calculate Irms only
- //int ON = 0;
- int washer=0;
- void loop()
- Irms = emon1.calcIrms(1480); // Calculate Irms only
- // This first if statement allows the current to
- // settle as there is some garbage displayed
- // in the com port serial monitor port.
- if (Irms > 3)
- Serial.println("Current settling");
- // This statement is executed only if the conditions
- // are met. With washer = 0 it will be bypassed even
- // if the current conditions are met.
- if (Irms > 2.4 && Irms <=2.5 && washer==1)
- Serial.println("Contents Washer ON");
- washer = 0;
- // Conditions zero current and washer equaling zer0
- // is the condition that must be met to carry out
- // the push statement(which has not been written
- // yet and help is needed to get this working
- // I would like the IFTTT code to live in the if statement
- // below and call the IFTTT.
- if (Irms < 0.5 && washer==0)
- Serial.println("Contents Washer OFF");
- washer = 1;
RAW Paste Data