Changes

Jump to: navigation, search

XUELK-AN-005: Implementing an Industrial IoT gateway/supervisor

3,722 bytes added, 09:53, 14 February 2020
no edit summary
{{InfoBoxTop}}
{{AppliesToSBCLynx}}
{{AppliesToIoT}}
{{InfoBoxBottom}}
{{WarningMessage|text=This application note was validated against specific versions of the kit only. It may not work with other versions. Supported versions are listed in the ''History'' section.}}
== History ==
{| class="wikitable" border="1"
|May 2017
|First draft
|-
|0.6.0
|May 2017
|Added section "Configuring SBC Lynx as an MQTT broker"
|-
|}
==Introduction==
[[:Category:SBC_Lynx|SBC Lynx ]] is extremely flexible in terms of [[Connectors,_buttons_and_switches_(SBC_Lynx)|communication interfaces]] and [[Additional_industrial_I/Os_(XUAL)|I/O ports]]. When used in combination with a Linux distribution such as [[XUELK-AN-002:_Running_Debian_distribution|Debian]], it is an ideal solution to implement compact highly-integrated cost-effective gateways/supervisors for [http://internetofthingsagenda.techtarget.com/definition/Industrial-Internet-of-Things-IIoT Industrial Internet of Things applications (IIoT)].
IIoT is a vast field that includes several disciplines. At field level, the typical IIoT system requires
[1] See for example [[#TBDList of IoT cloud platforms (not exhaustive)|this section]].
===Ubidots===
[https://ubidots.com Ubidots] is ''a codeless IoT Platform designed to help you prototype and scale your IoT projects to production''.
This example consists of three steps. The first shows:
*How to connect the SBC Lynx to Ubidots
*How to upload data to the cloud.
The second part describes how to visualize on the dashboard of Ubidots. That Tha last one shows how to set up events so as to get a notification.
The procedure here described was tested on a SBC Lynx running Debian distribution. For more details, please refer to [[XUELK-AN-002:_Running_Debian_distribution|this application note]].
====Events and notifications====
Ubidots allows sending a notifications—for instance in the form of text message messages (SMS) or an email to emails—to the authorized users, based on the events configured on the cloud. In the following example, a variable that was not mentioned in the previous sections is used (<code>heartbeat</code>).
In To configure notification options, click enter the ''Events'' section, we can set a trigger, SMS or an email to get notification based our interest.
[[File:XUELK-AN-IIoT-11.png|thumb|center|600px]]
When we click Then sekect the “Even option “, we will get device (<code>My_device_1</code> in the following example) ...
[[File:XUELK-AN-IIoT-12.png|thumb|center|600px]]
Then ... and click the device and select the variable you wish to configure the notification for.
[[File:XUELK-AN-IIoT-13.png|thumb|center|600px]]
After selecting the variable, we will put define the if then statement condition that triggers the notification. In this case, it is triggered when the <code>heartbeat</code> variable is less than 4:
[[File:XUELK-AN-IIoT-14.png|thumb|center|600px]]
[[File:XUELK-AN-IIoT-15.png|thumb|center|600px]]
 
 
Last, we compose the message we want to be emailed every time the notification is triggered.
[[File:XUELK-AN-IIoT-16.png|thumb|center|600px]]
 
==Device-to-device communications==
===Configuring SBC Lynx as an MQTT broker===
This example shows how to install an MQTT broker on SBC Lynx, running Debian distribution. "MQTT, a simple, lightweight, publish/subscribe messaging protocol on top of the TCP/IP protocol, is the ideal protocol for the emerging IoT world" [1] and is becoming one on the most common protocols used for machine-to-machine communications.
 
In contrast to HTTP with its request/response paradigm, MQTT is based on a publish/subscribe model, as depicted in the following image. This makes it suitable for "Internet of Things" messaging where highly constrained devices are used (low power sensors, mobile devices, embedded computers, microcontrollers, etc.).
[[File:MQTT-architecture.png|thumb|center|600px]]
Publish/Subscribe is an event-driven way of communicating and it enables messages to be pushed to clients. The central communication point is the MQTT broker (server). It is in charge of routing all messages between the senders and the rightful receivers. Each client (sensors) that publishes (transmits) a message to the broker includes a topic into the message. The topic is the routing information for the broker. Each client that wants to receive messages subscribes to a certain topic and the broker delivers all messages with the matching topic to the client.
For more details, please refer to the publicly available resources such as [http://www.steves-internet-guide.com/mqtt/ this link].
 
 
 
[1] https://www.ibm.com/developerworks/cloud/library/cl-mqtt-bluemix-iot-node-red-app/
====Installing the broker====
Eclipse Mosquitto™ broker will be installed on SBC Lynx. Eclipse Mosquitto™ is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 3.1 and 3.1.1.
 
The procedure was tested on an [[XUELK-AN-002:_Running_Debian_distribution|SBC Lynx running Debian Jessie distribution]].
First, import the repository package signaling key:
<pre class="board-terminal">
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquito-repo.gpg.key
</pre>
 
 
Make the reposioty available for the mqtt:
<pre class="board-terminal">
cd /etc/apt/sources.lit.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list
</pre>
 
 
Install Mosquitto
<pre class="board-terminal">
sudo apt-get update
sudo apt-get install mosquitto
</pre>
 
 
Install Mosquitto developer libraries to develop MQTT clients
<pre class="board-terminal">
sudo apt-get install libmosquitto-dev
</pre>
After putting a value Execute the following command to install Mosquitto client packages<pre class="board-terminal">sudo apt-get install mosquitto-clients</pre>  Ensure that Mosquitto broker is running<pre class="board-terminal">sudo service mosquitto status</pre>  To verify that the if – then statementbroker is running properly, we will select you can perform this simple test. Open a means terminal and issue this command to get notificationsubscribe the topic <code>mqtt</code><pre class="board-terminal">[[File:XUELKmosquitto_sub -ANh localhost -IIoTt "mqtt" -15.png|thumb|center|600px]]v</pre>
Then, we will put a statement (Open another terminal and issue the given below command to publish message) to get as a notification either for sms (cell phone number) or email for email notification. Here in below I put snap shot of the final step of the event setting topic <code>mqtt</code><pre class="board-terminal">[[File:XUELKmosquitto_pub -ANh localhost -IIoTt "mqtt" -16m "Hello MQTT"</pre> Now the message <code>Hello MQTT</code> will be displayed in the first terminal where the topic <code>mqtt</code> was subscribed.png|thumb|center|600px]]
==References==
dave_user, Administrators
5,141
edits

Navigation menu