Yesterday evening Trystan and I attend a local meetup in Bangor, North Wales hosted by NorthWalesTech It was a good event with some interesting talks. Here are the slides from the 5min lightning talks we gave:

My slides give a brief overview of the OpenEnergyMontor project before diving in to MQTT and node-RED with a live demo controlling LightWave RF plugs switching Christmas lights over the web using MQTT and nodeRED:

Trystan's lightning talk was focused on a heatpump which he has recently installed with John Cantor to heat his home. Trystan gave an overview of heatpump technology, his monitoring setup and the preliminary performance results:

Using a Raspberry Pi as an emonPi / emonBase web-connected base station for energy monitoring has many advantages (maintainability, remote access, debugging, updated etc.) but it does seem rather wasteful to have a 900Mhz 1GB RAM machine being used to post a couple of integers to a web-server! The always-on nature of a web-connected base station and plenty of spare processing power makes it ideal to use the emonPi for more than just energy monitoring; home automation and heating control optimisation are obvious candidates.

HardwareMany home automation products such as RF plugs, relays and heating remotes use a simple OOK (On-Off-Keying) wireless protocol. UK company LightWaveRF produce a variety of RF plugs and relays which can be controlled via OOK RF. The protocol is also compatible with some cheaper OOK learning receiver relays. While maybe not strictly open-source the protocol and been reverse engineered allowing plugs to be easily controlled from Arduino / Raspberry Pi. There is an active LightWaveRF online community. Using off-the shelf hardware like this is a 'safe' way to control lights, heaters and appliances around a home without getting our hands dirty dealing with with high voltages. These plugs and relays can be used to control anything from lights to immersion heaters, most LightWaveRF plugs/relays will switch up to 13A / 3kW.

Note: OOK protocol by it's simplistic nature is not particularly secure, I would not recommend controlling anything you don't mind getting accidently switched.

Existing LightWaveRF remotes can be emulated allowing plugs to be controlled from either emonPi MQTT or via the remote.

Now our plugs can be controlled via MQTT there are a many of options open as to how to control either via interface openHAB (blog post coming soon..), nodeRED, android Tasker etc.

I have been using nodeRED with input from android OwnTracks running on my phone to detect when I'm home and turn on a couple of lights:

Demo:

Using NodeRED and OwnTracks to turn on LightWave RF sockets when I arrive home:

Using android Tasker with AutoVoice and MQTT plugins to control LightWaveRF sockets:

Next Steps

Now we can control appliances remotely via MQTT the next logical step is to add a mobile user interface. In my next blog post I plan to explore setting up openHab to control appliances. Here's a early preview:

We plan to include out-of-the-box support for OOK LightWave RF, nodeRED and openHab pre-configured on our next emonPi pre-built SD card. Due for release in December 2015.

I have recently been experimented using Node-RED for a number of tasks. Thanks to the work of others a Node-RED flow node already existed for Emoncms making it very easy to post data to Emoncms. For my Ambient Wind Energy Indicator I had the need to extract real-time feed data from Emoncms feeds using the Emoncms API. I have now contributed this functionality to the official Node-RED Emoncms node. Using the updated Emoncms node it's now super easy to post data to extract latest real-time feed values from any Emoncms server including Emoncms.org.

The emonPi / emonTx standard install is designed to monitor whole house power consumption. An excellent learning exercise that we recommend everyone undertake soon after installing a whole house energy monitor is to turn off every appliance in the house then slowly turn on each appliance keeping a close eye on the real-time Emoncms dashboard. Walking around the house using a handheld mobile device to display the Emoncms dashboard works great for this. For fastest response we recommend connecting to the local Emoncms running locally on the emonBase / emonPi which will update ever 5s (emonPi default) or 10s (emonTx default).

After this exercise you should have a good idea what the trace signature of each of your appliances looks like on the graph. The easiest to identify are the large power consumers e.g kettle 3kW spike and shower 8kW spike. However with a bit of observation it's possible to identify subtler power signatures. Here's an excellent example by posted by @Zapaman showing a Solar PV dashboard annotated to identify his fridge / freezer and central heating pump running over night. It's great to see the solar PV kick in providing more then the demand when the sun hits the panels in the morning :-)

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..

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/115Test it's operation by turning on a white LED with$ ~/blink1/commandline./blink1-tools --onTo 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

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.

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:

Using the emonPi in it's default configuration works great to post data to Emoncms for logging and visualisation. However there may be times when you want some more flexibility and or ability to interface with other hardware.

Using a tool called Node-Red the emonPi can become a central hub for home automation, control and notification. Node-RED is a tool for wiring together hardware devices, APIs and online services in new and interesting ways. At the heart of Node-RED is a visual editor allowing complex data flows to be wired together with only a little coding skills. Here are some of my ideas of things I might like to achieve with Node-RED, For more inspiration check out Martin's IoT Google hangout 29min in:

When you are done don't forget to put the emonPi back to read-only mode to preserve SD card lifespan:$ rpi-ro

Getting data from the emonPi into Node-RED

There are two options to get our energy data into Node-RED:

1. Real-time data from emonHub using MQTT (see example below):

MQTT is a lightweight communication protocol for small web-connected devices. The latest version of emonHub as setup on the emonPi (and emonHub from July 15) uses MQTT as a link to Emoncms and also to provide data to the emonPi LCD script. Since MQTT is already running all we need to do is to point Node-RED MQTT input block to subscribe to the 'emonhub/rx/#' MQTT topic on port 1883. The '#' topic includes data received from all nodes. To subscribe to just one node use e.g. emonPi use: 'emonhub/5/values' or 'emonhub/10/values' for emonTx.

To subscribe the the emonPi's MQTT topics externally (if your running node-RED on another machine) you will need to open up the MQTT port on the emonPi:

$ sudo iptables -A INPUT -p tcp -m tcp --dport 1883 -j ACCEPT

2. Historic data from Emoncms using HTTP API:

To pull historic data already logged to Emoncms (e.g KWh data) into Node-RED we can use Emoncms's API. Here is a simple example to pull in the latest value from the KWh feed, just enter your RW API key and feed ID:

Node-RED example: send warning email when emonTH battery is low

Simple but useful example, use Node-RED connecting to emonPi in real-time data via MQTT (localhost) and sending email (via Gmail SMTP) if emonTH battery drops below 1.7V. Also in this flow as an example is a node to decode emonPi power data.

For the past two weeks I have been travelling out to the South of China from the UK via overland travel. I have always wanted to visit China but could not bring myself to justify the carbon impact of flying*. My journey took me from the UK to Moscow via European trains then the Trans Siberian Railway across Russia and Mongolia to China. It was a fantastic adventure, we broke up the travel by stopping off in various locations on route. I have posted a couple of blog posts on my personal blog accounting the journey.

Even though at OpenEnergyMonitor we do most of our manufacturing and assembly locally in the UK there are many components that are only possible to source in China e.g CT sensors, power adapters and RF modules. In fact most electronic components originate in some way from a factory in China. Even though we do our SMT assembly and PCB fabrication in the UK we still rely heavily on Chinese manufacturing. For heavy items like power adapters and CT sensors we purchase in bulk (pallet load) and ship via ocean freight rather than air cargo to reduce carbon footprint.

I wanted to visit China to experience the culture and see for myself the working conditions in the factories that supply some of the components we use. No doubt attempting to trace back every factory and company in a supply chain for a complex items such as electronic components is a big task, something large corporation (think Apple and Samsung) have struggled with. We have all heard the horror stories of overworked and under-age employees in Chinese electronic factories.

My epic train ride to China rolled me into the North of China and Beijing first. After being a tourist for a day and visiting the very 'great' Great Wall of China I took a fast train down to Shenzhen. This train was seriously impressive, cruising at a smooth 307 Km/hr. I was glued to the window watching countryside and cities larger than London that I had not heard of fly by. I was aware that China is home to many, many people however this was really evident looking out the window watching huge cities and row upon row of skyscrapers flash by. In every town town and city it seemed many more tower blocks were in the process of being built, there is no doubt that China is undergoing an economic boom. After 8hrs of fast train blur we arrived in Shenzhen, nicknamed together with it's neighbouring city Guangzhou as the ‘factory of the world’; it's almost certain that the laptop/tablet/phone you are using to read this was made in factories in these cities.

During my time in Shenzhen I visited the world's largest electronic component market and the HopeRF factory where the RFM12B and RFM69CW RF modules that we use are designed and manufactured. I didn't manage to visit the factory where our CT sensors are manufactured since this factory was located in the north of China, however I did post up some photos I was sent from inside the factory a while back.

Electronic component market in downtown Shenzhen (I'm pictured with the seller of encapsulated DS18B20 temperature sensors that we stock)

Visiting the electronics market in downtown Shenzhen was a fantastically crazy experience. It was amazing to see all types of components carefully organised under the glass counters. There is something satisfyingly tactile about being able to hold different types of connectors and switches to compare quality and dimensions and chat to the seller about the pros, cons and cost of each item. Assuming you could speak Mandarin shopping for components here would be a far more social experience than an online parametric search tool! Obviously prices for these components are significantly cheaper than in the West.

Before I started working in electronic manufacture I assumed (like I think many people do) that most electronic manufacture is performed by robots. This is mainly true for pick-and-place assembly, however there are many more manufacturing steps which require significant human effort such as thru-hole soldering, testing and final assembly.

I am happy to report that the HopeRF I visited was clean, air conditioned and all employees were at least the minimum age, paid at least the minimum wage and worked 8am - 6pm with a 2hr lunch / siesta break. Overtime is common but employees are paid accordingly. All employees I met seems happy, although I did happen to arrive just as they were leaving on their lunch break! On the wall in the corridor there was a notice board with photos showing various company employee group outings including activities such as hill walking, running, swimming and group dinners. I also noticed an employee suggestion box.

Hope RF Factory Visit

I did get a chance to speak to an engineer at Hope RF who is involved in the design of new modules. As I had presumed the RFM69CW using a more standard IC package is much more suited to reflow soldering and less susceptible to humidity ingression than the older RFM12B design that often used a 'black blob' IC package. Second photo down on the left shows a naked RFM12B before receiving it's 'blob' dressing! Interestingly I learned (and witnessed!) that each and every single module is hand tested before leaving the factory. Modules that fail the test are debugged by hand. I was told that they have no plans to halt manufacture of the older RFM12B modules as long as there is demand.

The international 'safe' level of emissions per person is around 2T/yr to contain global temperature changes at or below 2 deg C which will 'hopefully' keep runway climate change and subsequent rise in sea levels at bay. Return fight from London to Málaga will emit 2/3T of carbon per person

This guide details how to setup a WIFI Hotspot using the Edimax USB WIFI adapter on an EmonPi or EmonBase to make it possible to connect directly to an EmonPi from a tablet or computer without the need for a router or internet connection.

The guide is based on Dave Conroy's guide here but also covers setting up a DHCP server rather than ethernet to WIFI bridge.

There are 3 pieces of software that need to be installed to get this to work: