loading

This work was part of a summer project at M-ITI to monitor power consumption and give feedback to the user using a web interface.

List of hardware:

For this project you will need the following:

  • Intel Edison
  • x2 USB-Micro USB cables
  • IO Expansion Shield for Edison from DFRobot (optional)
  • ADC block from SparkFun (optional)
  • ASC712, 20A current sensor
  • 10A relay or higher
  • x3 MOSFETs
  • RGB LED strip
  • x3 4,7k Ohms resistors
  • x3 220 Ohms resistors
  • x1 10k Ohms
  • Header pins
  • 230 AC V to 12 DC V transformer
  • Wires
  • Multimeter

You will also need:

  • Intel's XDK
  • SparkFun's ADC block library (optional)

The components marked as optional are only needed if you're not using the Intel Edison kit. We ended up using the DFRobot shield for Intel Edison which didn't have any analog ports so we also needed an extra ADC.

WARNING: This project involves working with high voltage from the grid, therefore, proceed with caution. We do not take responsibility for any harm done.

Step 1: Components Overview

Intel Edison

The Intel Edison is a small computer-on-model made by Intel. It is a very powerful and small development system with great applications for Internet of Things devices.

Current sensor

The current sensor we used was the ASC712. These sensors can measure up to 5A, 20A and 30A DC/AC. We chose the 20A version. It uses Hall Effect which means a current will induce a voltage that can be read by the Intel Edison. It needs to be supplied with 5V and has a sensibility of 100 mV/A. At zero current readings it should output 2,5V. For positive current readings it outputs a voltage between 2,5V and 5V and for negative currents it will output a voltage between 0 and 2,5V.

SparkFun's ADC block for Intel Edison

The SpakFun's ADC block used has a 12 bit ADC and shouldn't get more than 3,3V at its pins.

DFRobot Shield for Intel Edison

We used a IO expansion shield for Intel Edison which has 14 digital pins. We supplied it with 12V.

Transformer

We used a 230 AC V to 12 DC V transformer made for LED strips to supply the Intel Edison with the needed 12 V. This was also used to power our RGB LED strips.

Relay

We used a small relay to be able to turn the plug on/off. The one we got can be controlled using 5V coming from the Intel Edison shield.

MOSFET's

We used the FQP30N06L MOSFET to be able to control each LED's colour intensity by using commutation and PWM (Pulse Width Modulation) ports. These MOSFET's are a bit overkill for this application but they were the only ones we had at hand. You could use other ones as long as they can be activated with the 5V coming from the Intel Edison Shield.

RGB LED strip

The RGB LED strip we used needed a 12V power supply.

Step 2: Circuit

Here are the values of the resistors used:

  • R1 = 4,7k Ohms
  • R2 = 4,7k Ohms
  • R3 = 220 Ohms
  • R4 = 220 Ohms
  • R5 = 4,7k Ohms
  • R6 = 220 Ohms
  • R7 = 10k Ohms

Resistors R3 and R4 were used to limit the current being drawn from the shield's pins. R1 and R2 were used as pull down resistors to ensure that when no signal was being sent the value would be 0.

The current sensor outputs at max 5V but the ADC block we used can only handle 3,3V, therefore, we used a voltage divider (with R5, R6 and R7) at Analog 0 so that the voltage would never go above 3,3V.

3,3V = 5V * (R7/(R7 + R5+ R6)) <=> R7 = 1,94 * (R5 + R6)

This also means that the sensibility will be reduced to:

Sensibility = (100 mV/A * 3,3 V)/5V = 66 mV/A

The MOSFETs are used together with PWM pins to control the intensity of the LED's lights.

Step 3: Source Code

The source code needed to make this work can be found at github. You will also need to download this library from flowthings if you're using SparkFun's ADC block. After downloading the library, go to EnergyMonitorEdison-master and create a folder called node_modules. Inside this folder, create another folder named sparkfunadc and place the downloaded files from flowthings in it.

The following code from the function getPower() was used to measure and calculate the RMS current:

while(countSamples < samples){      //To give some time before reading again    
      if((Date.now()-startTime) >= sampleInterval){
        //Centers read value at zero
        readValue = a0_4v.adcRead() - adcZero; 
        //Squares all values and sums them  
        result += (readValue * readValue);       
        countSamples++;
        startTime += sampleInterval;
      }
    }

//Calculates RMS current. 3300 = 3.3V/mV. 1650 is the max ADC count i can get with 3.3V
    AmpRMS = (Math.sqrt(result/countSamples))*3300/(sensibility*1650);

Since i'm using a step range of 2 mV/step on the ADC block, the max step value i can get is given by:

MaxStep = 3,3V / (2 mV/step) = 1650 steps 

Step 4: Box Design

We desgined and printed a box using a 3D printer to accommodate all the components in it. We used Sketchup to design the box.

<p>hi it is a very nice thing, why do you use voltage divider and the MOSFET's?</p>
<p>Hello, we used an external ADC that didn't support more than 3,3V at its inputs. The current sensor output can go up to 5V so we needed to use a voltage divider to insure that the ADC wouldn't get damaged. The MOSFETs are being used as a switch to control the light intensity and colour of the RGB LEDs.</p>
<p>hi nice thing, where did you draw the diagram?? </p>
<p>Hello, we used a software called Fritzing.</p>
<p>thank you very much</p>
<p>Hi i have a arduino Mega controlling my home lamps, but i need know when the lamp of my room, for exemple, is turned on or off.</p><p>In my system, i can only turn on or off, but i don't know the real condition of lamp because i have a parallel interruptor on the lamps.</p><p>So, i can use the ASC712 to read the status of my lamp and show me in my web interface if the real status of my lamp is on or off?</p>
<p>Hello, yes it can be done. In this project we had a relay to turn the plug on/off and it could be controled remotely using the web interface or using a physical button. The button &quot;Turn plug on/off&quot; that shows on the interface is updated with the actual state of the relay everytime the button is pressed.</p><p>You could implement something similar, whenever your lamps consume energy your arduino could send a signal to the web interface to show if the lamp is on or off. </p>
<p>Nice thing, but could it be made with Arduino?</p>
<p>Hello, it should work if you use a WebSockets library for Ardu&iacute;no and adapt the code. You would also need a wifi module or something like arduino Yun which already comes with wifi. If you don't desire a web interface then all you need is to adapt the code that calculates current and power and the part of the code that makes the LED's change its colour. </p>
<p>Very cool idea, thanks for sharing :)</p>
<p>Thank you :)</p>

About This Instructable

2,705views

16favorites

License:

More by EnergyMonitorInstructables:Create a plug to monitor power consumption with Intel Edison and give feedback on a web interface - IoT 
Add instructable to: