EmonTx (no RF) question

Hello,

I'm playing with my emonTx (without RF) and 1 voltage and 3 current sensors (all orginal openenergy).

My idea is to connect the Rpi to my arduino (USB serial) , i tried that and it works fine!

I have the following arduino software:

[code]

#include "EmonLib.h"                   // Include Emon Library
EnergyMonitor emon1, emon2, emon3;      // Create tree instances

void setup()

  Serial.begin(9600);
  emon1.voltage(0, 234.26, 1.7);  // Voltage: input pin, calibration, phase_shift
  emon1.current(1, 111.1);             // Current: input pin, calibration.
  emon2.voltage(0, 234.26, 1.7);  // Voltage: input pin, calibration, phase_shift
  emon2.current(2, 111.1);             // Current: input pin, calibration.
  emon3.voltage(0, 234.26, 1.7);  // Voltage: input pin, calibration, phase_shift
  emon3.current(3, 111.1);             // Current: input pin, calibration.
 
}

void loop()
{
  emon1.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out
  Serial.println("CT 1:");
  emon1.serialprint();           // Print out all variables

  emon2.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out
  Serial.println("CT 2:");
  emon2.serialprint();           // Print out all variables
 
  emon3.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out
  Serial.println("CT 2:");
  emon3.serialprint();           // Print out all variables
}

[/code]

When i take a look to my serial output i see the following values:

CT 1:
-475.78 1707.07 231.89 7.36 -0.28
CT 2:
16.61 208.05 232.66 0.89 0.08
CT 2:
753.23 895.12 230.48 3.88 0.84
CT 1:
-156.12 631.12 231.66 2.72 -0.25
CT 2:
13.39 205.52 233.68 0.88 0.07
CT 2:
792.80 924.17 232.96 3.97 0.86
CT 1:
-167.20 602.54 232.29 2.59 -0.28
CT 2:
1.69 209.64 232.43 0.90 0.01
CT 2:
772.37 903.69 233.85 3.86 0.85

(i know i used 2x CT 2 :x ).

The question i have:

1. How is a negative value possible? (CT 1)

2. Is a calibration necessary ? (or can i work with the default values).

3. And i try to understand the calibration but i can't follow that story (my english isn't that good :( ).

4. Is the code i used good? (because i see severally explanations) 

Thank you!

Regards,

Rob

 

jagerp's picture

Re: EmonTx (no RF) question

Hi Rob,

From your post your English is pretty good to me in fact it is much better than other "English speaking" people I know. 

 

In relation to your question is it possible you have 'CT1" orientated a different way to the other CTs for example the arrow on the CT is in opposition to the current flow in the cable you have it installed on.

 

Regards Paul

RobV's picture

Re: EmonTx (no RF) question

Hi Paul,

I tried changed CT1 with CT2 but no result (CT1 and CT2 are both negative).

I tried tho mount the CT1 on the other way (turn around) but the results are more negative.

And it looks like it's only on "low" power.

Regards,

Robert

RobV's picture

Re: EmonTx (no RF) question

I tried also the next thing:

I disconnected CT1 and CT2 (with closed clamp) and i get those values:

CT 1:
-35.59 173.91 225.61 0.77 -0.20
CT 2:
-25.32 210.49 224.91 0.94 -0.12
CT 2:
648.35 771.14 225.05 3.43 0.84

It looks like they are measuring something?

RobV's picture

Re: EmonTx (no RF) question

I think i have to build my arduino into a metal case or something.. I tested again on my desk and the values are less..

 

Robert Wall's picture

Re: EmonTx (no RF) question

What is your construction method? - you say emonTx at the top but refer to Arduino elsewhere. Anecdotally, people who use Arduino boards and prototype boards (stripboard, plugboard) for the input circuitry seem to have experienced more noise pickup and spurious readings - as you are seeing - than people who use the emonTx kit. It has been suggested that a 2n2 capacitor connected from the processor input pin for the current inputs to ground is a cure for noise pickup. It should have no significant effect on the desired signal, but I have not tested it.

RobV's picture

Re: EmonTx (no RF) question

I have a arduino uno and i connected the orginal emonTx (without RF) directly on the arduino uno.

I will test the 2n2 capacitor soon!

Ps, how is it possible that i get negative values like i said into the first post?

Robert Wall's picture

Re: EmonTx (no RF) question

The sign refers to the direction of power flow. You can read up how the emonTx does the maths in Building Blocks.

Calibration is not necessary, the default values should give you reasonable results, but if you want the best accuracy, then you should calibrate.

RobV's picture

Re: EmonTx (no RF) question

I tested with a 2n2 capacitor but i got the same results :(

 

Robert Wall's picture

Re: EmonTx (no RF) question

Why are you connecting an emonTx to an Arduino Uno? I think you are reading digital noise that is getting in to the analogue input, or into the analogue reference voltage via the power supply. It is possible that this digital noise is coming from the Uno. Another possible source of noise is a poor quality 5 V power supply. See Not all USB power adapters are created equal.

dBC's picture

Re: EmonTx (no RF) question

or into the analogue reference voltage via the power supply.

Now that you mention that, Atmel call for AVCC to be connected to VCC via an LC network (Fig 23-9 in the datasheet),  and yet very few Arduino designs do that, and nor does emonTx since it's based on them.   Does anyone know the history of that?

RobV's picture

Re: EmonTx (no RF) question

@Robert,

I have also a 9vdc battery connected to my arduino but with the same results.

I ordered also a mega 2560 and i got the same results on that board :(

 

 

Robert Wall's picture

Re: EmonTx (no RF) question

RobV:
What result do you get with your emonTx connected to a good clean power supply, with the voltage input connected but with the c.t's off their cables and unplugged, sending the results by radio (meaning no other connection to the outside world)?

dBC:
Why not take a look at Atmel's App.Note? (Hint: the emonTx is based on that and it doesn't decouple the Aref either!). And a pre-emptive answer to the inevitable question: NO, I don't know either.

 

dBC's picture

Re: EmonTx (no RF) question

Why not take a look at Atmel's App.Note?

Which one?  "AVR042: AVR Hardware Design Considerations" certainly shows it in Fig 6-1.

Hint: the emonTx is based on that and it doesn't decouple the Aref either!

Actually, I was talking about AVCC not AREF.  I assume that's a typo on your part, because emonTx does decouple AREF right?

Robert Wall's picture

Re: EmonTx (no RF) question

You're right, it was a typo. I can't remember now which note it was, but I was rather surprised there was no decoupling, as they're fairly insistent on good layout practice etc. AVR465 does show it too, so it wasn't that one. I'm wondering now whether I was looking at an incomplete diagram.

We haven't yet proved that noise is the problem, but it seems to me the likeliest cause of the erroneous readings that we've seen.

dBC's picture

Re: EmonTx (no RF) question

I'm wondering now whether I was looking at an incomplete diagram

Is it possible you were looking at an Arduino schematic?  As far as I can see, the only official Arduino design to include the LC network is the Leonardo.  That may provide a fairly painless way to determine if it's the lack of LC network causing the problem, at least if you can replicate it on the shield-based solutions.

RobV's picture

Re: EmonTx (no RF) question

@Robert,

I don't have RF so i have to use the USB port to monitor the values :(

Maybe i will connect a LCD display soon so i can use the LCD to monitor.

Another question where in the CPP file can i add a offset to set the input to the 0 value?

My situation right now: i disconnected the power wires and i made some new wires with 3 turns (so my measuring will be 3x higher)  and i add a diverter (/3) into the CPP file. with this solution my noise also diverted to 3.

Maybe another detail, i ordered my arduino at dx.com (i don't know if it orginal?)

Robert Wall's picture

Re: EmonTx (no RF) question

That tells me without doubt that you are measuring noise. Tell me again what you are using. Is it an emonTx from the openenergymonitor shop but without the RFM12B module?

How does the Arduino Uno relate to your problem?

RobV's picture

Re: EmonTx (no RF) question

Yes Robert, i explain that earlier.

I have 2 arduino's

1. Uno

2. Mega

Same problems.

Robert Wall's picture

Re: EmonTx (no RF) question

So you do not have an emonTx?

There are many ways that the wrong readings could be generated.

First, it could be digital noise from the processor finding its way into the ADC, either by the signal input or by the supply AVcc. as dBC wrote above, the Arduino boards don't appear to include the filter here that Atmel recommends.

Second, it could be pick-up from the circuits you are measuring or from adjacent circuits.

Third, it could be due to circulating ground currents between power supply, the computer you are using to monitor, and the analogue circuits.

Fourth, it could be from a poor quality 5 V power supply, but as you get the same from a 9 V battery, in this case it is not that.

Are your current transformers connected like this: http://openenergymonitor.org/emon/buildingblocks/ct-sensors-interface

Which current transformer are you using and what is the value of your burden resistor?

RobV's picture

Re: EmonTx (no RF) question

Hi Robert,

I have the following configuration:

1. Arduino uno : http://dx.com/p/x1301-uno-r3-starter-singlechip-set-kit-multicolored-961192965

2. http://shop.openenergymonitor.com/emontx-shield-kit-no-rf/

3. 3x http://shop.openenergymonitor.com/100a-max-clip-on-current-sensor-ct/

4. http://shop.openenergymonitor.com/ac-ac-adapter-euro-plug/

Thats exact my configuration :)

And yes maybe it is one of the problems you mentiont i will try some thing.

But about the filter where can i a how to made a filter layout?

Thank you!

dBC's picture

Re: EmonTx (no RF) question

But about the filter where can i a how to made a filter layout?

I doubt you'll be able to successfully retro-fit the LC network to your Uno.  However, if you're up for spending another $25 you could purchase an Arduino Leonardo and see if that improves things.  The Leonardo has the Atmel specified LC filter between VCC and AVCC.    There's no guarantees it will fix your problem, but it would go some way to determining if the missing LC filter is relevant.

Robert Wall's picture

Re: EmonTx (no RF) question

There is a big difference between an emonTx and an emonTx shield!

You will probably not be able to fit a filter to your Arduino - that should have been done when the circuit board was designed.

Are you certain that you have the correct components fitted, especially the 33 R burden resistors R3, R5, R16 & R22?

[Edit]
Compare it carefully with this photo: http://cdn2.bigcommerce.com/server4400/98a75/products/78/images/183/emon... and check that the colour code on each component is the same as the picture, and the electrolytic capacitors are the right way round.
[/Edit]

In your first post:
CT 1:
-167.20 602.54 232.29 2.59 -0.28
CT 2:
1.69 209.64 232.43 0.90 0.01
CT 2:
772.37 903.69 233.85 3.86 0.85

and later:
CT 1:
-35.59 173.91 225.61 0.77 -0.20
CT 2:
-25.32 210.49 224.91 0.94 -0.12
CT 2:
648.35 771.14 225.05 3.43 0.84

The numbers I have marked are current, these are far too high. I would expect to see small numbers ~ 0.2 maximum. You are using the wrong current calibration factor, it should be 60.6 here: emon1.current(1, 111.1); but that only partly explains the problem - when you correct this it will change 3.86 to 2.10 which is still at least 10 times too big.

I have only now looked at the circuit diagram of the emonTx shield. If the diagram is correct, and it is, I think I can see what your problem might be.
The drawing shows the body of the socket and the sleeve of the plug connecting to the ADC input. If the cable screen is connected to the plug sleeve and you have high voltages close by, that would explain the high current that you see [edit] if there is mistake in your assembly [/edit]. If you take the c.t's off their cables and unplug them all from the shield (but leave the voltage input plugged in and on, working), what currents do you see?

[Edit]
Can you also check that the ground connection between your shield and the Arduino board is good.

RobV's picture

Re: EmonTx (no RF) question

Hi Robert,

I checked the hardware and the hardware is OK.

Right now i have values like:

CT 1:
0.01,0.04,0.43,0.10,0.22,
CT 2:
0.02,0.11,0.40,0.27,0.21,
CT 3:
0.01,0.12,0.47,0.25,0.12,
CT 1:
0.00,0.07,0.54,0.13,0.00,
CT 2:
0.03,0.13,0.49,0.27,0.21,
CT 3:
0.03,0.13,0.52,0.25,0.25,
CT 1:
0.02,0.08,0.51,0.16,0.22,
CT 2:
0.07,0.18,0.65,0.28,0.41,
CT 3:
0.02,0.12,0.50,0.25,0.15,
CT 1:
0.02,0.06,0.47,0.13,0.26,
CT 2:
0.06,0.12,0.45,0.27,0.47,
CT 3:
0.02,0.12,0.48,0.25,0.17,

CT 1:
0.04,0.12,0.55,0.22,0.33,
CT 2:
-0.01,0.14,0.55,0.26,-0.11,
CT 3:
0.01,0.13,0.54,0.24,0.11,
CT 1:
0.04,0.11,0.54,0.21,0.38,
CT 2:
0.07,0.15,0.54,0.27,0.47,
CT 3:
0.02,0.13,0.52,0.25,0.15,
CT 1:
0.02,0.08,0.52,0.15,0.20,
CT 2:
0.05,0.14,0.55,0.26,0.32,
CT 3:
-0.01,0.15,0.65,0.23,-0.04,
CT 1:
0.02,0.10,0.57,0.18,0.15,
CT 2:
0.02,0.14,0.54,0.25,0.16,
CT 3:
-0.02,0.14,0.61,0.24,-0.17,

This is just my arduino connected to my PC and 3x a current clamp without connecting to the wires.

And about the values i posted before.

In my first post my question was "Why are those negative?"

The post later was with disconnected CT 1 and CT 2 (CT 3 was still on the line).

Above are the values right know WITHOUT anything on the clamps.

Robert Wall's picture

Re: EmonTx (no RF) question

Those values are much better but still high - you now have  ~0.25 A of current showing on CT2 & CT 3, CT 1 is sometimes better.

Are you using the correct current calibration factor now?

Are your current transformers unplugged from the shield?

In my first post my question was "Why are those negative?"  You get negative power if the current is flowing in the opposite direction. It is explained here. You can reverse the sign by turning the c.t. around on its wire, but you said you did that and the numbers got more negative. That means you are getting readings that are not coming from the current in the cable that the c.t. is clipped onto. The true current is half the difference and the 'false' current is the average of the two readings.

RobV's picture

Re: EmonTx (no RF) question

I use the default current calibration right now.

I changed that before but without big difference.

The current transformers are plugged into the shield.

I think im going to build the arduino into a metal case maybe this will solve my problem.

Robert Wall's picture

Re: EmonTx (no RF) question

The correct calibration for the emonTx Shield is 60.6. That is the default value in the Shield example sketch.

Unplug the c.t's from the shield and post the values you see.

Robert Wall's picture

Re: EmonTx (no RF) question

Just for reference, I have loaded a standard emonTx (NOT the shield) with the "emonTx_CT123_Voltage" sketch and get this It is calibrated to read 100 A with 15 Ω burden resistors (current calibration factor = 138.8), voltage sensor connected and working, no c.t's connected, powered via FTDI programmer & laptop USB 5 V. The emonTx is uncased - it was actually resting on the laptop keyboard to record these numbers:

CT 1: 2.44 26.12 248.80 0.10 0.09
CT 2: 4.80 33.16 248.83 0.13 0.14
CT 3: 2.26 30.25 248.69 0.12 0.07
CT 1: 4.21 31.76 248.51 0.13 0.13
CT 2: 5.47 33.50 248.60 0.13 0.16
CT 3: 1.32 29.93 248.26 0.12 0.04

So you should expect the current read by CT2 & CT3 to come down a little more yet before I would say the results are acceptable.

RobV's picture

Re: EmonTx (no RF) question

Hi Robert,

I changed the calibration to 60.6 and i see the following values:

CT 1:
0.00,0.02,0.36,0.05,0.19,
CT 2:
0.02,0.07,0.43,0.16,0.31,
CT 3:
0.02,0.07,0.49,0.14,0.26,
CT 1:
0.02,0.07,0.53,0.13,0.24,
CT 2:
0.05,0.12,0.70,0.17,0.47,
CT 3:
0.01,0.08,0.57,0.13,0.09,
CT 1:
0.02,0.08,0.54,0.14,0.29,
CT 2:
0.02,0.09,0.61,0.16,0.26,
CT 3:
0.02,0.07,0.57,0.13,0.26,
CT 1:
0.02,0.07,0.54,0.14,0.27,

CT 2:
0.02,0.07,0.44,0.15,0.35,
CT 3:
0.01,0.06,0.43,0.14,0.22,
CT 1:
0.05,0.15,0.77,0.19,0.33,
CT 2:
0.04,0.11,0.73,0.15,0.35,
CT 3:
0.00,0.06,0.55,0.11,0.03,
CT 1:
0.06,0.13,0.72,0.18,0.42,
CT 2:
0.01,0.07,0.55,0.13,0.10,
CT 3:
0.02,0.05,0.37,0.15,0.31,
CT 1:
-0.00,0.03,0.43,0.07,-0.03,
CT 2:
0.05,0.09,0.56,0.17,0.58,
CT 3:
0.02,0.06,0.44,0.15,0.27,
CT 1:
0.01,0.02,0.36,0.06,0.26,
CT 2:
0.02,0.08,0.52,0.15,0.29,
CT 3:
0.00,0.07,0.54,0.12,0.06,
CT 1:
0.05,0.12,0.65,0.19,0.40,
CT 2:
0.01,0.08,0.57,0.14,0.15,
CT 3:
0.00,0.07,0.55,0.12,0.07,
CT 1:
0.02,0.08,0.59,0.14,0.28,
CT 2:
0.01,0.08,0.54,0.14,0.17,

A littlebit unstable but i think it's better?

This are the values with current sensors connected:

CT 1:
0.01,0.03,0.37,0.08,0.19,
CT 2:
0.00,0.01,0.22,0.05,0.22,
CT 3:
-0.00,0.05,0.48,0.11,-0.04,
CT 1:
-0.00,0.08,0.54,0.15,-0.00,
CT 2:
0.06,0.12,0.58,0.20,0.52,
CT 3:
-0.01,0.06,0.52,0.11,-0.14,
CT 1:
0.02,0.08,0.55,0.15,0.20,
CT 2:
-0.00,0.07,0.54,0.13,-0.04,
CT 3:
0.01,0.02,0.15,0.15,0.23,
CT 1:
0.00,0.01,0.28,0.03,0.25,
CT 2:
0.01,0.06,0.42,0.15,0.23,
CT 3:
-0.00,0.07,0.55,0.12,-0.00,
CT 1:
0.03,0.10,0.65,0.15,0.28,
CT 2:
0.01,0.07,0.55,0.13,0.08,

Ps. the arduino + shield are on my table (wood / plastic).

Robert Wall's picture

Re: EmonTx (no RF) question

Those numbers are a fraction higher than mine, but I doubt that you will get them much lower. As far I can find out, the noise comes from the digital circuits inside the processor and there is little you can do about it.

If you do not need to measure the full 100 A, you can increase the value of the burden resistor, but you risk distorting the waveform and introducing errors into the measurements if you make it too large.

estqwerty's picture

Re: EmonTx (no RF) question

Hello, I am trying the same thing - arduino to talk to rasppi via usb cable. I see that arduino talks to usb0 on raspi but i cant foward the data to emoncms.

How i must configure oem-gateway script and OemGatewaySerialListener ? 

And what i must change in arduino sketch?

Thanks.

 

calypso_rae's picture

Re: EmonTx (no RF) question

RobV: I have the following configuration:

1. Arduino uno : http://dx.com/p/x1301-uno-r3-starter-singlechip-set-kit-multicolored-961192965

2. http://shop.openenergymonitor.com/emontx-shield-kit-no-rf/

3. 3x http://shop.openenergymonitor.com/100a-max-clip-on-current-sensor-ct/

4. http://shop.openenergymonitor.com/ac-ac-adapter-euro-plug/

Thats exact my configuration :)

Good!  With that configuration, you should be able to run my Raw Samples Tool sketch.   This will display exactly how your signals are being seen by the processor.  For details about this tool, and many others, just follow the link on my Summary Page

The above sketch requires an AC signal to be present at Analog input 2 - the voltage sensor.  If it's not working, try my MinMaxAndRangeChecker sketch, also linked from near the top of the same page. 

Whenever I build anything new, I always run these basic sketches because they are so useful for checking that the new hardware is OK.  Another useful sketch, linked from the same page, is my DigitalMeterEmulator.  Every time that 1Wh has been recorded, a pulse appears at the on-board LED.   Just clip the CT around an incoming tail and the two LEDs (meter and emonTx/Uno) should pulse at the same rate.  If they don't, then just change the value of powerCal until they do.  Calibration made easy!

powerCal is the means by which all of my sketches are calibrated.  Other software has different calibration methods.  It only takes a minute or two to switch from one sketch to another, so you could run one of mine to check that everything is working for you, and then switch to a different sketch, e.g. emonTx_CT123_voltage

estqwerty's picture

Re: EmonTx (no RF) question

calypso_rae : thanks, your tools will be very useful.

i picked up an old topic. i had a problem with running no rf, trough usb cable serial connection but all my problems seems to be lack of connection to emoncms.org. now everything is alright , up and running.  

i am trying to run an ultrasonic level sensor to emoncms. 

calypso_rae's picture

Re: EmonTx (no RF) question

Great.

If things are not working as intended, it's often worth running some simple checks to confirm that the basic parts of the system are in order.

Comment viewing options

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