Today I will start a new series on how to use the Internet of Things in different sectors. The first one will be the energy and utilities sector, and I will show you how a simple light can be used to communicate the real-time price of electricity to consumers in an efficient way.
The energy and utilities sector in most countries has transformed into an open market where prices can be adjusted per hour, and where those prices are set depending on the current supply and demand in the smart grid. The system works for high volume consumers that can adjust their use over time, but a large part of the consumption is by households that are not aware of the current price. But what if there was a way to easily communicate prices to each household? Let’s create a light that can be placed at home, and that indicate the current price with a color – red for the high price during peak hours and green when the price is low.
To do that, I have chosen to use a device called Electric Imp (www.electricimp.com) and an accompanying breakout board (e.g. April or the one from SparkFun), but you can also use the same hardware that I showed in my video called “Internet of Things – Business Intelligence Flower”. You also need an RGB LED (I used one with a common cathode), and to connect everything, you need a breadboard, three resistors (two 10 ohm and one 68 ohm), and four jumper cables.
To setup the hardware, you start by disconnecting everything from its power source, and then connect the GND on the Imp’s breakout to the second (longest) pin of the LED. Then connect the Imp’s pin 7 to the LED pin 4 (blue) over the 10 ohm resistor, the Imp’s pin 8 to the LED pin 3 (green) over the other 10 ohm resistor, and the Imp’s pin 9 to the LED pin 1 (red) over the 68 ohm resistor.
I won’t go through the setup of the Electric Imp, but there are great instructions on their web site. You find the server code on http://cforsberg.com/?p=232, and first I just log a message on how to use the agent (on line 1). Then I define a function that will be called for each request (on lines 3-17), and the event is hooked up (on line 19). The function checks that there is a parameter named “led” in the request (on line 7), and if so sends an event (also called “led”) to the device with the parameter value, which is a color code (on line 9). Depending on whether the call to the device works, a corresponding HTTP code is returned (200 for success, on line 11, and 500 for an error, on line 15).
You also find the device code on http://cforsberg.com/?p=232, and first the variables for the pins are defined (on lines 1-3), which are used to configure the pins for PWM (Pulse-Width Modulation) at 400 Hz (on lines 5-7). Then a function is defined (on lines 9-14) that is called by the server/agent, and the event for that is hooked up (on line 16). In the function, the three color values are encoded into an integer value that is sent to each of the pins (on lines 11-13) using a helper function (on lines 18-28).
When you have entered this code into the Electric Imp IDE and run it, you can change the color using the URL logged (see the server code). That is the URL that the energy supplier can request when the prices change. To get a nice effect, you should put a diffuser over the LED, like a Ping Pong ball. I have put the LED inside a cute glass puppy, and here is how it looks when the price is low, and this is how it looks when the price is high.
That’s how the Internet of Things can be used in the energy and utilities sector.