Community
OpenEnergyMonitor

Community

Open energy monitor and arduino mega

Hi

i use arduino mega , and my problem are the result open energy monitor
i have realizzed the circuit for ct-013-030 and AC-AC adapter with te site openenergymonitor.org

my scketch

#include "EmonLib.h"             // Include Emon Library

#define VOLT_CAL 230.0
#define CURRENT_CAL 111.1

EnergyMonitor emon1;             // Create an instance

void setup()
{  
  Serial.begin(9600);
  
  emon1.voltage(8, VOLT_CAL, 1.7);  // Voltage: input pin, calibration, phase_shift
  emon1.current(9, CURRENT_CAL);       // Current: input pin, calibration.
}

void loop()
{
  emon1.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out

  float currentDraw            = emon1.Irms;             //extract Irms into Variable
  float supplyVoltage   = emon1.Vrms;                    //extract Vrms into Variable

  Serial.print("Voltage: ");
  Serial.println(supplyVoltage);
  
  Serial.print("Current: ");
  Serial.println(currentDraw);

  Serial.print("Watts: ");
  Serial.println(currentDraw * supplyVoltage);
  Serial.println("\n\n");

  Blynk.virtualWrite(V100, supplyVoltage);
  Blynk.virtualWrite(V101, currentDraw);
  Blynk.virtualWrite(V102, currentDraw * supplyVoltage);

}

and the result is

[6283] Time sync: OK
Current time: 11:59:0 13 6 2019
Voltage: 16.05
Current: 7.91
Watts: 126.98

in italy Voltage 230

why ??

Welcome to the forum.

Which circuit diagram did you use to make your analogue interface to the Arduino?

I do not know the precise details of an Arduino Mega.

Your voltage input is on AI 8
Your current input is on AI 9
Are you certain that these are the correct names for the pins that you are using for analogue inputs?

In setup(), if you insert:

Serial.print("Reference voltage: "); Serial.println (emon1.readVcc() / 1000.0);

what value does it print? It should be 5.0 if your Arduino Mega runs at 5 V.

I see you have some wrong values.

If you are using the Ideal 77DE-06-09-MI a.c. adapter, VOLT_CAL should be 260.0

For the SCT-013-030,
CURRENT_CAL should be 30.0 and you must NOT use a second (18, 22 or 33 Ω) burden resistor with this c.t., because there is already one inside the c.t.

Also, currentDraw * supplyVoltage is not the real power in watts, it is apparent power measured in VA (volt-amperes). emonLib calculates real power for you, and apparent power too:

  Serial.print("Watts: ");
  Serial.println(emon1.realPower);
  Serial.print("VA: ");
  Serial.println(emon1.apparentPower);

my circuit diagram are :
https://learn.openenergymonitor.org/electricity-monitoring/ctac/how-to-build-an-arduino-energy-monitor

I connect pin input in arduino PWM 9 and PWM8, my error is there? the pin correct are in arduino " analog in" and not PWM?
arduino mega runs at 12V whit dc external
my a.c. adapter is : mkc-230924v
and my sensor is SCT-013-030

i have used burden resistor 33ohm , because 30 ohm not find

Yes, that is your error. “PWM” (modulazione di larghezza di impulsi) is an output (uscita). If you find it hard to translate technical words, there is Electropedia (also known as the “IEV Online”), a comprehensive online electrical and electronic terminology database available at www.electropedia.org /

You must use an input (ingresso) pin - you have ADC 0 - 15. You must use these, one for the voltage and one for the current.

I cannot give you the correct VOLT_CAL for this, but it will be approximately the same as the Ideal one. I think the value will be between 230 - 300. You must measure your voltage and change VOLT_CAL to make your reading correct.

You must not use a burden resistor with that c.t. It is designed to give a voltage output, not current, therefore you do not need a burden resistor.

now the result is

Voltage: 35.18
Current: 217.93
Watts: 7667.04

When i turn on the phon the result are:

Voltage: 38.15
Current: 223.41
Watts: 8523.56

not function voltage in my house : 228V
ampere turn on the phon : 07,93

maybe the my sketch is incorrect

Your sketch looked correct to me, but the calibration is wrong. Are you sure you have the correct pins, and the circuit is wired correctly?

Look here:
Learn→Electricity Monitoring→Voltage Sensing→1. Measuring Voltage with an AC-ACPower Adapter→Measuring AC Voltage with an AC to AC power adapter
On that page is the circuit diagram for just the voltage measurement. Check that you have everything connected like that. If you have a voltmeter, check that the “mid-point” voltage is approximately 2.5 V d.c., and that the voltage from your a.c. adapter is approximately 11 V a.c. measured between “mid-point” and “adapter output” and approximately 1 V a.c. measured between “mid-point” and “Arduino input”.
If everything here is correct, you should read approximately 230 V with your Arduino.

When you have done that, look here:
Learn→Electricity Monitoring→CT Sensors→3. Interfacing with an Arduino→CT Sensors - Interfacing with an Arduino
It is almost the same circuit on that page, but there is one very important difference for you:
you must NOT have the resistor “Burden 33 Ω”.
Check that you have everything connected like that. Check that the “mid-point” voltage is approximately 2.5 V d.c., and that the voltage from your c.t. adapter is approximately 1 V a.c. measured between “mid-point” and “Arduino input” for 30 A of a.c current. (You might not be able to measure that - if you connect a 2 kW heater, you should read approximately ¼ V.)