Ambient Wind Energy Indicator using Node-RED and Blink(1) USB

As we move to a low carbon electric grid with large amount of input from renewable sources we will need to match our consumption of energy to generation. The wind will not always blow and the sun doesn't always shine. Grid energy storage will play a role, however the closer we can match our consumption of energy to generation the less storage will be required. In the future we can expect dynamic pricing to act as as an incentive for shifting consumption patterns. 

As an experiment I have been playing around with creating a real-time ambient indicator of UK wind energy generation. Since wind energy is the greatest input of renewable energy into the UK grid we can assume that when wind generation output is high this is the best time for us to use power e.g. run the washing machine, dish washer etc.. 

I've used emoncms.org,  Node-RED and a ThingM blink(1) USB RGB LED plugged into an emonPi energy monitor to create the indicator.

Real-time wind energy indicator

Blink USB Indicator

First let's install the software to control the Blink(1) USB on the emonPi / RaspberryPi:

$ git clone https://github.com/todbot/blink1
$ sudo cp ~/blink1/linux/51-blink1.rules /etc/udev/rules.d/
$ sudo udevadm control --reload-rules
un-plug then re-plug device
$ cd blink1/commandline
$ make

Note: if Node HID fails to compile you may need to install gcc-4.8. I did not experience this problem using Raspbian Wheezy: https://github.com/node-hid/node-hid/issues/115

Test it's operation by turning on a white LED with
$ ~/blink1/commandline./blink1-tools --on

To make the Blink(1) USB work with Node-RED we need to install the Blink(1) node-RED flow and libusb driver. If you haven't already got it installed this example also requires the emoncms noe-RED flow to pull data from emoncms.org

$ sudo apt-get install libusb-1.0-0.dev
$ cd ~/.node-red
$ npm install node-red-node-blink1
$ npm install node-red-node-emoncms

Then restart node-RED.

Node-RED makes it super easy to link the required software components together, with pre built nodes available for emoncms and Blink USB it's just a case of linking the nodes together and adding some logic. Here is now node-RED flow, see node-RED export at bottom of this post:


We have a script running on emoncms.org to pull in real-time UK wind energy generation. We have been logging this data for almost a year now. Checkout the dashboard here: http://emoncms.org/mywindpower/ukwind.

http://emoncms.org/mywindpower/ukwind

The read API key for this account is 8f5c2d146c0c338845d2201b8fe1b0e1 and the feed ID is 67088. To pull the real time data into node red just plug in the  api key and feed ID into the node-RED emoncms in node. Node-RED will then execute the following GET request:

http://emoncms.org/feed/value.json?id=67088&apikey=8f5c2d146c0c338845d2201b8fe1b0e1




The blink usb node requires RGB csv to represent a colour output. A node is used to map the generation 0 -  7000 MW (currently!) to 0 - 255 RGB representation. 





[{"id":"98c24074.673dc","type":"emoncms-server","server":"http://emoncms.org","name":"emoncms UK windpower"},{"id":"5a3294d0.a5cd6c","type":"function","name":"Create RGB values CSV","func":"// convert to integer \n//var wind = +msg.payload;\n\n// green = 255 @ max wind output\nvar g = msg.payload\n\n// red = 255 @ zero wind output\nvar r= 255 - msg.payload\n\n// Round to whole number\ng = Number((g).toFixed(0));\nr = Number((r).toFixed(0));\n\nvar csv = r + \",\" + g + \",\" + 0;\nreturn {payload:csv};","outputs":1,"noerr":0,"x":617,"y":348,"z":"c0b0c402.3f4f38","wires":[["52d8719f.ad279","f3dd00d0.0c23"]]},{"id":"6ec040ed.913fc","type":"inject","name":"Trigger every 10min 7AM-11PM","topic":"","payload":"1445415635","payloadType":"string","repeat":"","crontab":"*/10 7-22 * * *","once":false,"x":297,"y":261,"z":"c0b0c402.3f4f38","wires":[["68f8d790.970728"]]},{"id":"52d8719f.ad279","type":"debug","name":"","active":false,"console":"false","complete":"false","x":878,"y":334,"z":"c0b0c402.3f4f38","wires":[]},{"id":"b5d43139.4a2bd","type":"inject","name":"Test 100MW","topic":"","payload":"100","payloadType":"string","repeat":"","crontab":"","once":false,"x":223,"y":421,"z":"c0b0c402.3f4f38","wires":[["2da76a85.d25896"]]},{"id":"9122dd65.6edd2","type":"inject","name":"Test 2000 MW","topic":"","payload":"2500","payloadType":"string","repeat":"","crontab":"","once":false,"x":225,"y":469,"z":"c0b0c402.3f4f38","wires":[["2da76a85.d25896"]]},{"id":"b5c8e6e5.4a3718","type":"inject","name":"Test 5000MW","topic":"","payload":"5000","payloadType":"string","repeat":"","crontab":"","once":true,"x":224,"y":514,"z":"c0b0c402.3f4f38","wires":[["2da76a85.d25896"]]},{"id":"f3dd00d0.0c23","type":"blink1","fade":"600","name":"Blink(1) USB","x":847,"y":440,"z":"c0b0c402.3f4f38","wires":[]},{"id":"68f8d790.970728","type":"emoncms in","name":"Get UK wind generation output from emoncm.org","emonServer":"98c24074.673dc","feedid":"67087","x":263,"y":343,"z":"c0b0c402.3f4f38","wires":[["2da76a85.d25896"]]},{"id":"2da76a85.d25896","type":"range","minin":"0","maxin":"6000","minout":"0","maxout":"255","action":"clamp","round":true,"name":"Range: Scale wind output to RGB value","x":551,"y":417,"z":"c0b0c402.3f4f38","wires":[["5a3294d0.a5cd6c"]]},{"id":"64a3fa26.9b5c04","type":"inject","name":"Turn off after 11PM","topic":"","payload":"0,0,0","payloadType":"string","repeat":"","crontab":"01 23 * * *","once":false,"x":613,"y":488,"z":"c0b0c402.3f4f38","wires":[["f3dd00d0.0c23"]]}] To engage in discussion regarding this post, please post on our Community Forum.