emonTx V2 newbie - no data [SOLVED]

Last weekend I did try my emonTx V2. However, I am not sure if I did all correctly.
Did I something wrong? I am completely lost.

I tried two sample codes:

This code I have aleatory data (values) while I have a reader connected. But when I remove it, I have only zeros:

// 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(3, 111.11);             // 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
}

This code, I have only zeros... all the time.

/*
    -----------------------------------------
  Part of the openenergymonitor.org project
  Licence: GNU GPL V3
*/ 

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

  int count = 0;
  float meassurements[20];
  float maximum = 0;
  float minimum = 0;
  float average_addition = 0;

void setup()
{  
  Serial.begin(9600);
  
  ct1.voltageTX(216.58, 1.7);          // Calibration, phase_shift
  ct1.currentTX(4, 111.1);             // CT channel, calibration.
  delay(50);
  
}

void loop()
{
  ct1.calcVI(20,2000);                 // Calculate all. No.of half wavelengths (crossings), time-out
  Serial.print(ct1.realPower);
  Serial.println(' ');
  
  meassurements[count] = ct1.realPower;
  count++;
  delay(50);

  if (count == 20){
    maximum = minimum = meassurements[0];
    average_addition = 0;
    for (int i=0; i<20; i++){
      if (meassurements[i] < minimum) minimum = meassurements[i];
      if (meassurements[i] > maximum) maximum = meassurements[i];
      average_addition += meassurements[i];      
    }
    float average = average_addition / 20;
    
    float nominador = 0;
    for(int i =0; i <20; i++){
       nominador += pow ((meassurements[i] - average),2);
    }
    float standard_deviation;
    standard_deviation = sqrt(nominador/20);
    m
    Serial.println("Max Min Average Standard-deviation");
    Serial.print(maximum);
    Serial.print(' ');
    Serial.print(minimum);
    Serial.print(' ');
    Serial.print(average);
    Serial.print(' ');
    Serial.print(standard_deviation);
    Serial.println(' ');
    Serial.println(' ');
    
    count = 0;
    delay(10000);
  }
}

Robert Wall's picture

Re: emonTx V2 newbie - no data [SOLVED]

What hardware do you have? EmonTx V2 + ( 5 V DC USB Power Supply OR FTDI Programmer )

Do you also have a Current Transformer?

Do you also have an AC-AC adapter?

If you have NO AC-AC adapter: Load this sketch: https://github.com/openenergymonitor/emonTxFirmware/tree/master/emonTxV2...

If you HAVE an AC-AC adapter: Load this sketch: https://github.com/openenergymonitor/emonTxFirmware/tree/master/emonTxV2...

allmac's picture

Re: emonTx V2 newbie - no data [SOLVED]

Hi... I have a EmonTx V2 + Arduino Duo. My steps were...

1) soldered all parts (http://shop.openenergymonitor.com/emontx-arduino-shield-smt/)
2) connected EmonTx to Arduino
3) connected CT sensor to EmonTx (and around my refrigerator power cord)
4) uploaded both codes

But I am not able to understand results in Arduino Terminal (no CT or 9V AC Sample connected)

emonTX CT1234 example
OpenEnergyMonitor.org
Node: 10 Freq: 433Mhz Network: 210
CT1:0 CT2:19686 CT3:0 CT4:19685 VCC:5120
CT1:0 CT2:79 CT3:0 CT4:80 VCC:5120
CT1:0 CT2:55 CT3:0 CT4:50 VCC:5120
CT1:0 CT2:49 CT3:0 CT4:45 VCC:5120

allmac's picture

Re: emonTx V2 newbie - no data [SOLVED]

 

I had the following data reading only CT1...
But I am not able to understand what should be reading, what changes it when Power-supply is connected. 

1) /emonTx_CT123.ino:

​emonTX CT123 example
OpenEnergyMonitor.org
Node: 10 Freq: 868Mhz Network: 210
0 19670 19712 5120
0 70 64 5120
0 37 26 5120
0 37 24 5120
0 32 22 5120
0 31 22 5120
0 31 28 5120
0 3 6 5120
0 5 16 5120
0 9 21 5120
 

2) emonTx_CT123_Voltage.ino:

emonTX CT123 Voltage example
OpenEnergyMonitor.org
Node: 10 Freq: 433Mhz Network: 210
0 0
emonTX CT123 Voltage example
OpenEnergyMonitor.org
Node: 10 Freq: 433Mhz Network: 210
0 0
 

3) emonTx_CT123_3Phase_Voltage.ino:

emonTX CT123 Voltage 3 Phase example
OpenEnergyMonitor.org
Node: 10 Freq: 868Mhz Network: 210
Voltage: nan
 Current 1: nan Power 1: nan VA 1: nan PF 1: nan
 Current 2: nan Power 2: nan VA 2: nan PF 2: nan
 Current 3: nan Power 3: nan VA 3: nan PF 3: nan

Voltage: nan
 Current 1: nan Power 1: nan VA 1: nan PF 1: nan
 Current 2: nan Power 2: nan VA 2: nan PF 2: nan
 Current 3: nan Power 3: nan VA 3: nan PF 3: nan

4) emonTx_Pulse.ino:

emonTX Pulse example
0W 0
0W 0
0W 0
0W 0

 

 

Robert Wall's picture

Re: emonTx V2 newbie - no data [SOLVED]

1. Please decide whether you have an emonTx V2 or an emonTx Shield V2 SMT. These are quite different, and require different sketches.

2. Read the sections about the current sensor in "CT and AC power adapter installation and calibration theory" in Building Blocks. You will never measure a meaningful current if your CT is on a two-core or 3-core cable. This is how a current transformer is fitted:

allmac's picture

Re: emonTx V2 newbie - no data [SOLVED]

I am sorry... it is an emonTx Shield V2 SMT. I will try to understand this.

I am using now shield sample. What make no sense to me is that CT1 to CT 4 are 0 (zero) while no CT connected. But when I connect a CT it shows a big number and count down until 0 (zero)... later shows continuously a small number (between 1 and 15), even if CT is not close to any eletric cable.

I am worry if it is really working or if I did something wrong soldering the board. Sorry for stupid doubts.

Robert Wall's picture

Re: emonTx V2 newbie - no data [SOLVED]

What you are seeing is the high pass filter in software settling, following the step change in input as you plug in the CT. It is perfectly normal. The small number after the filter has settled is digital noise from the processor leaking in to the analogue input. It will be smaller when you measure real power because the calculation averages the noise, but larger when you read current or apparent power because the rms calculation rectifies the noise. Again, that is normal and is usually less than 1% of the maximum reading.

allmac's picture

Re: emonTx V2 newbie - no data [SOLVED]

I did a try in my office "power room" and it really appears to be OK (Watts: 3967.79 / Current: 31.24).
Specially after all your explanations.
​Thanx a lot Robert.

No more stupid questions... promise.

 

Patric's picture

Re: emonTx V2 newbie - no data [SOLVED]

Hi!

I have same question regarding it´s always showing a value around 12-15 Watts regarding CT is on cable or not. Is it possible with calibration to get to zero?

When I light my 40 watts buld it´s showing 52 watts in emoncms. Dosen´t feel 1% accurate at all for me.

Thanks in advance
Patric

Robert Wall's picture

Re: emonTx V2 newbie - no data [SOLVED]

No, calibration only affects the ratio measured power : genuine power, it does not affect the zero.

Think: y = mx + c      -  'c' is the zero offset, 'm' is the calibration. 

Patric,  is the maximum power that you can measure 4 kW?  I think it is closer to 23 kW. 

Patric's picture

Re: emonTx V2 newbie - no data [SOLVED]

No, I haven´t tried to get max of my 10amp fuse. It should be 23  kW then. But I can´t understand why it´s always have to be +12watts then I measure my buld that is on 40 watts. Is it not more accurate then this? 

If I put CT on all of my 20 fuses it´s going to look that my house is consuming 300 watts even if everything is shut down.

Robert Wall's picture

Re: emonTx V2 newbie - no data [SOLVED]

And if you put a CT on the busbar or cable that supplies those 20 fuses, you will still read ~ 12 W. If you really only want to measure to 10 A, then you should remove the CT's burden resistor and replace it with one of higher value. A CT is a current source, so it is easy to calculate the resistance you need for the secondary current that corresponds to 10 A to develop the appropriate voltage. I don't know what you are using so I cannot be more specific.

dBC's picture

Re: emonTx V2 newbie - no data [SOLVED]

Think: y = mx + c      -  'c' is the zero offset, 'm' is the calibration. 

Now that you mention it, is there any reason you couldn't add a 'C' to the calibration process?  It would assume the background noise has a constant real component.  Do you think that would be wildly optimistic?

Robert Wall's picture

Re: emonTx V2 newbie - no data [SOLVED]

Yes! If you look at the "power factor" of the noise, it can be anything from one cycle to the next.
If you're looking at real power, then because the noise (which is most troublesome in the current input because the signal is small) is multiplied by the voltage - the sign of which alternates - so alternate half cycles tend to cancel to some extent, you tend to get a significantly smaller noise error value than if you look at current, where the squaring of the rms calculation immediately rectifies the noise so there's no possibility of cancellation happening.

The real problem is Patric is running at about 10% of full scale, and expecting 1% accuracy at 10% all with a 10-bit ADC - i.e. ±50 ADC steps to digitise the waveform - and he's using an Arduino, which we know is more susceptible to noise than the emonTx V2, which is more susceptible than the emonTx V3. That's a rough sum at 10 A, assuming he's using a 100 A CT.

What are the numbers at 40 W, which is what he's complaining about? Assuming he's on a 230 V system, 40 W ~= 174 mA rms, and again assuming 100 A max, that is 0.174% of max input, so the current signal is 5 ADC steps from peak to peak. I'll leave you to work out how realistic the expectation of any sort of accuracy is at those levels.

dBC's picture

Re: emonTx V2 newbie - no data [SOLVED]

Yes! If you look at the "power factor" of the noise, it can be anything from one cycle to the next.

But over some large number of cycles, wouldn't the noise's contribution to real power be roughly stable?  Any reason you couldn't subtract that value out?

he real problem is Patric is running at about 10% of full scale

Yes, and as you pointed out, that's easily solved.  But an increasing number of OEM users seem to be complaining about the background power level they're seeing, and I'm still having trouble getting my head around why you can't just subtract it out.   My energy IC certainly lets me do that.  I can subtract a Real Energy Offset, and a Reactive Energy Offset, although I need to be able to inject a very low level ideal input in order to measure the offsets required.

 

 

Robert Wall's picture

Re: emonTx V2 newbie - no data [SOLVED]

I think an increasing number of OEM users seem to be complaining about the background power level they're seeing, because I think we are only seeing the ones who use Arduino boards with a prototype stripboard/plugboard front end, and like Patric they are looking to measure currents accurately at around 10% or less of the available range. If they are happy and think they have an accurate measurement by subtracting a constant, that's fine. But surely it's better to at least alleviate the problem at source by scaling the input appropriately?

dBC's picture

Re: emonTx V2 newbie - no data [SOLVED]

Absolutely.  Just to be clear I totally agree with your suggestion as to what Patric should do, and have for this entire thread.

Now, can't we also discuss Patric's suggestion about using calibration to get rid of background power levels?  Is the observation that it's worse on Arduino/stripboard meters a reason not to see if we can improve it in software?

It seems to me there are multiple ways to measure that noise offset, clamp your CT around a dead circuit like Patric has, or calibrate at 2 points: say 2kW and 4kW, and solve the line.    If they've already done all they can to reduce noise, and they've scaled their CTs correctly for the job at hand, then, and only then, do you think that including a " + c " in the calibration process would further help?

Your comments about "noise power factor per cycle" and "think they have an accurate measurement by subtracting a constant" makes me think you think it's bogus, and I'm trying to understand why it's bogus.

Robert Wall's picture

Re: emonTx V2 newbie - no data [SOLVED]

Here is a very quick spreadsheet to show what happens. The "signal" is three cycle (50 samples, so reasonably representative) of a sine wave of 0 to 15 amplitude, to which is added RAND() * 3, then the rms is calculated and plotted against amplitude. So without the 'noise', you should have a straight line through the origin of slope 0.707.  

With the noise, this is what you get. Selecting the constant to give zero at zero current might appear to be correct, but is not the best solution in general. Plotting the curve for a lot of points would give the greatest confidence, but who's got the facilities to do that?

 

dBC's picture

Re: emonTx V2 newbie - no data [SOLVED]

I thought we were talking about Power rather than RMS values.  My spreadsheet takes a slightly different approach.  To simplify things, I assume a pure V (230V RMS), and a noisy I.  I start with a pure I at various current levels, and add in some noise.  I did 5 seconds worth of data, at 50 samples/cycle, and calculate Power the traditional way: Sigma(V*I) over the 5 seconds and then scaled back into Watts.

If you add white noise into I it has no impact on Power, because the pure V swing, the quality of your white noise and the lengthy 5 seconds of data ensures it averages 0.   For noise in I to have an impact on Power, there's got to be some correlation between the noise and V.  In real life, there's a myriad of sources for 50Hz noise in your current signal.  It could be as simple as cross-talk from the V measurements, or the other I measurements, or lots of other sources.

So for my noise, I used:

0.02*rand() + 0.0002 * V.

So the first component can add up to 20mA and the second component adds a pure in-sync sine wave to the noise, with a peak of 65mA.   I left it so I could tweak those contributions, and when you do you quickly see the first component makes no difference to the Power reading,  it's all in the second.  At those settings (plotted below), the noise contributes 10.6W to the power calculation (similar numbers to some of the anecdotal reports from the field).

Regardless of what current I dial up on my pure I signal, Power always over-reads 10.6W once I add in the noise.  In fact, it's obvious that it must (230V * 0.0002 * 230 = 10.58W)

 but who's got the facilities to do that?

Aren't we just talking about a beefy resistive load, a trustworthy plug-through power meter, and then 1, 2, and 3 primary windings through your CT?  That'll give you 3 points on the line, and it keeps you well away from the quantization errors you get if you try to measure down at 0.

Of course, all of that assumes that the component of the noise that is an in-sync sine wave is constant, and I agree that's a big assumption. But perhaps not as big an assumption as assuming it doesn't exist at all, which I think is what happens when you don't include a " + c" in your Power calibration.  Further in-situ measurements would help clarify that.

Robert Wall's picture

Re: emonTx V2 newbie - no data [SOLVED]

I thought we were talking about both power values, but concentrating on the apparent power, because that's where it is perceived to be the bigger problem.

If the residual noise contribution for real power is sufficiently stable, then it's probably acceptable to subtract a constant. But I don't think the same can be said for current and apparent power.

At least we can agree that the best solution is careful attention to earthing, screening and filtering so as to reduce the unwanted input in the first place.

dBC's picture

Re: emonTx V2 newbie - no data [SOLVED]

Yes, once the noise has gone through the RMS process, it's very hard to unscramble it.  I agree with your comments about keeping it out in the first place (with one exception noted below).  But whether you're building a meter with an Arduino and some stripboard, or you're designing a PCB for a leading meter manufacturer, there's always going to be noise.  The techniques for dealing with it are the same, it's just a matter of degree.  And wherever you live on the build spectrum, it's human nature (engineer's nature?) to want to extract the last bit of performance out of the hardware you've built.  But you also have to know the limitations of your hardware.  It's crazy quoting 6 decimal places of resolution, when your hardware design means most of those digits are nonsense.

When measuring very slow moving DC signals, noise is your friend.  My rainwater tank level only ever changes when it's raining, or someone turns a tap on, so it's a perfect opportunity for some serious oversampling.  I use a 4-20mA probe for that, and I can measure a dynamic range of 21mA (0 to 21) to a resolution of about 1.3uA all with an AVR 10-bit AtoD.  My Fluke current loop calibrator lets me knock up the current 1uA at a time, and I can see that appear in my dials (subject to my 1.3uA stickiness).  Without the noise to dither the fine detail out of the 10-bit chunkiness, I wouldn't achieve anything like that, it was just do big ~20uA steps instead.

I'm not sure dithering really helps with AC signals.  The AC component of the signal you're trying to measure is already shaking things around for you which is all dithering aims to achieve.  I guess if you were measuring a perfectly repetitive signal, and your timing was such that you started each conversion at exactly the same place on the signal each time around, then maybe some noise would help.

Oversampling an AC signal helps a lot.  I tell my energy chip to integrate the energy data for 10 seconds and then give it me, which I figure is a fairly friendly update rate to emoncms.  But it also has the benefit that on a steady-state house, the reading is rock solid, you're lucky to see a 0.5W change between 10 second readings, and it also means a 5W load being switched on shows up easily.  The obvious disadvantage is it can take up to 20 seconds for the dials to show the 5W load has been switched on.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.