How we Built an IoT Application in 10 Days Using Watson IoT and IBM Blockchain


on March 15, 2017

The Internet of Things (IoT) has opened up countless opportunities for businesses to drive smarter operations. Virtually every device and asset around us is becoming equipped with sensors that transmit data to the cloud. Naturally, many companies are eager to make IoT applications part of their business to drive new experiences, cut costs and generate efficiency.

There is no shortage of potentially ground-breaking ideas out there, but there aren’t yet many IoT examples to pull inspiration from.  In order to demonstrate the possibilities of what companies can build on Mendix, we built an IoT application.

How We Came Up with The Idea for Our IoT Application

In order to identify a use case for our IoT app, we chose to focus on the Logistics industry as there are many exciting things happening in supply chain logistics. When coming up with the idea, we knew we wanted to demonstrate a use case of combining IoT and Blockchain. We decided to build a connected supply chain tracking application to keep track of cargo shipments. 

One of the critical issues facing manufacturers, suppliers, carriers and ultimately customers across the supply chain is ensuring that transported goods arrive at their target destination, safe and fit for their purpose. Whilst in transit, there are many factors that can adversely affect cargo, such as exposure to light, temperature increases and decreases, movement, and humidity to name a few.

Ensuring the correct conditions are continually met while many different handlers and carriers are involved across the global supply chain can be challenging. What happens when something goes wrong? Insurers may be required to pay the bill for lost or damaged goods, there could be legal implications, remanufacturing costs and potentially even a compensation pay-out needed. Blockchain can be used as unmitigated proof of every transaction in the case of a shipment mishap.

We started to think about how to combine IBM Watson IoT and IBM Blockchain to create a mobile-first tracking solution with an immutable ledger of events to support end-to-end auditing across the supply chain. We wanted to create a way to protect each link in the chain to help pinpoint when damage occurred, proactively manage cargo for issues and offer peace of mind to insurers, potentially even reducing premiums and pay outs. 

The IBM Watson IoT platform lets your apps communicate with data collected by connected devices and sensors. Blockchain technology is becoming widely used across many industries including: automotive, pharmaceutical, logistics and manufacturing. Using Blockchain technology allows industries to create an unchangeable and secure ledger for recording the history of transactions.

Combining IoT with Blockchain technology has become an incredibly powerful combination to allow industries to monitor, track and secure data.

How We Built Our IoT Application for Fail-Proof Asset Management

The Design Process

When designing the IoT application, the Evangelist team employed a collaborative approach using an affinity diagram. To the untrained eye, an affinity diagram may look very scientific, confusing and even messy. But what you are viewing is a simple, yet powerful technique used in the early stages of our design process. By using the diagram and a lot of post-it notes, we stimulated idea generation and collaboration to help us discover both design features and use cases for the application.

From our findings, we created a series of dirty mock-ups using paper and pen to explore and evaluate our design ideas. Pen and paper is a great resource for initial designs as they invite critique and require little investment and effort. We produced several ideas, which were compared and evaluated, with the best features from each selected and combined into a further design iteration. The final version was created using Adobe Experience Design (XD), and was produced as an interactive prototype.

The Sensors

When building the application, we wanted an easy way to demonstrate how to use sensor data to track containers and then secure this information in a blockchain. To demonstrate the sensors, we decided to use a popular sensor tag called Texas Instrument.

The Texas Instrument Sensor Tag contains multiple sensors including: Humidity, temperature, movement and light. The Sensor Tag links to an app via Bluetooth and the app sends the data to IBM IOT using MQTT. The app contains an easy to use setup for connecting to Watson IOT. Using these small sensors allows us to interact with users at the booth. Visitors to the booth can handle the sensors and impact the data generated by either heating it up or shining light on the device.

Connecting to Watson IoT

By using the Mendix Appstore we were easily able to build the integration into the IBM Watson IOT. We used the MQTT connector Appstore module, which allows for Mendix apps to both subscribe and publish to MQTT topics. In our scenario we wanted to subscribe to the MQTT topics published by IBM Watson. The Texas Instrument Tags will publish its sensor data to IBM Watson IOT and the Mendix app subscribes to the data from IBM Watson IOT, allowing us to perform operations based on the data from the sensors.

We decided to use the following data from the sensors: Temperature, humidity, light and movement. In the Mendix application we setup the subscription to the device topics using the MQTT module. The module allows you to subscribe to MQTT topics and execute a microflow every time a message is received from the devices. The microflow that executes when a message is received comes with topic information and the message payload in JSON format. In order to import the data, we setup a mapping between the JSON data and the Mendix domain model.

Once we had the IoT framework setup correctly, we started building the dashboards. Using a few widgets from the Mendix Appstore, like the Google maps widget & ChartJs widget, we were quickly able to build a nice looking dashboard. The dashboard shows the containers location, light, temperature, humidity and movement. Giving the end user an easy to use overview.

Using Blockchain

In order to demonstrate blockchain technology in action, we decided that we only wanted to record abnormal events in the blockchain. We setup some limits in the application for each of the sensors so that every time we received a reading above the set limit we would do the following: send a push notification to the engineer, create an inspection for the engineer and add a block to the blockchain recording the event.

IBM Blockchain technology comes with a REST API interface for adding to the blockchain and retrieving the blocks from a chain. Using the Mendix native REST integration makes it easy for us to build an integration into the IBM Blockchain. Using the chaincode operation along with the invoke method allows us to add a block into the chain every time an alert is triggered from the sensors. To create the integration we again used the JSON mapper and REST functionality.

Blockchain is a fantastic way for keeping a ledger of all events that have occurred, but for a non-technical user it’s not easy to explain and even harder to visually demonstrate. We decided that the best way to visualize the chain would be to create a timeline overview. Using a timeline would allow us to show that a blockchain Is a series of events in time order and each block effects future blocks. To retrieve the data for the timeline we used another operation from the blockchain API called chain/blocks. The chain operation allows us to view the length of the chain and drill down to see individual blocks in the chain. Below is the final product timeline we created:

Inspections

We wanted a way to demonstrate to users Mendix’ fantastic mobile capabilities. So we decided to build a Mobile app allowing employees on the cargo ship to view alerts, sensor readings, notifications and assigned inspections. Every time an alert is triggered in the application we wanted a way to allow users to perform an inspection of the containers. The inspections part of the app allows users to upload photos, get the co-ordinates of where they are, add a date for the inspection, total weight and what the quality is currently. All using native device functionality. After a user has performed an inspection a PDF version of the inspection is generated and stored on the system. Some pictures of the application are below:

The Final Product

The final solution combines both a mobile app for managing alerts with a dashboard to track and trace events from IoT. All data is audited using IBM Blockchain to provide an immutable ledger of events across the entire supply chain. The app protects every member of the chain, from manufacturer to customer to insurer. We built the app in 10 days using out of the box connectors to IBM Watson and without writing a single line of code. 

  • Savan Vyas

    This is great use of using the latest features provided by Mendix platform, it would be great to see this as part of a webinar. Looking forward to seeing more interesting things from the Evangelist team.

  • Nick Ford

    Hi Savan, thanks for the comment and yes I agree. We will be setting up a series of webinars and videos to showcase some of the cool features of the platform when building Smart Apps, like the one outlined above. Watch this space!!