July 7, 2017 | Written by: Nick Ford
Categorized: How-tos | Watson
Share this post:
There is no shortage of potentially ground-breaking IoT ideas out there, but there aren’t many IoT use cases to pull inspiration from for developers. To demonstrate the possibilities of what companies can build, the Mendix Evangelist team built an IoT application using IBM Watson IoT and IBM Blockchain in just 10 days without writing a single line of code. Here’s how it was done.
Coming up with the idea for an IoT application
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. While in transit, there are many factors that can adversely affect cargo, such as exposure to light, temperature increases and decreases, movement, and humidity.
The IBM Watson IoT platform enables apps to communicate with data collected by connected devices and sensors. Using blockchain technology allows industries to create an unchangeable and secure ledger for recording the history of transactions.
How the IoT application connects to Watson IoT and uses IBM Blockchain for fail-proof asset management
When building the IoT application, it was important to demonstrate how to use sensor data to track containers and then secure this information in a blockchain. Mendix used a popular sensor tag by Texas Instrument that links to the app via Bluetooth and sends the data to IBM IoT using MQTT. The app contains an easy to use setup for connecting to Watson IoT.
Connecting to Watson IoT
By utilizing the Mendix Appstore, the team was able to build the integration into IBM Watson IoT. They used the MQTT connector Appstore module, which allows for Mendix apps to both subscribe and publish to MQTT topics via IBM Watson. The Texas Instrument Tags are registered devices in IBM Watson IOT, and the Mendix app subscribes to their data feed on a specific topic allowing the app to perform operations based on data from the sensors.
To demonstrate blockchain technology in action, the team decided to only record abnormal events in the blockchain. They set up some limits in the application for each of the sensors so that every time they received a reading above the set limit the app 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 to build an integration into 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, they 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 demonstrate visually. The best way to visualize the chain is to create a timeline overview. Using a timeline would allow the app to show that a blockchain as a series of events in time order and each block effects future blocks. To retrieve the data for the timeline, the app used another operation from the blockchain API called chain/blocks. The chain operation allows the viewer to see the length of the chain and drill-down to see individual blocks in the chain.
The final product
The final product combines both a mobile app for managing alerts with a dashboard to track and trace events from IoT. All data is audited using 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.
The app was built in 10 days using out of the box connectors to IBM Watson and without writing a single line of code. To try it for yourself and watch a coding video, check out the entire Mendix blog article.