Arduino Pro Mini Energy Monitor - Receiving Wrong Large Negative Values

Greets from Greece,

Great project and amazing guidance. I've manage to build a prototype with an arduino pro mini (5v) with both current and voltage sensors following the original circuit schemas, using for "Voltage"="AC 9v feed, 1x10k, 1x100k, 2x470k, 10uf" and "Current"="CST013 100A/50mA, 2x15K, burden 33ohm, 10uf". I used A1 pin for Current and A2 pin for Voltage.

The whole board connects to pc with Tx/Rx/GND with a USB/TTL adaptor for monitoring and code upload, while it is powered from an AC/DC 9v adapter on arduino's Raw Pin. The same adapter was modified with to wires directly on the transformer which are used for measuring voltage (giving a steady ~11.3 voltage with no load).

When i tried only the current sensor i was getting reasonable values and changes with load/no load (even testing with an economy lamp i was receiving a change from 0.004 to 0.15 Amp).

With the voltage measuring also ON, i receive repeating random values (huge and negative ones) which don't appear to change in any amperage change on the current sensor. An example of the resulting measuraments follows:  

-2966.78 4145.23 250.69 16.54 -0.72
-1630.27 2281.31 185.98 12.27 -0.71
-2893.68 4045.82 247.73 16.33 -0.72
-2919.60 4080.83 248.72 16.41 -0.72
-1619.96 2267.65 185.21 12.24 -0.71
-2941.50 4112.07 249.67 16.47 -0.72
-1629.55 2282.14 185.81 12.28 -0.71
-2823.30 3943.62 244.67 16.12 -0.72
-1674.72 2342.38 188.39 12.43 -0.71
-2795.35 3909.90 243.44 16.06 -0.71
-1619.78 2267.70 185.50 12.22 -0.71
-2890.70 4037.24 247.38 16.32 -0.72
-1631.00 2281.73 185.93 12.27 -0.71
-2846.32 3983.15 245.73 16.21 -0.71
-2844.14 3973.90 245.36 16.20 -0.72
-1630.23 2281.43 186.07 12.26 -0.71
-2892.72 4041.72 247.79 16.31 -0.72
-1676.51 2351.12 188.62 12.46 -0.71
-2993.49 4188.22 252.19 16.61 -0.71
-2890.18 4041.22 247.65 16.32 -0.72
-1598.35 2265.97 183.96 12.32 -0.71
-1667.91 2340.63 188.35 12.43 -0.71
-2934.35 4106.06 249.50 16.46 -0.71
-1618.79 2266.47 185.37 12.23 -0.71
-2888.23 4042.81 247.61 16.33 -0.71
-1624.98 2272.92 185.64 12.24 -0.71
-1624.28 2276.33 185.56 12.27 -0.71
-2986.94 4174.50 251.58 16.59 -0.72
-1625.25 2279.05 185.81 12.27 -0.71
-2993.24 4180.37 251.77 16.60 -0.72
-1631.67 2282.18 185.91 12.28 -0.71
-2839.70 3971.21 245.37 16.18 -0.72
-1627.13 2279.42 185.70 12.27 -0.71
-2992.90 4181.14 251.71 16.61 -0.72
-1623.91 2279.20 185.79 12.27 -0.71
-2993.81 4182.45 251.85 16.61 -0.72
-1627.72 2279.96 185.79 12.27 -0.71
-2990.95 4180.99 251.71 16.61 -0.72
-1625.08 2272.83 185.59 12.25 -0.72
-1622.17 2275.62 185.64 12.26 -0.71
-2990.45 4183.34 251.85 16.61 -0.71
-1625.04 2273.18 185.76 12.24 -0.71
-1626.75 2279.03 185.78 12.27 -0.71
-2791.81 3907.20 243.38 16.05 -0.71
-1628.31 2281.22 186.03 12.26 -0.71
-2935.14 4106.38 249.61 16.45 -0.71
-1627.37 2280.07 186.01 12.26 -0.71
-2909.56 4072.66 248.56 16.38 -0.71
-1623.10 2280.25 186.00 12.26 -0.71
-2939.31 4109.29 249.77 16.45 -0.72
-1683.76 2357.40 189.11 12.47 -0.71
-1643.43 2308.43 187.12 12.34 -0.71

My code is the following:

#include <EmonLib.h>
EnergyMonitor emon1;             // Create an instance
#define CurPin A1
#define VolPin A2

void setup()
{
  pinMode(VolPin, INPUT);
  pinMode(CurPin, INPUT);
  Serial.begin(9600);
  emon1.voltage(VolPin, 111.1, 1.7);  // Voltage: input pin, calibration, phase_shift
  emon1.current(CurPin, 60.6); // 100A CT
}

void loop() {
  emon1.calcVI(20, 2000);        // Calculate all. No.of wavelengths, time-out
  emon1.serialprint();           // Print out all variables
}

Any ideas would really be very helpfulll and much appreciated and thanks for your time reading my post!!!

best,
Thanos
 

Robert Wall's picture

Re: Arduino Pro Mini Energy Monitor - Receiving Wrong Large Negative Values

You cannot use the same transformer winding for both the power supply to the Arduino and for measuring the voltage. If you draw out the complete circuit diagram, you will find that you have a link between the ac and dc sides of the rectifier that you should not have. You must use two transformers or a transformer with two completely separate windings - one for power and one for measurement, or you can copy the arrangement we use in the emonTx V3.

thanosmats's picture

Re: Arduino Pro Mini Energy Monitor - Receiving Wrong Large Negative Values

Yes!!!! You are absolutelly right!!!! I am so sorry for my ignorance but i was trying to cut out the use of two adaptors for the job. My greed panished me!!!

I allready received values like this, which i have to check further but i'm on the right track!!! :D

9.28 32.96 260.90 0.13 0.28
11.25 33.45 260.95 0.13 0.34
13.25 32.53 260.82 0.12 0.41
9.93 32.43 260.93 0.12 0.31
9.93 33.59 260.81 0.13 0.30
9.39 32.95 260.89 0.13 0.28
12.92 34.54 260.94 0.13 0.37
11.16 34.45 260.87 0.13 0.32
11.36 32.60 260.94 0.12 0.35
13.87 34.14 260.99 0.13 0.41
9.86 30.52 260.87 0.12 0.32
8.78 32.64 260.87 0.13 0.27
10.50 32.65 260.88 0.13 0.32
10.74 31.36 260.94 0.12 0.34
9.13 32.64 260.95 0.13 0.28
9.71 32.89 260.94 0.13 0.30
9.80 31.03 260.99 0.12 0.32
11.06 33.74 260.85 0.13 0.33
12.48 34.25 260.89 0.13 0.36
10.85 34.77 260.99 0.13 0.31
7.54 29.99 260.93 0.11 0.25
9.93 33.30 260.81 0.13 0.30
10.04 31.90 260.96 0.12 0.31
12.70 32.81 260.97 0.13 0.39
8.98 31.88 260.92 0.12 0.28
9.70 32.32 260.93 0.12 0.30
7.87 32.75 260.89 0.13 0.24

 

thanosmats's picture

Re: Arduino Pro Mini Energy Monitor - Receiving Wrong Large Negative Values

Greetings again, and thanks for all the help provided so far.

After measuring the mains voltage which equals to a stable 230V reading, I've managed to output the following readings, only by setting the emon1.voltage(VolPin, 98.08, 1.7) which's output reflects the real measured mains power. Now my readings are as shown below:

Open Energy Monitor
230.34V    0.00kWh    0.12    0.01kW    0.32
Raw: 9.03 28.34 230.34 0.12 0.32
 
Open Energy Monitor
230.50V    0.00kWh    0.12    0.01kW    0.33
Raw: 9.30 28.34 230.50 0.12 0.33
 
Open Energy Monitor
230.38V    0.00kWh    0.12    0.01kW    0.31
Raw: 8.16 26.73 230.38 0.12 0.31
 
Open Energy Monitor
230.40V    0.00kWh    0.12    0.01kW    0.25
6.74 26.57 230.40 0.12 0.25
 
Open Energy Monitor
230.44V    0.00kWh    0.13    0.01kW    0.30
Raw: 9.11 30.12 230.44 0.13 0.30
 

I would like to ask

1) are the raw values correct?! the second row shouldn't be almost the same with the first?!?!

2) why the current always measures 0.20~0.35 even if there is no load on the SCT sensor. Is it my fault or it's a calibration matter?!

Thanks in advance for reading my post and for all the help provided!!

best,
Thanos

 

Robert Wall's picture

Re: Arduino Pro Mini Energy Monitor - Receiving Wrong Large Negative Values

The value of the voltage calibration constant (your 98.08) depends on the ratio of the voltage transformer, the ratio of the voltage divider and the reference voltage of your Arduino. If you read the same voltage as the true mains voltage, it is correct.

The current you read with no load is noise. It might be generated within the digital part of the Arduino itself, or it might be coming from your d.c. power supply, or some might be coming from each. The very low power factor (~0.3) is typical of noise. You can try a "better" power supply (see http://openenergymonitor.blogspot.co.uk/2011/08/not-all-usb-power-suppli...  and http://openenergymonitor.org/emon/node/10111)

thanosmats's picture

Re: Arduino Pro Mini Energy Monitor - Receiving Wrong Large Negative Values

Once again 100% correct!!! Thanks a lot for all the info and tips provided. I was using the computer usb to power the arduino. Now with an external 5v adaptor things became more stable and i even had to reduce the factor to 96.7 to get an even more stable 230.3~4 reading instead of the 234 volts AC i was getting since i connected the external DC power adaptor on the arduino.

and my current readings are:

 
Open Energy Monitor
230.34V    0.00kWh    0.05    0.00kW    0.20
2.47 12.49 230.34 0.05 0.20
 
Open Energy Monitor
230.36V    0.00kWh    0.04    0.00kW    0.15
1.44 9.60 230.36 0.04 0.15
 
Open Energy Monitor
230.37V    0.00kWh    0.05    0.00kW    0.18
2.06 11.45 230.37 0.05 0.18
 
Open Energy Monitor
230.35V    0.00kWh    0.04    0.00kW    0.15
1.41 9.49 230.35 0.04 0.15
 
Open Energy Monitor
230.35V    0.00kWh    0.04    0.00kW    0.15
1.40 9.34 230.35 0.04 0.15
 
Open Energy Monitor
230.33V    0.00kWh    0.04    0.00kW    0.13
1.17 8.78 230.33 0.04 0.13
 
Open Energy Monitor
230.35V    0.00kWh    0.05    0.00kW    0.16
1.73 10.52 230.35 0.05 0.16
 
Open Energy Monitor
230.33V    0.00kWh    0.04    0.00kW    0.14
1.28 9.20 230.33 0.04 0.14

Thanks once again!!!!!

Comment viewing options

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