/ EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3
#include "EmonLib.h" // Include Emon Library EnergyMonitor emon1; // Create an instance #include <LiquidCrystal.h> LiquidCrystal lcd(12,11,5,4,3,2); int Lampe = 8; int Aspi = 9; void setup() { Serial.begin(9600); pinMode(Lampe, OUTPUT); emon1.current(1, 111.1); // Current: input pin, calibration. lcd.begin(16,2); lcd.clear(); // on efface l'écran } void loop() { double Irms = emon1.calcIrms(1480); // Calculate Irms only // Serial.print(Irms*230.0); // Apparent power // Serial.print(" "); //Serial.println(Irms); // Irms delay(500); lcd.begin(16,2); lcd.clear(); // on efface l'écran if (Irms*230 > 230) { lcd.print("MOTEUR EN MARCHE "); lcd.setCursor(0,1); //on passe à la ligne suivante lcd.print("P = "); lcd.print(Irms*230); // on finit d'écrire lcd.print(" W"); digitalWrite(Lampe, LOW); // turn the LED on (HIGH is the voltage level) digitalWrite(Aspi, LOW); } else { digitalWrite(Lampe, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(Aspi, HIGH); lcd.print("MOTEUR A L'ARRET"); // on écrit Bonjour lcd.setCursor(0,1); //on passe à la ligne suivante lcd.print("P = "); lcd.print(Irms*230); // on finit d'écrire lcd.print(" W"); } }