August 30, 2016 | Written by: BART BOGAERT
Categorized: How-tos | Internet of Things | Watson
Share this post:
Ever thought about connecting your house to cognitive system using Internet of Things? I gave it a try! Here’s a brief overview of how I made it work.
Within our house, we have different protocols – specifically EIB for the house appliances, MiLight for controlling the color of the lighting, a specific data logger for the solar panels, Sonos for audio, and some IP cameras.
My first goal for this experiment was to connect with the EIB bus. The following diagram illustrates how that connection was made:
(click to enlarge diagram)
Setting up the home side
On the home side, the EIB bus can be reached through an EIB/IP router. To build the connection, I used a small ARM-based Linux box. On that box, I downloaded, compiled, and installed the EIBnetmux server and the MQTT client. The next step was to connect the two of them, so I wrote a small program in C (source on GitHub) that does the following:
- Reads a configuration file containing:
- MQTT credentials
- EIB credentials
- A list of devices (EIB addresses and the corresponding device names and parameters to be used)
- Sets up a connection to the EIBnetmux server
- Sets up a connection to the MQTT client
- Subscribes to the MQTT Bluemix service
- Listens to the EIB bus and, for each event, writes a message to the MQTT client
- Analyzes and creates an event on the EIB bus for each message received through MQTT
The small Linux box serves as a gateway device, so the connection with the Watson service requires a one-time setup for the gateway itself. Thereafter, the devices are automatically added by the IoT platform at their first published event.
Setting up the IoT backend
On the back end, I used Bluemix to create a Node.js application and then attached the Watson IoT Platform. On the IoT platform, I created the gateway device and used the credentials on the house side. Here is a screenshot of the populated devices in the IoT platform:
Once I got the connection to work, I was able to see the data coming into the NoSQL database. I used the Watson IoT boards’ functionality to get a glimpse of the data coming in live. In the image below, the standard Usage Overview board shows the number of devices and the data usage of the system.
On a second board, I added the live temperatures coming from the outdoor temperature measurement and from the water heater system measurement. I also added status indicators for the lights on the right-hand side.
The nice thing about using MQTT is that you can return messages without having to expose the gateway to the internet. As the MQTT client at the gateway subscribes to the MQTT server, it receives all messages published by the IoT platform. I experimented with the service by using Node.js to write an MQTT message that is received by the gateway and contains an instruction to write to the EIB bus. By doing this, I am able to control, for example, the lights remotely without any opening in the DMZ at home.
So, what’s next? Maybe I’ll connect the solar plant and start doing some trend analysis on the data. Stay tuned!