Ruddog

NodeMCU_SCT-013_Current_Sensing_Settle?

Nov 19th, 2018
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include "EmonLib.h"                    // Include Emon Library
  2. EnergyMonitor emon1;                    // Create an instance
  3.  
  4. void setup()
  5. {
  6.   Serial.begin(115200);
  7.   delay(1000);
  8.   emon1.current(A0, 111.1);// Current: input pin, cal
  9.  
  10. }
  11. double Irms = emon1.calcIrms(1480);  // Calculate Irms only
  12. void loop()
  13. {
  14. delay(1000);
  15. Irms = emon1.calcIrms(1480);  // Calculate Irms only
  16.  
  17. if (Irms < .2)
  18. {
  19.   Serial.println("No Current");
  20.   Serial.println(Irms);
  21. }
  22. else if (Irms >= 1.2)
  23. {
  24.   Serial.println("Current ON");
  25.   Serial.println(Irms);
  26. }
  27. else
  28. {
  29.   Serial.println("Transtion between on and off or visa versa");
  30. }
  31. }
Add Comment
Please, Sign In to add comment