Summary of Open IoT Challenge – Monitoring Industrial Automation Equipment

During last minutes of the Open IoT Challenge I’d like to summarize my work in this project.

An idea of remotely monitoring industrial equipment came form my experience with those systems. There are SCADA systems that tend to be complicated and expensive. Transmitting interested data to end user dashboard or “big data” intelligent system can involve several intermediate systems/databases. With open source IoT technologies it can be made simple.

I’ve managed to successfully establish communication between Eclipse Kura and Modbus device, poll registers periodically and use kura cloud service to send it to MQTT broker. Remote configuration is possible using Kura Configuration UI and remote LwM2M server. However, only simple configuration of UART and fixed set of Modbus Discrete Input and Holding Registers is possible to configure.

I’ve faced several major problems during my development. Most of the time took me to establish reliable communication channel between Eclipse Kura and Modbus Simulator device through RS485 line. Because I’ve used RS485 converters without automatic direction control, software arbitration was needed. Unfortunately current implementation of Modbus in Kura is not sufficient for providing decent handling of synchronization between sending data through UART and  controlling data direction over GPIO. I implemented dirty workaround inside Kura Modbus bundle.

Second fight I have had with the Leshan client functionality and it’s dependencies. It took me several hours to successfully connect from bundle to Leshan server. But it was worth it.

Summarizing :

I’ve managed to realize :

  1. Modbus slave simulator  – implemented using libmodbus library –
  2. Modbus Monitoring application with basic functionality – based on Eclipse Kura framework

However, I haven’t implemented local alarm and data visualization application and full feature remote configuration using LwM2M.

Nevertheless, I’m not going to stop this project and continue with joy of exploring IoT space.

Later this month I will publish source code. It needs a little bit of cleanup 😉

Stay tuned….


One Bundle Project – Modbus and Eclipse Kura

Default installation of Eclipse Kura 1.1.1 do not provision org.eclipse.kura.protocol.modbus bundle. Nevertheless, you can find it in source code (compile yourself) or grab it from .

All you need is to install modbus budle in Kura.

First you need to upload org.eclipse.kura.protocol.modbus-1.0.1.jar to your target device (RPi or BBB), connect with osgi console and install mentioned jar file:

telnet localhost 5002

osgi> install file:/{path to folder with jar file}/org.eclipse.kura.protocol.modbus-1.0.1.jar

Now, you can reference it from your bundle.

<?xml version="1.0"?>
<scr:component xmlns:scr="" name="io.github.tobidi.modbus.monitor.service.impl.ModbusMonitorServiceImpl" activate="activate">
  <implementation class="io.github.tobidi.modbus.monitor.service.impl.ModbusMonitorServiceImpl"/>
    <provide interface="io.github.tobidi.modbus.monitor.service.api.ModbusMonitorService"/>
  <reference name="connectionFactory" cardinality="1..1" interface="" bind="setConnectionFactory" unbind="unsetConnectionFactory"/>
  <reference name="modbusDeviceService" cardinality="1..1" interface="org.eclipse.kura.protocol.modbus.ModbusProtocolDeviceService" bind="setModbusDeviceService" unbind="unsetModbusDeviceService"/>

There is more about modbus on Kura Documenation.

One bundle project – Serial connection over RS-485 using Eclipse Kura

RS-485 standard (TIA/EIA-485) specifies a communication interface that uses differential signal lines to establish communication between devices. Majority of application consists of half-duplex transmission mode with a twisted pair copper wire as a physical medium. Each device turns its line driver only when transmitting. During remaining time the driver is kept turned off in order to allow other devices on network to operate by avoiding the data collision. It is the responsibility of the application-layer protocol to supervise data being exchanged.

In order to connect RS-485 to Raspberry Pi or BeagelBone Black we need to use appropriate HW converter. There are adapters that handle direction control automatically and ones that need external control. I’m using RS485 Board (3.3V version) from Wavesare.

Below is an example that that utilizes RS-485 Transceiver (like SP3485 or MAX3485). Converter that I’m using has RSE pin that control internal line drivers (it is connected to  DE and RE pins of SP3485). More information can be found in the datasheet.

Example code uses RSE line in order to turn on/off transmission driver. It is based on Eclipse Kura Serial Example and Device I/O example (from Kura Documentation and JavaDoc). I’m using Bndtools to develop OSGi bundles under Eclipse, that’s why the Bnd annotations are visible in the code.

Later, I will write post about how to use Bndtools to create bundles for Eclipse Kura.

Below is simple example that sets direction to transmit and sends some string to uart. You can implement reading using InputStream and direction pin.

package io.github.tobidi.obp.kura.comm.serialRS485;


import jdk.dio.DeviceConfig;
import jdk.dio.DeviceManager;
import jdk.dio.gpio.GPIOPin;
import jdk.dio.gpio.GPIOPinConfig;

import org.eclipse.kura.comm.CommConnection;
import org.eclipse.kura.comm.CommURI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import aQute.bnd.annotation.component.Activate;
import aQute.bnd.annotation.component.Component;
import aQute.bnd.annotation.component.Reference;

public class SerialRS485Example {

	private static final Logger log = LoggerFactory

	ConnectionFactory connectionFactory;

	private CommConnection connOne;

	private InputStream isOne;

	private OutputStream osOne;

	public void setConnectionFactory(ConnectionFactory connectionFactory) {
		this.connectionFactory = connectionFactory;

	public void unsetConnectionFactory(ConnectionFactory connectionFactory) {
		this.connectionFactory = null;

	public void activate() {

		GPIOPinConfig pinConfig = new GPIOPinConfig(DeviceConfig.DEFAULT, 22,

		GPIOPin directionPin = null;

		try {
			directionPin = (GPIOPin),

		} catch (IOException e1) {
			log.error(e1.getMessage(), e1);

		if (connectionFactory != null) {

			try {
				String uri = new CommURI.Builder(&quot;/dev/ttyAMA0&quot;)

				connOne = (CommConnection) connectionFactory.createConnection(
						uri, 1, false);

				isOne = connOne.openInputStream();
				osOne = connOne.openOutputStream();

				byte[] array = &quot;ping\n\r&quot;.getBytes();


				isOne = null;
				osOne = null;

				connOne = null;


			} catch (Exception e) {
				log.error(e.getMessage(), e);
		} else {
			log.warn(&quot;No ConnectionFactory&quot;);



Hardware setup – Eclipse IoT Challenge project

It’s been a while since my last post. I’d like to show hardware setup for my IoT Challenge project.

My application is organized in form of services running on Eclipse Kura (OSGi based framework). I’m running it on Raspberry Pi B+ (512 MB RAM) with additional LCD shield from AdaFruit (PiTFT) and RS-485 adapter from Waveshare (RS-485 Board). Standard RASPBIAN distribution from RASPBERRY PI FOUNDATION is used.

Although Java 7 is advised by Kura documentation, I’ve used latest Java 8. Up till now I don’t have any problems.

Development Setup

LCD screen is intended to show values acquired from monitored device and alarms triggered by application logic. Currently I’m using JavaFx for visualization layer.


RS-485 Adapter is connected with RPi UART0 interface and one additional GPIO. This adapter needs additional pin to control transmission direction. I’ve used GPIO17 as direction control pin.


For development I’m using additional Raspberry Pi (old B version with 256MB of RAM) that acts as Modbus slave. I’ve created simple Modbus simulation app using libmodbus library for testing purposes.

Connection diagram using RS-485 adapter – SP3485 / MAX3485 :