Social Energy Awareness

A year ago, Noa Younse and myself (Carson Smuts), were given a grant and the opportunity by the Greendbuilders society of Columbia University in New York to build our proposal for social energy awareness (PlugIN). Our proposal was to design and build a fairly complex piece of electronics and programming that measures the use of electricity of a device and then to integrate itself with social networks. All while allowing a user to interact with the device via mobile devices.

Objectives Achieved

The first objective was to create fully self-sustained piece of hardware that can measure electrical voltage and current, power itself from mains (120 Volts) and create its own WiFi network as well as connecting to an existing network. We wanted to create our own hardware and not rely on hacking existing products as seen on the net. Dealing with high voltage mains was far more dangerous , however, it was important to the proof of concept that it could be built from scratch. It also allowed us to have total control and understanding of the system.

The second objective was to create a fully functioning online database that could collect data from multiple devices and then integrate the database with online social networks. We chose to use Facebook as our platform of choice. Incentive was a key factor when considering why people would use this hardware and interface. Hence, the intention was to create a competitive environment for people to measure themselves against. An online social network app/game, that lets users not only compete, but also allows them to see how they fit into a global system.

the PlugIN

The operation of the device is straight forward. You plug the device into a wall outlet and plug in any device you wish to measure. The PlugIN will then connect to the internet and start uploading your information to the main database.

However, if this is the first time using the device you need to go through a quick setup. Holding down the reset button will create its own WiFi network which you can connect to using the iPhone/iPad app we created. Once connected, you can set the network name and password of your home wireless, as well as the devices connected to the PlugIN and your personal ID.

Electronics

NOTE!! this project deals with High Voltage Mains, DO NOT use this as a template.

The project hardware had one major hurdle, dealing will high 120 Volt mains, and syphoning enough power off the mains to power the microprocessor  and the wifi module which run at only 5 Volts so that it did not need an external power supply/adapter. This section will go through the various electronic hardware we created in order to achieve our goals, safely. A B.O.M can be found in the last section.

The PlugIN can be separated into four separate electronic sections:

  • A custom PCB board design that measures both the Voltage and Current.
  • A microprocessor  for power algorithms and interfacing  with our database via TCP protocols.
  • A WiFi module and antenna.
  • A custom 120v to 19v to 5v power supply for the electronics.

Here is our PCB board schematic. Much of the design was achieved with the help of tutorials on OpenEnergyMonitor. The basic principles are as follows:

  • Two Optocouplers were used to isolate the high voltage from the low voltage side of the PCB, one for voltage and one for current.
  • A voltage divider was used in order to measure the voltage from the mains.
  • A current sensing resistor is used to determine the current flowing through the system.
  • A microprocessor is used to calculate power using the values from the optocouplers.
  • While testing, separate 12v power supplies for the High and Low sides of the optocouplers were needed.
  • Finally a Wifi module communicates with the Microprocessor to upload the final calculated values.


Prototypes

Four different prototypes were created during the development of this project.

Prototype 1: A low 6v measurement device on breadboard.

Prototype 2: Version 2 of the low 6v system on a PCB board.

Prototype 3: First high voltage 120v device.

Prototype 4: Final custom PCB design.

Measuring Power

(A lot of the fundamentals learned can be found at http://openenergymonitor.org)

The power or energy used (Joules per second J/s) by a device is measured in Watts. In order for us to calculate the Watts used we need to  use the equation, Power = Current * Voltage:

P(t) = I(t) * (V(t)

For those interested in the history, this calculation can be attributed to the works of German physicist Georg Ohm and James Prescott Joule.

So we know that we need to get both the Voltage and the Current. This is easier said than done. In order to get these measurements we need to create an interface between the device we want to measure and the 120v mains voltage. This is regarded as an invasive method of power measurement and is the only way to accomplish what we wanted to do without hacking existing hardware, such as the "Kill-a-Watt". Essentially we had to create our own version. Needless to say this is extremely dangerous and could result in fatal electric shock.

The trick was separating ourselves and our laptops from the High Voltage wiring. After some searching I came across the OpenEnergyMonitor.org site which outlined a method for this separation. Their advice was to use optocouplers or opto-isolator in order to achieve this electrical-isolation.

Optocouplers: These optocouplers contain an internal emitter or light source that converts electronic signals into light, it then uses an optical or di-electrical channel to pass the light to a photosensor  which in turn detect the incoming light and either generates an electrical signal or modulates an existing one from an external power source. You could actually use LED's to create a very crude optocoupler as LED's can both emit and detect light. For the purposes of this project we employed the use of the HCPL-7520 Optocoupler. It is a great little piece of tech and essentially allows us to measure the voltage drop through the external sense resistors and develop a proportional output voltage on the other side of the optical isolation barrier. What is important to remember is that the optocouplers sense voltage drops between -0.256v and +0.256v.

In order to get the Power measurement we need a voltage divider and a current sensing resistor. The optimum components were calculated below in the Voltage and Current sensing sections of this page. The results were the following:

Now that all the calculation are done , we know the following

R1 resistor = 2.2 MOhms

R2 resistor = 1Kohm

Current Sensing resistor = 0.025 Ohms (rated at 3 Watts)

Based on these chosen components we also know that the maximum power we can measure is 3482 Watts. Which is more than enough for most devices.

Voltage sensing:

In order to calculate the voltage we need to first lower the Voltage to an acceptable level. In order to do this we need to know the maximum voltage that we might encounter while using our device to measure power.

The guys at OpenEngeryMonitor suggested taking into account the fact that voltage fluctuates. Europe runs on 240v and the West runs on 120v.  It is important to know how alternating current works. When it says 240v it is actually alternating between a number such as +340v and -340v. What we tend to talk about on an everyday basis is the average or mean value of the Sin wave of the alternating current and that is 240v. However we need to be exact, so our maximum voltage is 340v.

Next we make use of a voltage divider in order to lower the voltage, this consists of two resistors in series. This is often used to get a low voltage signal of the voltage to be measured. The equation we use to calculate the resistors is derived from Ohms law:

V out / V mains  = V out / 340v   = R2 / (R1+R2)

From the above equation we can see that R2 will be much smaller than R1 if our output is to be close to 0.256v. However, we cannot use just any resistors, they must be able to handle the power dissipated. In order to calculate this we use the following:

We know that :

I = V / (R1 +R2)

Therefore:

P = V * I = (V*V) / (R1 +R2) = (340v*340v) / (R1 +R2)

Most resistors can handle around 0.3 W , so as long as the following is below that things will be fine:

(340v*340v) / 1000000 Ohms = 0.1156W

I chose 1000000 as a starting point, as it seemed to be a good starting point for the guys at OpenEnergyMonitor.

Now that we know that the two resistors should add up to something within that range, you just need to see which resistors are available on the market. R1 needs to be far bigger relative to R2. There are 2.2 MOhm (2200000 Ohm) resistors available. Plugging this in gives me R2.

V out / 340v  =  R2 / (2200000+R2)

V out = R2 * 340 / (2200000 + R2)

Now we can choose a value for R2 like 1000Ohms

V out = 1000Ohm * 340 / (2200000 + 1000Ohm)

V out = 0.15447v

Since the value falls below 0.256v we are fine. We now know the following:

0.1544v reading the voltage divider = 340v

R1 = 2.2 MOhms

R2 = 1 KOhm

Current Sensing:

Additional calculations now need to be made to figure out the correct specifications for the current sensing resistor.We need the maximum power we are likely to measure, and the maximum voltage in order to calculate the maximum current we will deal with:

Max Voltage = 340v , as explained in the voltage sensing section above.

Max Power = 3000w, as the OpenEnergyMonitor guys suggested few devices are likely to exceed this.

Max Current = Max Power / Max Voltage

I = P/ V = 3000/340 = 8.82 Amps

Now we needed to calculate the value of the resistor that will give us a value closest to 8.82Amps within 0.256v range of the optocoupler isolator:

Resistance = Voltage / Current

R = V / I = 0.256v / 8.82A = 0.029Ohms

Once again we need to calculate the maximum power that will be dissipated through the resistor, so that we know that it will not explode.

P = V * I = 0.256 * 8.82 = 2.26 Watts

The closest current sensing resistor for sale was 0.025 Ohms rated at 3 Watts. Now the peak current and power dissipation can be re-calculated:

Peak Current = Voltage  / Resistance

0.256v / 0.025  = 10.24 Amps (the maximum current we can measure)

Peak Power Dissipated = Voltage * Current

0.256v * 10.24 = 2.62W (the most power that could be dissipated, which is below 3W)

Voltage re-mapping:

Now we need to remap the values to the Microprocessors analog input. Essentially the Microprocessor inputs range between 0v - 5v and the readings will display 0 - 1052. Since the Optocouplers will read between -0.256v and +0.256v, we can assume the following:

Values between 0 and 340v will range between 0 and 0.1544v therefore:

The output voltage from the optocoupler will range between 2.5 and 5v since we never go out of the o to +0.256 range.

So the microprocessor will only ever see values between 512 and 1056.

Therefor a 340 voltage (0.1544v) will equal the following analog reading:

512 + (512/ (0.256/0.155) = 822~ analog reading for 340v

So for example an analog reading of 170 can be calculated as follows:

Voltage = 682 * (340/822) = 186v

Current re-mapping:

This is similar to the voltage re-mapping except its far simpler now that we now 0.256 = 10.24 Amps:

512 + (512/(0.256/0.256)) = 1056 analog reading for 10.24 Amps

For example an analog reading of 812 could be calculated as follows:

(812 * (10.24/1056)) = 6 Amps


Bill Of Materials

Custom PCB for measuring power:

1 x Carbon Film 1 KOhm Resistor, 500mW Power Rating, 350 Voltage Rating

1 x Carbon Film 2.2 MOhm Resistor, 500mW Power Rating, 350 Voltage Rating

1 x Wirewound Current-Sensing 0.025 Ohm Resistor, 3W Power Rating

6 x 0.100 uF Capacitors, 50v Voltage Rating

2 x DIP Socket , 8POS , Through Hole

2 x Optocoupler HCPL-7520-000E

1 x ATmega328 Microprocessor

1 x 16 MHz 18 pF Crystal Oscillator for Microprocessor

2 x 7805 Voltage Regulator, 5v DC

WiFi Module:

1 x RN-XV WiFly Module - Wire Antenna

1 x PCB mount Switch Button

19v Power Supply:

1 x 470 uF Electrolytic Capacitor, 35wvdc

1 x Silicon Bridge Rectifier, 100VDC, 1500mA forward current

1 x 12.6VAC, 300mA, PCB Power Transformer

logo-default-ss_c

Synthetic Spaces is the design portfolio and writings of Carson and Anja Smuts.

Copyright 2018 SyntheticSpaces © All Rights Reserved