Difference between revisions of "DIY Real time mains power meter"

From DIYWiki
Jump to navigation Jump to search
(WIP)
(WIP)
Line 17: Line 17:
  
 
=== Circuit and theory of operation ===
 
=== Circuit and theory of operation ===
[[File:EnergyMonCircuitDiagram.png|left|thumb|600x600px|Circuit diagram for the basic energy monitor]]
+
[[File:EnergyMonCircuitDiagram.png|left|thumb|650x650px|Circuit diagram for the basic energy monitor|alt=]]
  
 
==== Reading the mains voltage ====
 
==== Reading the mains voltage ====
Line 24: Line 24:
 
So we can't use the output from the adaptor directly, because the peak voltage will exceed the maximum the ADC can read, and there is also a negative component of the waveform which will be below the minimum level for the ADC. So we need to do some conditioning first. There are two parts to this. Compressing the voltage to a smaller range, and adding a constant DC bias to it so that we never see a negative going component to it.  
 
So we can't use the output from the adaptor directly, because the peak voltage will exceed the maximum the ADC can read, and there is also a negative component of the waveform which will be below the minimum level for the ADC. So we need to do some conditioning first. There are two parts to this. Compressing the voltage to a smaller range, and adding a constant DC bias to it so that we never see a negative going component to it.  
  
First we need to scale down the voltage range. A 9V AC transformer will give 9V RMS when under some load. Without any load the voltage will tend to rise a bit. So to be on the safe side we shall assume it could be 20% more than the nominal 9V. We also need to allow for the mains voltage to be higher than the nominal 240V. The upper limit is normally taken as 230V + 10%. Lastly the specified voltage is the RMS (DC equivalent) voltage, we need to know the full range of values that our ADC will see. This will be the "peak to peak" voltage. So to find the max output due to a high mains input:
+
First we need to scale down the voltage range. A 9V AC transformer will give 9V RMS when under some load. Without any load the voltage will tend to rise a bit. So to be on the safe side we shall assume it could be 20% more than the nominal 9V. We also need to allow for the mains voltage to be higher than the nominal 240V. The upper limit is normally taken as 230V + 10%. Lastly the specified voltage is the RMS (i.e. the DC equivalent) voltage, we need to know the full range of values that our ADC will see. This will be the "peak to peak" voltage. So to find the max output due to a high mains input:
  
 
<math>\frac{9V}{ 240 \times 253} = 9.49V
 
<math>\frac{9V}{ 240 \times 253} = 9.49V
Line 35: Line 35:
 
Now convert that to its peak value:
 
Now convert that to its peak value:
  
<math>11.39V \times sqrt(2) = 16.10V</math>
+
<math>11.39V \times \sqrt{2} = 16.10V</math>
  
 
Then just to be on the safe side we should assume that the Arduino may be running at the lower end of its typical supply voltage of 4.8V, restricting the total range of the ADC a bit. So R6 and R7 act as a potential divider that will scale the voltage so that the peak voltage is:
 
Then just to be on the safe side we should assume that the Arduino may be running at the lower end of its typical supply voltage of 4.8V, restricting the total range of the ADC a bit. So R6 and R7 act as a potential divider that will scale the voltage so that the peak voltage is:
Line 45: Line 45:
 
C2 will create an AC path to the Arduino's ground reference. R4 and R5 form a second potential divider, that will add a bias of half the Arduino's supply voltage to the ground referenced side of the transformer's output. So the ADC should see a voltage waveform that can swing between <math>\frac{5V}{2} \pm 1.03V</math>i.e. between approx 1.5 to 3.5V
 
C2 will create an AC path to the Arduino's ground reference. R4 and R5 form a second potential divider, that will add a bias of half the Arduino's supply voltage to the ground referenced side of the transformer's output. So the ADC should see a voltage waveform that can swing between <math>\frac{5V}{2} \pm 1.03V</math>i.e. between approx 1.5 to 3.5V
  
==== Reading the main current ====
+
==== Reading the mains current ====
The current is sensed by a YHDO SCT 013 current transformer with a 100A maximum reading. These are available in forms that will either give 50mA current output , or 1V output voltage at the full 100A current. The difference is that the voltage output type includes an internal burden resistor across the output of the transformer's secondary coil, to allow the meter to read a voltage directly. My one was a voltage output type, however to get a bit more resolution from it, I opened it and removed the internal burden resistor, so that I could turn it into the current output version,and then use my own burden resistor to scale the output to better match my ADS range. We also have one of the same problems we had with the voltage input - that the waveform we will see will be bipolar with a negative going part of each cycle. So R1 at 33 Ohms will show a potential difference across it of:  
+
The current is sensed by a '''YHDO SCT 013''' current transformer with a 100A maximum reading. These are available in forms that will either give 50mA current output, or 1V output voltage at the full 100A current. The difference is that the voltage output type includes an internal burden resistor across the output of the transformer's secondary coil, to allow the meter to read a voltage directly. My one was a voltage output type, however to get a bit more resolution from it, I opened it and removed the internal burden resistor, so that I could turn it into the current output version,and then use my own burden resistor to scale the output to better match my ADS range. We also have one of the same problems we had with the voltage input - that the waveform we will see is bipolar with a negative going part of each cycle. So R1 at 33 Ohms will show a potential difference across it of:  
  
<math>0.050A \times 33 = 1.65V AC RMS
+
<math>0.050A \times 33\Omega = 1.65V AC (RMS)
1.65V \times sqrt{2} = 2.33V AC Peak</math>
+
</math>
 +
 
 +
<math>1.65V \times \sqrt{2} = 2.33V AC (Peak)</math>
  
 
R2 + R3 act as a potential divider and add a bias of half the Arduino supply voltage to side of the transformer coupled to the Arduino earth reference by C1.
 
R2 + R3 act as a potential divider and add a bias of half the Arduino supply voltage to side of the transformer coupled to the Arduino earth reference by C1.
 +
 +
That is all the electronics dealt with.
 +
 +
== Building it ==

Revision as of 15:53, 25 November 2022

If you have rather fancied the nifty "in house" real time power use monitors that come with some "smart" meters, but don't fancy the rest of the smart meter, this simple project will get you some of the same functionality.

Rough and ready

A basic clamp meter that can measure the current passing through a wire that is passing through the jaws of the meter. (the probes are not required for AC current measurements using the clamp).

A quick "rough and ready" estimate of your power use can be obtained with a digital "clamp" meter. This will make a "non contact" reading of the current passing through a wire. So if you clamp it round of the "tails" that connect your electricity meter to your Consumer Unit (CU), you will get a reading of the current flowing at that moment. Multiple that number by your mains voltage (typically 240V), and you will have a an indication of the total power in watts being used.

Now this may be all you need, however there are a couple of sources of inaccuracy in this approach. To assess the actual power being used, you need to know the actual voltage as well as the current, so ideally we need to measure this rather than just assume it is 240V since not only will each property likely vary a little from the "normal" voltage anyway, it will fluctuate throughout the day as the load on the supply changes.

The second source of error is that the multiple of volts and amps when dealing with AC rather than DC, does not actually get you Watts, but "Volt Amps" or "VA". The VA reading is the total "apparent power" being used. This may be different from the real power being actually consumed because some part of the electrical load may be "reactive" - i.e. it stores some energy on part of the mains cycle, but then releases it later. This means not all of the current you can measure amounts to energy you need to pay for. See the article on power factor for a fuller explanation of this.

Depending on what you need to know, this may or may not matter. For knowing what size cables are required for a given load or what size UPS is required to keep your computer running during a power cut, the VA is the more useful number, since you need to know how many amps you need to allow for. For working out your energy use or costs, you will need the real power consumption in Watts and not the VA, since domestic electricity meters only charge for the real power consumed.

Design

This project was a simple "proof of concept" to see how well the monitor would work. (It may be followed by a multi channel mains power consumption meter with data logging, but that is for later!). So we need a way to measure the real time mains voltage, and the real time current consumption. This needs to be done in a safe and easy way that does not require wiring into the electrical system.

Using a 9V or 12V AC/AC mains power adaptor (basically a small transformer, in a box with a plug on it, and if we are lucky a thermal fuse), allows gives a low voltage supply that we can measure the voltage of. Power supplies with an AC output are less common than the typical DC ones, but were commonly used with many "dial up" modems, so there is a fair chance there is one stuffed in a drawer somewhere. We need a clip on current transformer to act as our clamp meter, and let us measure the current in the meter tail feeding the CU. Lastly we need a small amount of computing power to collect the voltage and current readings, do some number crunching, and send out the information we need to a local display. For this I used a Aruino "nano" clone, and a 16x2 line LCD display with back light.

Circuit and theory of operation

Circuit diagram for the basic energy monitor

Reading the mains voltage

The AC adaptor will give us a low voltage supply that we can measure. To do this we need to first capture the output from it with an Analogue to Digital Converter (ADC). The ADC channels on the Arduino can measure any analogue voltage between 0V and the supply voltage (typically 5V), and digitize with 10 bits of resolution.

So we can't use the output from the adaptor directly, because the peak voltage will exceed the maximum the ADC can read, and there is also a negative component of the waveform which will be below the minimum level for the ADC. So we need to do some conditioning first. There are two parts to this. Compressing the voltage to a smaller range, and adding a constant DC bias to it so that we never see a negative going component to it.

First we need to scale down the voltage range. A 9V AC transformer will give 9V RMS when under some load. Without any load the voltage will tend to rise a bit. So to be on the safe side we shall assume it could be 20% more than the nominal 9V. We also need to allow for the mains voltage to be higher than the nominal 240V. The upper limit is normally taken as 230V + 10%. Lastly the specified voltage is the RMS (i.e. the DC equivalent) voltage, we need to know the full range of values that our ADC will see. This will be the "peak to peak" voltage. So to find the max output due to a high mains input:

Allow for 20% voltage rise on unloaded transformer:

Now convert that to its peak value:

Then just to be on the safe side we should assume that the Arduino may be running at the lower end of its typical supply voltage of 4.8V, restricting the total range of the ADC a bit. So R6 and R7 act as a potential divider that will scale the voltage so that the peak voltage is:

C2 will create an AC path to the Arduino's ground reference. R4 and R5 form a second potential divider, that will add a bias of half the Arduino's supply voltage to the ground referenced side of the transformer's output. So the ADC should see a voltage waveform that can swing between i.e. between approx 1.5 to 3.5V

Reading the mains current

The current is sensed by a YHDO SCT 013 current transformer with a 100A maximum reading. These are available in forms that will either give 50mA current output, or 1V output voltage at the full 100A current. The difference is that the voltage output type includes an internal burden resistor across the output of the transformer's secondary coil, to allow the meter to read a voltage directly. My one was a voltage output type, however to get a bit more resolution from it, I opened it and removed the internal burden resistor, so that I could turn it into the current output version,and then use my own burden resistor to scale the output to better match my ADS range. We also have one of the same problems we had with the voltage input - that the waveform we will see is bipolar with a negative going part of each cycle. So R1 at 33 Ohms will show a potential difference across it of:

R2 + R3 act as a potential divider and add a bias of half the Arduino supply voltage to side of the transformer coupled to the Arduino earth reference by C1.

That is all the electronics dealt with.

Building it