loading

Someday you might have made a brilliant smart object in your house. For example, automatic window blinds. Now you want these blinds to automatically close when some other hardware, like your television is turned on.

Using this Instructable will allow you to create an energy monitor sending an RF command when a certain threshold is reached. This involves some basic math and knowledge about electronics/electricity.

When your finished you'll have an adapter that measures current draw without having to cut any existing electronic wires.

Step 1: Getting the Required Hardware

For this all to work you'll need some hardware of course. Since we're using an Arduino to measure the current draw and send the RF command, we'll need an Arduino to start with. D'uh!

Required hardware:

  • Arduino (Uno or Pro Mini)
  • Non-Invasive Current Sensor
  • To be defined resistor
  • RF Emitter & Receiver

Prototype:

  • Breadboard
  • Breadboard wires

Final version:

  • Soldering iron
  • Solder
  • Wires

Of course you can choose not to solder everything together in a neat package. This is more about the prototyping proces itself, not so much about making a polished product.

Step 2: Required Software

There is not much needed to start programming, just the ordinary Arduino IDE. Since we are not using any libraries you need not install anything more.

Required software:

  • Arduino IDE

Step 3: Finding the Current Sensor Values

For achieving the best results, we will need to find the resistor that fits the current sensor (CT sensor) best. This is done by some calculations based on the specs of the CT sensor.

The first steps would be to find these values. You'll often find them by entering the product type and brand in your favourite search engine. In my case it will be the 'Talema AC1010', a product that I already had in my possession.

We need the following:

  • Max primary current (RMS)
  • Turns ratio

Furthermore we need to know at which voltage our Arduino works. In case of the Arduino Uno this will just be 5v.

To sum it all up, this is what my values are, useful for reference:

  • Max primary current: 60A
  • Turns ratio: 1000:1
  • Arduino voltage: 5

Step 4: Calculating Ideal Burden Resistor

If the CT sensor is a current output type such as the Talema AC1010, the current signal needs to be converted to a voltage signal with a burden resistor. If it is a voltage output CT you can skip this step and miss out the burden resistor as the burden resistor is already built in to the CT. It is time to start remembering these basic math classes from high school.

Choose the current range you want to measure. The Talema AC1010 has a current range of 0A to 60A so for this example let's choose 60A as our maximum current.

Convert maximum RMS current to peak-current by multiplying by √2:

Primary peak-current = RMS current × √(2) = 60A × 1.414 = 84.8A

Divide the peak-current by the number of turns in the CT to give the peak-current in the secondary coil.

The Talema AC1010 has 1000 turns and so the secondary peak current will be:

Secondary peak-current = Primary peak-current / no. of turns = 84.8A / 1000 = 0.0848A

To maximise measurement resolution the voltage over the burden resistor at peak-current should be the Arduino analog reference voltage (AREF) divided by 2

If you're using an Arduino running at 5V: AREF / 2 will be 5 V / 2 = 2.5 V and so the ideal burden resistance will be:

Ideal burden resistance = (AREF/2) / Secondary peak-current = 2.5V / 0.0848A = 29.5Ω

29Ω is not a common resistor value we have a choice of 22Ω or 33Ω. Always choose the next smaller value, or the maximum load current will create a voltage higher than AREF. I recommend going for 33Ω ±1%. In some cases using 2 resistors in series will be closer to the ideal burden value. The further from ideal the value is, the lower the accuracy will be. In this case, the peak current will results in an analog value of 4.7V (3822 after Analog to digital conversion using a 12bit ADC).

Step 5: Start Coding, More Math!

For the measurement to work we need to calculate some of the previous values in code. This will then give us an calibration value. For this we need the Arduino voltage, maximum RMS, loops and used burden resistor again. Make sure that the burden you use for calculation is the resistor value that you are actually using.

First we need to start calculating once more:

double primaryPeak = sqrt(2) * amps; // Peak RMS value.
double secondaryPeak = primaryPeak / loops; // Minimum RMS value. _sensorVoltage = voltage; // Voltage at which Arduino is running at. _sensorCalibration = (primaryPeak / secondaryPeak) / burden; // Calculate calibration value.

First we calculate the primary and secondary peak values. Just as before. We save the voltage for later use in the calculation and then calculate a calibration value by dividing the primary by secondary peak values. After that we divide this outcome with the burden resistor value.

Because my resistor is already soldered onto the board I use, the outcome of my calculation is: 0,078. In case of the previous calculated burden resistor calculation, the outcome would be 30,03. This value needs to be reused later on.

Now for the real part. Bear with me because this will sound kind of complicated, it is actually fairly easy. First of all we will need to define a sample rate, this is the amount of times a measurement is done. A good sample rate would be 1480. All samples will be added to and then divided by the amount of samples. This will give us an average value.

for (int i = 0; i < samples; i++) { _sensorValue = analogRead(_sensorPin); // Value of current sensor value, used for calculations.

_calculationOffset = (_calculationOffset + (_sensorValue - _calculationOffset) / 1024); // Calculated offet value from sensor. _calculationFiltered = _sensorValue - _calculationOffset; // Calculated filtered value from sensor.

_calculationSquare = _calculationFiltered * _calculationFiltered; // Square value from sensor. _calculationSum += _calculationSquare; // Sumary of all values since last sample reset.

}

_sensorAmperage = _sensorCalibration * (_sensorVoltage / 10) * sqrt(_calculationSum / samples); // Calculated amperage value from sensor.

_calculationSum = 0; // Reset summary so that new sample can be made.

This will give us a steady power draw in amperes. You could manually convert this ampere value to a wattage value. A simple equation:

voltage * amps = wattage

This voltage is of course the input voltage of your connected device, typically 230v or 110v.

Step 6: Finishing Up

From this point on you can do what ever you want with this value. In my case I'm connecting an RF transmitter to send an 'on' or 'off' command.

I can understand that the previous code explanation was a little on the short side. To make your life easier I've made an Arduino library making all these difficult equations. You can find the code on my GitHub, with this link below:

https://github.com/FricoRico/ArduinoEnergy

Have fun! See you in the next Instructable!

<p>Cool method to measure AC. Thanks for sharing.</p>
<p>This is awesome! I've seen these types of power strips before.</p>

About This Instructable

3,869views

26favorites

License:

More by FricoRico:Arduino Energy Switch 
Add instructable to: