Hi everyone.
How can I mensure the current in an especific analogic pin?
In the exemple who follow the Emon.lib (current only), the reference pin, it's "1", and when print the Irms variable, it's print's the current of the pin 1, how can i print the current, of an especif pin? For example, i have 10 current sensors, who was conect in the analog ports of my arduino (0-9), if i send "9" prnts the current of the sensor, who was conected at the por A9 in the arduino, if I send 4, prints the value os analog por 4...
I using this scketch as model:
// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3
#include "EmonLib.h" // Include Emon Library
EnergyMonitor emon1; // Create an instance
void setup()
{
Serial.begin(9600);
emon1.current(1, 111.1); // Current: input pin, calibration.
}
void loop()
{
double Irms = emon1.calcIrms(1480); // Calculate Irms only
Serial.print(Irms*230.0); // Apparent power
Serial.print(" ");
Serial.println(Irms); // Irms
}
Re: Multiple pins current sensor
You need to expand your sketch to set up, then scan, all 10 inputs:
#include "EmonLib.h" // Include Emon Library EnergyMonitor emon1, emon2, emon3, emon4, emon5, emon6, emon7, emon8, emon9, emon10; // Create 10 instances void setup() { Serial.begin(9600); emon1.current(1, 111.1); // Current: input pin, calibration. emon2.current(2, 111.1); // Set the correct input pin for channel 2, calibration. // etc for emon3 - emon10 } void loop() { // Channel 1: double Irms = emon1.calcIrms(1480); // Calculate Irms only Serial.print(Irms*230.0); // Apparent power Serial.print(" "); Serial.println(Irms); // Irms // Channel 2 double Irms = emon2.calcIrms(1480); // Calculate Irms only Serial.print(Irms*230.0); // Apparent power Serial.print(" "); Serial.println(Irms); // Irms // etc for Channels 3 - 10 }