A Practical Guide for Connecting LabVIEW to the Industrial IoT

Overview

In this white paper, learn about the three most prevalent communication protocols to connect to cloud-based development platforms for Internet of Things (IoT) applications. You can also find information on some of the most common IoT cloud development platforms such as Amazon Web Services, IBM Bluemix, PTC ThingWorx, and Microsoft Azure. Plus, learn how to connect an NI embedded system, such as CompactRIO, to these cloud platforms through the LabVIEW open graphical development environment.

Contents

The IoT Will Change the World

The world economy will greatly change in the next decade as new Internet-enabled applications are rolled out. Some of these applications are likely to be disruptive and innovative as well as have a large economic impact. This will affect many industries and sectors, as already seen in consumer sectors like hotels (Airbnb) and taxis (Uber).

This trend is also noticeable in the industry, for example, Germany’s Industry 4.0 initiative. Within Industry 4.0 or the Industrial IoT (IIoT), the focus is on integration and better use of existing technologies. In this sense, industry, machines, products, and people are all digitally connected. Manufacturers are mass producing bespoke products in quantities of one. Intelligent software in the cloud connects enterprise IT systems with the operational world, machines, devices, and sensors to control and optimize production flow.

Figure 1 – Common Architecture of the Industrial IoT: Intelligent Edge Nodes Connect Sensors, Actuators and Devices to IT Systems

Because of the decrease in cost of connectivity, processing devices and sensors adoption of IIoT has grown tremendously. Sensor data can be captured and preprocessed close to the machines by a smart edge device such as a CompactRIO or a PXI automated test system. The edge device can send the data in real time to the virtual world (IT cloud platform) where it can be stored, monitored, and analyzed or trigger an action.

The value of the IIoT is not in the connectivity of the devices, but in what a company unlocks from the stream of data the smart devices supply. Cloud computing platforms and their services help provide this insight.

Many significant challenges need to be taken into account when implementing an IoT solution. Challenges such as standardization, interoperability, Big Analog Data™ handling, security, and privacy. It is important to be aware of these challenges and give special care to security. Security is a crucial component for any IoT application. IIoT devices should enforce a strong security policy and be updated regularly with the latest security patches. To learn more about best practices for security on CompactRIO and receive the latest security announcements from NI, visit ni.com/support/security. All cloud computing platforms securely send and receive data, use strong authentication and authorization methods, and use encryption. The majority also have audit capabilities.

Cloud Computing

Cloud computing refers to a flexible way of delivering hardware, software, or data resources via the network on a user’s request. This is opposite to the use of running a software application on a local computer.

Figure 2 - Overview of Cloud Computing Elements (image source: Sam Johnston https://commons.wikimedia.org/wiki/File:Cloud_computing.svg)

 

The table below shows three service levels of cloud computing that are commonly encountered.

SaaS

Software as a Service

Provides a full business service. The service provider runs and manages the complete platform. Examples: Gmail, Salesforce.com

PaaS

Platform as a Service

Provides a platform. You need to build and deploy your own cloud application, leveraging the run time and services the vendor provides. Examples: IBM Bluemix, Microsoft Azure, AWS IoT

IaaS

Infrastructure as a Service

Provides the basic building blocks such as server hardware, storage, and network capabilities. You may need to install the OS and applications. Examples: Amazon EC2 (a virtual machine that Amazon provides to you), IBM SoftLayer

 

Clouds can be deployed as public—all services run in a secure environment hosted in the cloud, where servers may be shared with others—or private, which is available only to the user’s organization and may exist on or off premises. In addition, clouds can be deployed as hybrids, where parts are on premises and other services are in the cloud.

 

IoT Application Protocols

Communication protocols are responsible for the network connectivity to the server. Protocols like Wi-Fi, Ethernet, cellular, and LoRaWAN are all communication protocols that provide this level of connectivity. Application protocols sit on top of them to communicate application-specific messages.

Multiple standards handle the communication between devices and the cloud. As application requirements differ, specific IoT protocols have been developed and therefore the confusion is understandable. Protocols may even have multiple implementations and IoT platforms may have proprietary IoT solutions. To provide a universal solution, devices, applications, and platforms need to be interoperable. NI embedded systems provide an excellent solution by being open and flexible. This success is achieved through the NI Linux Real-Time OS, support for LabVIEW graphical and C/C++ programming environments, as well as several Linux packages available through the vibrant ecosystem.

At a high level, there are three main use cases for the application protocols: device to device (D2D or M2M), device to server (D2S), and server to server (S2S) communication. IoT application protocols have different levels of real-time behavior and other characteristics. The table below provides an overview.

Common Application Protocols for IoT Connectivity

 

HTTP/HTTPS

WebSocket

DDS

MQTT

AMQP

Description

Transmit data over Internet from applications, websites, and so on

Transmit data over Internet from applications, websites, and so on

Communication bus to connect intelligent machines

Lightweight protocol for collecting data and publishing it to servers and subscribers

Queue system to reliably transfer messages between applications and processes (servers)

Typical Use Case

Web

Web

D2D

D2S

S2S, (D2S)

Real-Time Behavior

No

No

Yes, us–ms range

No, ms–s range

No, seconds range

Messaging

Request/Response

Request/Response

Databus

Publish/Subscribe

Publish/Subscribe

Transport

TCP

TCP

TCP, UDP, shared memory, and so on

TCP

TCP

Security

Yes: HTTPS (SSL or TLS)

Yes: wss:// (SSL/TLS)

Yes

Possible: SSL or TLS

Yes: TLS or SASL (Simple authentication and Security layer)

LabVIEW Support

Yes, native

Yes, via VI Package Manager (MediaMongrels)

Yes, via VI Package Manager (RTI)

Yes, Implementations on VI Package Manager, LabVIEW Tools Network, and GitHub

Implementations on VI Package Manager (LabbitMQ) and GitHub

Quality of Service

No

No

Yes, over 20 levels

Yes, 3 levels

Yes

 

The next section describes the most common protocols, MQTT, AMQP and DDS, in further detail.

 

MQTT

Message Queueing Telemetry Transport (MQTT) is an IoT connectivity protocol. MQTT is used in applications with thousands of sensors, including power usage monitoring and oil pipeline monitoring. MQTT is efficient in terms of bandwidth, battery, and resources. MQTT uses a publish/subscribe model. The IoT devices publish data to an MQTT broker over TCP as a topic. An authorized client can subscribe to any topic and receive the value from the broker as they arrive from the publisher. The publisher (device) does not need to know about any of the subscribers, which makes the management easier at the device level. The broker can support multiple concurrent connections from many devices. A topic is a simple string that can have hierarchical levels and supports also wildcards. An example of a topic is GothamCityPlant/Building1/Pump7/Power. The message data is transmitted in JSON format and may be specific to the cloud platforms’ IoT service.

 

Figure 3 – Edge Devices Sent MQTT Messages over the Internet to a Central Broker Which Distributes the Messages to Authorized Subscribers

MQTT supports three quality-of-service levels:

  • QoS 0—At most once
  • QoS 1—At least once
  • QoS 2—Exactly once

 

MQTT can be implemented using standard HTTP calls within LabVIEW. NI Partner Program and other third-party implementations exist on the NI Tools Network and GitHub.

To debug MQTT communications, a MQTT client can be installed on a local computer. A popular free MQTT client is MQTTfx, available at mqttfx.org/.

Several MQTT brokers to test communication are on the Internet. One of the most popular is mosquitto. To test the communication, you can publish topics to test.mosquitto.org. The mosquitto broker is open source and can also be used in-house for sandbox testing or production use of MQTT communication.

AMQP

Advanced Message Queuing Protocol (AMQP) is an open message protocol that can send transactional messages between servers and from devices to servers and vice versa. Advantages of AMQP are the reliable communication (data is received reliably exactly once at the receiving end) and interoperability. AMQP uses a broker to receive data from a client. The client (or publisher) then publishes the message to the broker, where it is processed and routed to a queue. From the queue, the message is sent to any client who has subscribed to this data. AMQP focuses on tracking all messages and ensuring each is delivered as intended, even if a device is temporarily offline. Devices that generate loads of data can stream to AMQP servers, which is then consumed by receivers to perform monitoring and analytics. An example application for AMQP is the analysis of automotive driving behavior at the data center. Some cloud development platforms support device connectivity to AMQP or AMQP over WebSocket. Popular open-source AMQP brokers you may come across are RabbitMQ, ActiveMQ, and Kafka.

LabbitMQ is an AMQP library for LabVIEW that can be installed from the VI Package manager. An open-source AMQP client implementation in LabVIEW is available on GitHub.

 

DDS

The Data Distribution Service (DDS) main use case is to distribute data directly to other devices, although it can also distribute data to enterprise systems and mobile devices. Applications are found in wind farms, automotive test, asset tracking, and defense and big physics. Devices often need each other’s data in real time measured in milliseconds. All of this needs to happen reliably and usually with large data streams. DDS offers a detailed quality of service control, with configurable reliability, redundancy, and filtering, and selects exactly which data goes where. To do so, DDS uses a device-to-device bus communication, which can deliver the data to thousands of devices.

LabVIEW support for DDS can be installed through the VI Package Manager. RTI provides an excellent tutorial on the use of DDS with LabVIEW.

Cloud Development Platforms

Disclaimer: National Instruments does not endorse any cloud platforms. The intent is to give a brief introduction to the major platforms. You should make a thorough investigation before deciding which platform is most suitable for your application.

Amazon AWS IoT

Amazon Web Services (AWS) offers IT infrastructure as cloud computing, database storage, content delivery, and more. AWS IoT is a managed cloud platform that enables devices to connect and interact with other AWS cloud applications and services through a rules engine. AWS IoT also provides a device gateway and device shadows. The device gateway is the service that manages the device connectivity to AWS IoT and supports MQTT, WebSocket, and HTTP protocols. Device shadows can create a virtual device that retain the device’s latest state, even when it is offline. Applications within AWS can publish to the virtual device and when the device is back online, the state is synchronized. AWS provides open-source IoT SDKs to help connecting hardware devices with AWS IoT.

AWS uses an IoT rules engine that applies an SQL-like syntax to select data received from a device and perform actions. The rules engine makes it possible to build IoT applications that can gather, analyze, process, and act on the data received from the device. The rules engine can route the message to AWS endpoints like AWS Lambda (a compute service to run your uploaded code), Amazon Kinesis (to process a large stream of data in real time), Amazon S3 (simple storage service), Amazon Machine Learning, Amazon DynamoDB, and many more.

NI provides a free toolkit through the LabVIEW Tools Network to connect your LabVIEW applications to AWS S3, SNS, SQS, and IoT services directly to enable cloud storage, push notifications, and more.

 

IBM Watson IoT for Bluemix

Bluemix, IBM’s cloud development platform, is a PaaS. With Bluemix, you can access IBM software for services like “big data” analytics, storage, databases, security, IoT, cognitive applications, and more.

Watson IoT for Bluemix lets an application communicate with the connected devices and consumes data received from those devices and device gateways. MQTT is used to communicate with the devices and gateways. Devices can securely connect to Watson IoT using MQTT over TLS.

The device needs to be registered with IBM Bluemix before an MQTT connection can be established with the Watson IoT MQTT broker. Rules and logic to handle the data can be defined in any of the languages that IBM Bluemix supports, such as node.js (Node-RED), Java, Python, and more.

The LabVIEW Tools Network contains an example to connect CompactRIO and a detailed description for IBM Watson IoT for Bluemix.

 

PTC ThingWorx

ThingWorx is a model-based IoT application development platform that provides a complete application design, run time, and environment. ThingWorx provides components for connectivity, analytics, collaboration, and visualization including augmented reality. The core development features of the platform are:

  • Composer—An application modeling environment to model the “things,” logic, visualization, data storage, and security
  • Mashup builder—A web page is called a mashup with ThingWorx, and visualization of web pages can be created using the mashup builder tool
  • SQUEAL—A search feature that allows searching through all data in a model
  • Execution engine and storage—Event-driven platform for execution and storage to store, relate, and expose big data to make it valuable and actionable

ThingWorx supports device connectivity in several ways: direct network connections, MQTT and AMQP, third-party device clouds, and OPC-UA connectivity through PTC Kepware software.

Microsoft Azure IoT Suite

The Azure IoT Suite allows data collection from devices and provides a set of services like data analysis, data storage, real-time and historical data visualization, and integration with back-office systems. The Azure IoT hub receives the data from IoT devices. The device data can then be stored or passed on for further processing, analytics, and management. Devices can communicate with the IoT hub over HTTP, MQTT, or AMQP protocols. Microsoft offers a set of Azure IoT device SDKs through GitHub.

Other cloud platforms are available, such as Google Cloud Platform, GE Predix, and many more. For more information, see the vendor’s specific product pages.

 

Next Steps

 

Appendix A: Overview of 4 Major IoT Cloud Platforms

 

AWS IoT

IBM Watson IoT for Bluemix

PTC ThingWorx

Microsoft Azure IoT

Free Evaluation

1-year free trial

30-day trial, then free Lite version

30-day trial

IoT Hub free trial for unlimited time

Pricing

Usage basis, no minimum fees

Pay per device, data exchanged, data stored

Subscription, then pay depending on usage

Usage based (No. of IoT Hub messages)

Deployment Options

Public cloud

Public or private

Private or hybrid

Public, private, or hybrid

Getting Started Materials (Tutorials, White Papers, and Videos)

Yes

Yes

Yes

Yes

Platform Access Options

GUI, CLI

GUI, CLI

GUI

GUI, CLI

MQTT Support

Yes

Yes

Yes

Yes

MQTT WebSockets

Yes

Yes

Not Specified

Yes

AMQP

Use SQS instead or 3rd party

Through 3rd party

Yes

Yes

AMQP WebSockets

Through 3rd party

Not Specified

Yes

Data Format

JSON

JSON

JSON

JSON

Storage

S3 (files), DynamoDB (NoSQL database), Redshift (database), and others

Cloudant (NoSQL database), Mongodb, and others

Data tables, streams, and value streams

SQL storage, DocumentDB (NoSQL), blob storage (files), and table storage

LabVIEW Connectivity

Yes, LabVIEW Cloud Toolkit for AWS; MQTT

Yes, MQTT

Yes, MQTT/AMQP

Yes, MQTT/AMQP

Device SDKs Available

Yes

Yes

Yes

Yes

Rules Engine

Yes, rules engine acts on the data and routes onto other services

Yes, that is, node.js application

Yes, Expression Widget

Yes, Azure Stream Analytics

Visualization of Data

QuickSight or custom development

Yes, Watson IoT Real-Time Insight

Yes, ThingWorx SQUEAL, widgets, Vuforia, and Mashup

Via Azure web apps, power BI, and notifications

Platform Real-Time Streaming Analytics

Amazon Kinesis

IoT Real-Time Insights, IBM Streaming Analytics

Yes

Stream Analytics

Platform Machine Learning

Amazon Machine Learning

IBM Predictive Analytics

Predictive Analytics

Azure ML

Security

TLS/SSL

TLS

TLS

TLS/SSL

The table features out-of-the-box capabilities. Often features can be added by installing additional services.

 

 

Appendix B: Sources

AWS         https://aws.amazon.com

IBM           http://www.ibm.com

Intel          http://www.intel.com

PTC           http://www.ptc.com/internet-of-things/technology-platform-thingworx

NI              http://www.ni.com/nl-nl/innovations/industrial-internet-of-things.html

Electronic Design—Understanding the protocols behind the internet of things http://www.electronicdesign.com/iot/understanding-protocols-behind-internet-things

Internet of Things (IoT) Development Platforms—A case of IBM Bluemix, P Kumar, Univ. of Koblenz-Landau            https://kola.opus.hbz-nrw.de/frontdoor/index/index/docId/1373

IoT Standards and Protocols       https://www.postscapes.com/internet-of-things-protocols/

Industrial Internet of Things Platform Comparison           https://www.mandsconsulting.com/industrial-iot-platform-comparison

 

Books:

Internet of Things, W. Vermeend, J.W. Timmer, 2016, ISBN 97890821993-4-5

Enterprise IoT, Naveen Balani, 2016, ISBN 9781535505642

 

The registered trademark Linux® is used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a worldwide basis.