Open energy monitor on esp8266?

Hello, I'm working on like alot of other people to monitor my home. I'm not using any automated home system. I just wanted to make a Engery monitor system to monitor. I'm having problems Understanding the code just a bit. I'm using the emonLib Library here https://github.com/openenergymonitor/EmonLib Using the example Current Sketch https://github.com/openenergymonitor/EmonLib/blob/master/examples/current_only/current_only.ino. Most people that I search seen online is running 50Hz and 230v. Sense I'm in the USA I'm at 120v 60Hz.

What I'm having prioblem is in the code understanding
emon1.current(1, 111.1); // Current: input pin, calibration.
In there the first 1 is the analog pin but the 111.1 the calibration number is what I'm having problems trying to understand or What I need to change to for my Setup being I'm using 60Hz and 120v.

Second part is double Irms = emon1.calcIrms(1480); // Calculate Irms only.
I just don't know what to changes these two to suit my setup. I try to look up the information but very confusing.

Onto the hardware. I'm using an esp8266 because of the Wifi. Here is a image of what I'm using for my setup

I just need help to figure out the two area that I'm confused on. someone please help me?

Joseph

I suppose your code prints the value of current being read by your system to serial monitor (If open) , but the question is , how accurate is it ?

that's when the calibration factor ie: 111.1 comes in

you need to have a 'real' DMM ( the one with good accuracy and precision ) to compare your home-made meter's reading against

and all you have to do is modify the calibration factor ie: 111.1, until the Serial.println(Irms); matches the DMM's reading ( that's hooked up to your circuit and set to measure AC current )

And for the double Irms = emon1.calcIrms(1480);

1480 refers to number of samples when calculating the RMS value of current, you can change it, see here and here

I do have a Fluke amp clamp for my multimeter. I never through of comparing it to the Arduino one. I will try that. So the 111.1 is for the accuracy of the clamp and higher or lower number to adjust it to get it as close to my fluke meter, I didn't not know that. Thank you.

totally

here is the code (not tested) where you can modify calib. factor on the fly from serial console


#include "EmonLib.h"                   // Include Emon Library
EnergyMonitor emon1;                   // Create an instance

const byte thePin = 1;

void setup() {
  Serial.begin(9600);

  emon1.current(thePin, 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

  checkSerial();
}

void checkSerial() {
  if ( Serial.available() ) {
    String buff = "";
    while (Serial.available()) {
      delay(1);
      char c = Serial.read();
      buff += c;
    } // end while
    if ( buff.length() >= 1 ) {
      Serial.println("input: " + buff);

      buff.replace("\r", "");
      buff.replace("\n", "");

      float calibFac = buff.toFloat(); // buff.toDouble();

      emon1.current(thePin, calibFac);
    }
  }
}

Hello I'm trying the example code out from the library. Same thing. Only thing I changed is the 230v to 120v.

124.06 1.03
122.50 1.02
123.67 1.03
124.82 1.04
122.57 1.02
124.43 1.04
123.21 1.03
124.53 1.04
122.11 1.02
123.72 1.03
121.13 1.01
121.92 1.02
121.97 1.02

This is what is displaying on the serial monitoring.
I'm using it on a 19w Led flood bulb. I'm not sure what the first set of numbers means 121.97 or the second set of 1.02?

I use the online calculator https://www.rapidtables.com/calc/electric/watt-volt-amp-calculator.html It says at 19w at 120v it should be 0.17 amps.

Edit: I can not find my fluke clamp at the moment. It looks like the 1.02 is the ampsbut still not sure what the 121.97 means it keeps changing.

kindly post the code here using code tags please

// 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(0, 111.1);             // Current: input pin, calibration.
}

void loop()
{
  double Irms = emon1.calcIrms(1480);  // Calculate Irms only
  
  Serial.print(Irms*120.0);	       // Apparent power
  Serial.print(" ");
  Serial.println(Irms);		       // Irms
  delay(1000);
}

121.97 is apparent Power ( in VA , slightly equals Watts )

1.02 is current (amps) that's way off the expected 0.17A

were you modifying 111.1 ?

I don't know which resistor I need between the blue CT clamp. Some say 33ohms and others says 100ohms resistor. All agree the two other resistors are 10k resistors. I tried both. I got different readings. The 111.1 never changed.

The strange thing is the 100hms resistor one says put betwen Tip of the ct clamp connector and betwen the 2 10k resistors. the 33ohms resistor one shows it between Tip and sleeve connections. I honestly not sure what is correct and getting different readings.

The value "111.1" is a value to calibrate the measurement. You need as accurate a current as possible to pass through the SCT013AC. Then you have to adjust the value "111.1" in your program until you get the expected current as a result.

is it a 33ohms resistor or a 100ohms resistor on the burned resistor?

Hello Just an update. I mange to get the code to work on a single sensor. It comes up as

104.87 0.87

103.19 0.86

99.98 0.83

102.71 0.86

104.04 0.87

From my understanding the 104.04 is the volts times the current to get watts and second number is the current itself.

Here is the sketch i changed from the default Emon library.

// 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(A0, 55);             // Current: input pin, calibration.
}

void loop()
{
  double Irms = emon1.calcIrms(1480);  // Calculate Irms only
  
  Serial.print(Irms*120.0);	       // Apparent power
  Serial.print(" ");
  Serial.println(Irms);		       // Irms
  Serial.print("\n");

  delay(1000);
}

I'm adding a second sensor. I only have two sensors. When I add two I get this.

First sensor

100.02 0.83

Second sensor

102.64 0.86

First sensor

102.69 0.86

Second sensor

102.53 0.85

This is my new code

// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3

#include "EmonLib.h"                   // Include Emon Library
EnergyMonitor emon1;                   // Create an instance
EnergyMonitor emon2;                   // Create an instance

void setup()
{  
  Serial.begin(9600);
  
  emon1.current(A0, 55);             // Current: input pin, calibration.
  emon2.current(A1, 0.4);             // Current: input pin, calibration.
}

void loop()
{
  double Irms = emon1.calcIrms(1480);  // Calculate Irms only
  double Irms2 = emon2.calcIrms(1480);  // Calculate Irms only
   Serial.print("First sensor");   // Irms
  Serial.print("\n");
  Serial.print(Irms*120.0);	       // Apparent power
  Serial.print(" ");
  Serial.println(Irms);
   Serial.print("\n");
  Serial.print("Second sensor");   // Irms
  Serial.print("\n");
  Serial.print(Irms2*120.0);	       // Apparent power
  Serial.print(" ");
  Serial.println(Irms2);	
  Serial.print("\n");	       // Irms
  delay(1000);
}

But If i disconnect the second sensor I get this.

First sensor

100.74 0.84

Second sensor

19.35 0.16

If I disconnect the first sensor it goes to zero. The other thing is in this area

emon1.current(A0, 55);
emon2.current(A1, 0.4);

Thbe second sensor I have to change it to 0.4 in order to match up with the first sensor which makes no sense. Can someone please help me out why the big difference?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.