Project Update — Let’s Build a RHDS System from Scratch (part 1)


In this tutorial we will outline how we built our “Energy Modelling” system that measures conduction, heat loss through the building envelope. To recap, the system use case is to help homeowners self-diagnose and optimize energy consumption related to Heating and Cooling. The system is implemented as a “Service Platform” with Device management capabilities to allow third parties to provide support to the homeowner.

All software components are Open Source or purpose built and the hardware components are COTS (commercial off-the-shelf).

Overall the construction of the first RHDS went smoothly. However, integrating KURA with Mongo-dB was more technically challenging than we would have preferred. The Eclipse Forum folks helped us work thru our scenario. We now have a much better understanding on how to build an OSGI bundle for KURA.

This tutorial will focus on installation of the major system building blocks. We will follow up this tutorial with part II which will discuss the purpose built application software, system modifications and operation.

Let’s begin!

System Description:

preliminary_architectureThe base hardware platform is a Raspberry Pi 2. The IOT gateway application is Eclipse Kura. At project launch Kura did not support PI-3. That has since changed, but we stayed with the Pi-2, for now. To measure the indoor environment conditions such as temperature and humidity we use the TI Sensortag. For external outdoor conditions we use Internet available weather data. Device Management of the Gateway and HVAC (Heat, Ventilation, Air Conditioning system) is done thru an NXP microcontroller, using Eclipse Leshan and Wakaama. The End user and Service application is Freeboard. The cloud platform is AWS, Amazon Web Services.

Major system components:



  • (1) Raspberry PI 2
  • (1) Power Supply 5,25V/2.4A
  • (1) Bluetooth 4.0 LE USB adapter
  • (1) Wi-Fi Nano USB adapter; EDIMAX N150
  • (1) Kingston 16GB SD
  • (4) Texas Instruments Sensortag 2650 V1.3
  • (1) mbed NXP LPC1768
  • (1) mbed Application Board (for LPC1768)


Data-flow Model:

dataflowThe heart of the system is Kura an IOT Gateway. Its primary job is to (1) connect to multiple TI Sensortags, via BLE, and (2) packetize the sensor data into a JSON format and (3) create an MQTT data stream back to Amazon AWS for cloud storage. Kura’s secondary responsibility is to push a copy of the sensor data, JSON format, to a local Data Store running on Mongodb.  Freeboard, a damn-sexy, open source real-time dashboard builder is the fronted UI application. Freeboard is served with JSON sensor data by JSON-SERVER, a simple REST like interface connected to Mongodb. Device Management is provided by Leshan and Wakaama utilizing LWM2M and CoAP protocols.

Installing System Building Blocks: We will cover the basic steps involved. There are plenty of excellent guides available on the net, if you get stuck “google is your friend”.

Raspberry Pi-2 (Base Hardware Platform): Getting the Raspberry PI operational out-of-the-box is very straight forward and there is plenty of online help available, see:

The Raspbian OS download site is:  For this projects we went with: Raspbian Jessie 2016-09-23

A handy tool for creating the Raspbian SD image can be found at:

Once the Pi system is booted up it’s a good idea to do a couple of things, at a minimum. From the console run “sudo raspi-config” and select option 1 and expand the filesystem. Also select option 4 and set up the proper time zone and keyboard setting. From there it’s a good idea to upgrade the OS to the latest and greatest: From the console run “sudo apt-get update” and then “sudo apt-get upgrade”.

Kura V2 (IOT Gateway Application): Eclipse offers excellent resources to get you started.  Everything you need from setting up your IDE to creating the “hello world”. Working examples are also available. The installation instructions are here:

Working examples of Kura OSGI bundles are available. Downloads are here:

We relied heavily on the following working example to connect to the TI Sensor tags: org.eclipse.kura.example.ble.tisensortag

There is a solid tutorial for connecting Kura to AWS (Amazon Web Servics) here:

Mongodb (Data Base / Store): I found a simple to follow guide for installing Mongodb on a Pi 2 or 3. Everything you need is here:

Json-sever (a REST like, simple to use API): This is a very handy tool for prototyping an application where you need to serve up some JSON data in a hurry. It works like a REST server, only you don’t need to do any coding. The installation instructions are here:

Freeboard (UI – A damn-sexy, open source real-time dashboard builder for IOT): It doesn’t get any easier to create a simple Dashboard for your IOT application than Freeboard. Just point the system at some JSON and you are done. Get it here:

You will need a web service to front-end Freeboard. We use a Python service since as it comes bundled with Raspbian OS. To start a web service just change to directory of where Freeboard is installed and issue the following from the Pi console:  “python –m SimpleHTTPServer <preferred-port-number> “

Leshan (Device Management – an OMA Lightweight M2M (LWM2M) implementation): You can find the project here:

Get and run the demo server:

Get and run the demo client:

Wakaama (Device End-point Management – LWM2M Client interface): The project can be found here:

In addition there is a working example here for the LPC1768:

Also check out this tutorial which discusses LWM2M, Leshan, Wakaama and LPC1768:

Texas Instruments Sensortag (Sensor Solution): Here is the main site:

The “Tear Down” section contains a lot of helpful information:

That’s it for now. In a part II follow up we will expand on how we connect things up and introduce the purpose built code.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s