EcoHomeLab August 2016 - "From Monitoring to Control"

Sorry, sorry, sorry... I know, next EcoHomeLab is this week and I am posting the blog of the previous one now. My excuse: I went on holidays the day after the session and despite I tried to write it I didn't finished before I was off. Anyway here it is.

OpenEnergyMonitor is with us in almost every session of EcoHomeLab. And it is always Trystan who brings us the ideas, projects and developments they are working in. But this time we had Glyn, a master in hardware engineering that lives it with clear enthusiasm. As he told me in the pub, getting back home after work is a chance to test the new experiments of the day and make them real by the use in daily life.

Glyn was the main speaker but we also had great contributions from Mike about his amazing collection of Raspberry Pis controlling everything. And of course the rest of us, humble mortals including: fungi researchers, a Phd in sustainability, a electronic hobbyist, a software engineer (also CarbonCoop board member) and other geekies.

 

The intro

For those not familiarized with OpenEnergyMonitor, Glyn started with an introduction to it talking about:

  • The main products in the family: emonTx, emonTH and emonPi.

  • The visualisation tool: emonCMS. Monitoring is useless if you don't understand your data!

  • The importance of the community with never ending contributions being as important as their own work. A great example of this is the recent release of the emonCMS Android App.

  • There are reasons for everything they do and they take it seriously: monitoring is not for the joy of playing with high level technology. Saving carbon is the key concept behind so they have spent the time to look at if it is worth to use emonPi and you will be happy to know that yes it is: thinking about circular economies they researched the embodied energy of an emonPi. If users reduce their energy use in just a 5%, only 3 months are needed to cover what was used to manufacture it, after that everything is carbon saving

  • The intention of making it easy and accessible, and for that they have not only updated the user guide with the aim of reaching the not techy people, they are also working in a setup wizard that will auto detect the monitoring nodes you install in your house.

  • Megni: the OpenHardware business they run. As he showed us in the slide: PCBs are manufactured in the UK, assembly in North Wales, worldwide shipping... And there are reasons for the OpenHardware model: effective for making and distributing technology, providing employment and supporting open-source development that blurs the traditional lines between “business”, academic research and education.

I am tempted at this point to include most of the slides he showed about everything I mention above but as it would take a lot of space, I have decided to put this mad picture of the Megni team that shows their energy and enthusiasm needed to make all these good things happen.

 

From Monitoring to Control

So now the main topic, this is why we were there. Very exciting for me as I know about monitoring but have never done any control, no experience on this matter so a bit of guidance got me excited and hopefully one day I'll start with it...

And what has the OpenEnergyMonitor done about control? Nothing but a massive lot at the same time. Smart as they are, they decided not to reinvent the wheel. There is plenty out there aiming to control and automate houses and it is good stuff: Node-Red, OpenHAB, LightWaveRF, WiFi MQTT Relay/Thermostat and Home Assistant... probably many more things that I don't know but these are the ones that Glyn told us and where they are putting their energy. They are not developing them but integrating them with emonPi and that is a lot to do. Also there is a whole section in the user guide I mentioned before to help us understand and use them.

 

MQTT

As they say in their website, MQTT is a machine to machine “Internet of things” connectivity protocol. It was designed as an extremely light weight publish/subscribe messaging transport.

For not techy people this is the “mechanism/language” used by different devices to communicate with each other. Quickly explained, it works by having publishers, subscribers, a broker in between them and topics. The publisher connects to the broker “publishing” a message in a topic, then the broker sends the message to all the subscribers of that topic.

How do OpenEnergyMonitor use MQTT? I'll try to explain it the simplest way I can:

  • EmonPi comes with a pre installed Mosquito MQTT server.

  • EmonHub (that bit of software that decodes the info sent from the sensor nodes) is a publisher. Every time that new measurements arrive, EmonHub publishes them into a specific topic.

  • There is an input processor in EmonCMS that can be used as a subscriber to that topic. So when emonHub publishes something, the data is received by emonCMS, stored and used as normal (which is not control, just display).

And what about the control? What I have just said should be enough to understand the graph below and as you see there emonCMS is not the only one that subscribes to the topic... control is coming.

 

Node-RED

As said in the user guide Node-RED is a tool for wiring together hardware devices, APIs and online services in new and interesting ways. Using Node-RED the emonPi can become a central hub for home automation, control and notification. At the heart of Node-RED is a visual editor allowing complex data flows to be wired together with little coding.

Node-RED comes also by default in emonPi and already set up. To see it you only need to browse http://your_emonpi_ip:1880 and the visual programmer is displayed.

To make it easier to understand Glyn showed us the following screen snap:

In there the purple boxes are subscribers to topics, from bottom to top: power measured by the CT sensor 1 in emonPi, level of the battery of two different emonThs (emonth1 and emonth2), and finally every measurements arriving to emonHub that it automatically publishes through the MQTT server mentioned in the previous section. The other boxes do what they say: display the value measured by the CT sensor 1, check the level of the batteries and send an email when any of them is below 1.7V and the top one displays everything arriving to emonHub.

Node-RED is simple as it is a drag and drop visual programmer but there is a big but. Those boxes that are not purple don't come out of the box, you need to write the code that do what they say or hope that somebody has done it for you. After that you just drag and drop.

So what does Glyn do with it? To start with he gets the notifications when batteries are running low as the example shows. Something quite cool he also does is to check the temperature outside the house, compare it with the temperature inside and then switch the heating on or off, very clever!

More info in here.

 

MQTT ESP8266 WiFi Relay / Thermostat

Multi-purpose WiFi connected relay control board that allows you to switch on/off whatever can be switched like heating and A/C. The way to do it is communicating with it via HTTP (in a web browser), MQTT (using programs like Node-RED or openHAB that we discuss later). On top of that you can also schedule the heating for a whole week using the thermostat that comes with it.

The hardware has been designed by Martin Harizanov and the bits of software it uses by different contributors.

Glyn showed us the following slide with all the information that we need to know:

Bit by bit:

  • The device comes with a WIFI Access Point, this means that you can connect to it as you do to any WIFI network. This is there in order to allow you do the first setup. So once you are connected to its WIFI network you go to 192.168.0.1 and see the blue box in the right of the graph. In there you configure the device to connect to your own house WIFI network. Once it reboots you can access it for further setup through your own WIFI.

  • Find out which is the IP address of the device using an app called Fing or by any other way you geek can imagine.

  • Put that IP address in your browser and you have access to the set up tool that allows you to control the relay in different ways: manual switch, scheduler or even better configure it as a MQTT subscriber (left blue box in the graph) so that you can control it, as said before, with other MQTT tools that work as publishers like Node-RED. So good, so powerful!

More info in here.

 

LightWaveRF Control

This is basically a plug that you can switch on and off remotely. 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.

It is not open source and uses it owns protocol but there has been a lot of work made by many to make access to it possible.

Support for these plugs don't come straight away with emonPi, if you want to use them you need to add an OOK transmitter to it. How to do it in here. But what there is in emonPi is and MQTT service that works as a subscriber that will switch the plug when you publish (using Node-RED or OpenHAB or anything else) to the topic lwrf/.

Prior to start using these plugs you need to pair them with emonPi by pressing the pairing button. For this reason, it is not recommended to use them in applications that requires some security.

More info in here.

The slide that Glyn showed us:

 

 

OpenHab

Another home automation software like Node-RED with an even nicer visual interface. It comes preinstalled in emonPi but you need to do some work on it before you can control anything.

The configuration files are the key, they are where you say what you have in your house so that you subscribe to the nodes that measure things and you publish to the ones that control things. You also have another config file to tell openHab how to display this items in the visual interface. EmonPi brings the skeleton of these config files so looking at them you can easily make your own ones.

Glyn didn't want to go too much in detail on this as it can become a big issue itself, but maybe it is something we will look in the future once we are playing with our own monitors.

Something very cool of openHAB is that after some more work (forwarding ports in your router and setup a dynamic DNS service) you can access it from outside your house. Another option to avoid this would be to use the openHAB cloud but again too much to go in detail.

More info here.

To get an idea about how it looks like, here is Glyn's slide:

 

Home assistant

And another software for control similar to openHAB but easier to setup with some nice auto-detection for devices in the house like mobile phones. There are many systems that integrate with it but not OpenEnergyMonitor yet. It has been tested on emonPi though but doesn't come by default so if you want to use it you need to install it yourself.

Glyn was very keen on it but had less info. He really likes the interface and he uses it mainly to display info but also to control the devices showed above.

I am sorry but haven't got anything else to say. More info here.

His slide:

 

Demo

Everything sounds great but does it work? Well yes of course, and Glyn showed us. But before, he told us the funny anecdote of when he was working from the office switching from there some LightWaveRF plugs in his house. It was Christmas and the plugs were for the Christmas tree. The way to check that everything was working was to see the changes in the current consumption in emonCMS but also and just in case he set up a web cam so that he could see the lights on the tree turning on and off. After a whole day of the lights switching his girlfriend working on the desk in the living room couldn't even be bother to move a muscle. Here you have the slide :)

And finally he did it, with no web cam but using the resources that OpenEnergyMonitor provides he logged into the emonPi in his house, showed the power it was using and started switching on and off things and of course the consumption was changing with a very little delay for the joy of all of us.

Everything so good!

 

And then there was Mike

Lucky us, we also had Mike a control and simulation engineer that has a house with more Raspberry Pis that you can imagine. He told us about how he controls the led lights, the immersion heaters, the home brew, a quite advanced heat pump control for his house and the B&B they run and even if it sounds crazy the key for his daughter's house is a Pi.

Before the Pi, everything was much more expensive, and before MQTT and Node-RED life was a nightmare. Communication was made with web sockets and if one broke everything failed.

His next project: a heating system for a green house. The idea is to store day heat in the ground and pump it out in the night. A way of extending Summer into Spring just with some extra Raspberry Pis.

We were all very impressed, great work what he has done in his house, for sure a place I would like to visit.

 

Next one and the slide show

As the open source man that Glyn is, you can see the slide show he used and download it from here.

And I can't finish without thanking you, Glyn, for making the time to come and share with us the potential for controlling that comes with the master piece that emonPi is, for your enthusiasm, for your great work as part of the OpenEnergyMonitor project and your commitment with open source. I hope we see you again at EcoHomeLab!

The very final thing: I know this does not make any sense as the next session is so soon but as a formality I put it here. Next EcoHomeLab on the 8th of September, 2nd Thursday of the month as always in Madlab. This time to build the new low cost home energy monitor developed by OpenEnergyMonitor. See the meet up here.

Now I feel totally back from my holidays.

      Carlos

 

 

Tags