Difference between revisions of "XUELK-AN-005: Implementing an Industrial IoT gateway/supervisor"

From DAVE Developer's Wiki
Jump to: navigation, search
(List of IoT cloud platforms (not exhaustive))
 
(24 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{InfoBoxTop}}
 
{{InfoBoxTop}}
 
{{AppliesToSBCLynx}}
 
{{AppliesToSBCLynx}}
 +
{{AppliesTo AXEL ULite AN}}
 +
{{AppliesTo SBC Lynx AN}}
 +
{{AppliesToIoT}}
 +
{{AppliesTo IoT AN}}
 
{{InfoBoxBottom}}
 
{{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 ==
 
== History ==
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 9: Line 14:
 
|-
 
|-
 
|0.5.0
 
|0.5.0
|April 2017
+
|May 2017
 
|First draft
 
|First draft
 +
|-
 +
|0.6.0
 +
|May 2017
 +
|Added section "Configuring SBC Lynx as an MQTT broker"
 
|-
 
|-
 
|}
 
|}
  
 
==Introduction==
 
==Introduction==
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)].
+
[[: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  
 
IIoT is a vast field that includes several disciplines. At field level, the typical IIoT system requires  
Line 30: Line 39:
  
 
==Cloud interfacing==
 
==Cloud interfacing==
At the time of this writing, tens of cloud platforms are available on the market addressing IoT and IIoT applications. Some of them provide free accounts for small projects or evaluation purposes.
+
At the time of this writing, tens of cloud platforms are available on the market addressing IoT and IIoT applications. [1] Some of them provide free accounts for small projects or evaluation purposes.
 +
 
 +
The following sections describe how to interface an SBC Lynx-based gateway to some of such platforms.
 +
 
  
The following sections describe how to interface an SBC Lynx-based gateway to such platforms.
 
  
 +
[1] See for example [[#List of IoT cloud platforms (not exhaustive)|this section]].
 
===Ubidots===
 
===Ubidots===
 
[https://ubidots.com Ubidots] is ''a codeless IoT Platform designed to help you prototype and scale your IoT projects to production''.
 
[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
+
This example consists of three steps. The first shows:
 
*How to connect the SBC Lynx to Ubidots  
 
*How to connect the SBC Lynx to Ubidots  
 
*How to upload data to the cloud.
 
*How to upload data to the cloud.
The second part describes how to visualize on the dashboard of Ubidots. That last shows how to set up events so as to get a notification.
+
The second part describes how to visualize on the dashboard of Ubidots. 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]].
 
====Connecting and uploading data to Ubidots====
 
====Connecting and uploading data to Ubidots====
 
As stated before, it is assumed that the board runs a Debian distribution:
 
As stated before, it is assumed that the board runs a Debian distribution:
Line 52: Line 66:
 
</pre>
 
</pre>
  
I) Connecting the SBC-LYNX devices to the Ubidots IoT cloud
+
To connect to the Ubidots platform, a client written in Python will be used. The client will make use of the Ubidots' client library (https://pypi.python.org/pypi/ubidots/). To install it, please issue the following commands as <code>root</code> user:
by means of ubidot python api client
+
<pre class="board-terminal">
 
 
To connect our SBC LYNX board to the ubidots using ubidot’s api client library, the first step is to install the “Python ubidots python API client” that is available on the PyPal as ubidots
 
https://pypi.python.org/pypi/ubidots/ (First we need to have a python installed on our board.)
 
 
 
The command to install the API client to the sbcl-ynx board is as follows:
 
 
 
First Login to Sbc-lynx board with root privileges (sudo) and excute these commands:
 
 
apt-get update
 
apt-get update
 
apt-get upgrade
 
apt-get upgrade
Line 66: Line 73:
 
easy_install pip
 
easy_install pip
 
pip install ubidots
 
pip install ubidots
 +
</pre>
  
Now we have installed to our target device (local gateway/device=SBC Lynx) the necessary library python api ubidots client
+
On the cloud side, we need to have a user account on the ubidots.com platform and get the API (a unique key for each account ) and token from the website, very simple.
  
II) To connect our SBC LYNX board to the ubidot IoT cloud we need to have user account on the ubidots cloud platform and get the API(a unique key for each account ) and token from the website, very simple.
 
  
 +
Go to the [https://ubidots.com/ website of the Ubidots cloud] and click the sign up option on the right upper corner of the website to create the account.
  
Go to the website of the ubidots cloud, https://ubidots.com/ and click the sign up option on the right upper corner of the website and create the account
 
I have created for my activity and here I put it in below
 
username =zerihun
 
pass = Zeri@204920
 
  
 +
[[File:XUELK-AN-IIoT-1.png|thumb|center|600px]]
  
[[File:XUELK-AN-IIoT-1.png|thumb|center|600px|caption]]
 
  
  
To get the Api key for the created account, go to the right upper corner of the home page of the ubidots and click on the user name then you will see four options which are My Profile, API Credentials, Docs and Log Out
+
To get the API token for the just created account, go to the right upper corner of the home page and click on the username. Then you will see four options which are ''My Profile'', ''API Credentials'', ''Docs'' and ''Log Out''.
  
  
[[File:XUELK-AN-IIoT-2.png|thumb|center|600px|caption]]
+
[[File:XUELK-AN-IIoT-2.png|thumb|center|600px]]
  
  
Click the API Credentials
 
  
 +
Click the ''API Credentials''. The API token (<code>fwSetosAgIG3d128YdzP5fi4hADzWU</code> in this example) is a string which will be used later to initialize the API client instance.
  
[[File:XUELK-AN-IIoT-3.png|thumb|center|600px|caption]]
+
[[File:XUELK-AN-IIoT-3.png|thumb|center|600px]]
  
  
Here in below I wrote mine API key and token as an example which will be needed when we generate an instance to communicate with the target device (Sbc-lynx board)
+
To create and initialize an API Client instance, use the following code:
 
+
<pre class="board-terminal">
API KEY = 4435dd4dd5454114fc2e5425b3dd9361de0f2ffa
 
Token = fwSetosAgIG3d128YdzP5fi4hADzWU
 
 
 
 
 
III) Now, after creating the user profile on the ubidots cloud side, we can be connected to it by creating an Api-Client instance from the Lynx board.
 
 
 
To create an instance, the code is:
 
 
 
 
from ubidots import ApiClient
 
from ubidots import ApiClient
api = ApiClient(token=' fwSetosAgIG3d128YdzP5fi4hADzWU ')
+
api = ApiClient(token='fwSetosAgIG3d128YdzP5fi4hADzWU')
 +
</pre>
  
After establishing the instance with the cloud, we will retrieve the variable.
 
The variable is where we want to save the value that we will send to the
 
Cloud.
 
  
But before sending data to the cloud side, we first go to the device option and define our own device and create the variables (equivalent to sensors)
+
On the cloud side, it is necessary to create the variables that will store the values uploaded by the SBC Lynx. In the example, three variables are created: <code>Fall_sensor</code>, <code>Flood_sensor</code> and <code>Temp_sensor</code>. To create variables, there are three options in the upper center of the home page of the Ubidots interface, as shown below.
To create variables, there are three option in the upper center of the home page of the ubidots shown below
+
[[File:XUELK-AN-IIoT-4.png|thumb|center|600px]]
  
  
[[File:XUELK-AN-IIoT-4.png|thumb|center|600px|caption]]
+
Click the device option, then we will get the following:
 +
[[File:XUELK-AN-IIoT-5.png|thumb|center|600px]]
  
  
Click the device option, then we will get the following
+
Click the device and add a variable:
 +
[[File:XUELK-AN-IIoT-6.png|thumb|center|600px]]
  
  
[[File:XUELK-AN-IIoT-5.png|thumb|center|600px|caption]]
+
After adding the variables, we need their IDs. To get them, put the cursor on bottom side of each variable box. Then, you will see "I" option. Click it to get the ID.  
  
 +
To create an instance of the variable on the SBC Lynx side, use the following format code:
 +
<pre class="board-terminal">
 +
my_variable = api.get_variable('<variable ID>')
 +
</pre>
  
Click the device and add variable (equivalent to sensors)
+
To upload a value to the Ubidots platform, we can use a code like this:
 
+
<pre class="board-terminal">
 
+
new_value = my_variable.save_value({'value': <value>})
[[File:XUELK-AN-IIoT-6.png|thumb|center|600px|caption]]
+
</pre>
 
 
 
 
After adding the variables, we need their id therefore to find their id put the cursor on bottom side of each variable box then, you will see “I”option then click it you will get the id of the variable that is used to establish an instance to this variable with the target device(sbc -lynx)
 
 
 
In my case (for example), I have added to my device three different variables named as Fall_sensor, Temp_sensor and Flood_sensor
 
 
 
To create an instance, use the following format
 
my_variable_lynx = api.get_variable('id _variable form the ubidots')
 
 
 
Having instantiating variable, we can save a new value with the
 
following line:
 
new_value = my_variable.save_value({'value': xxxxxxxxxxx})
 
Here is my simple python script to send random data to the ubidots
 
 
 
 
 
[[File:XUELK-AN-IIoT-7.png|thumb|center|600px|caption]]
 
 
 
  
 +
Following is a code snippet that uploads random data to the platform:
 +
<pre class="board-terminal">
 
from ubidots import ApiClient
 
from ubidots import ApiClient
 
import random
 
import random
Line 157: Line 142:
 
test_value_3 = random.randint(1,10)
 
test_value_3 = random.randint(1,10)
 
test_value_3 = my_variable_3.save_value({'value':test_value_3})
 
test_value_3 = my_variable_3.save_value({'value':test_value_3})
 
+
</pre>
 
 
When we execute this python code from the SBC Lynx board, it will send random data to the ubidots (to each variable, in my case it is three variable)
 
  
 
====Visualizing data on the cloud dashboards====
 
====Visualizing data on the cloud dashboards====
To visualize the data sent to the ubodots, we have an option called Dash board on the ubidots cloud side, we have three steps to adjust the dashboard that is the place where we will select the way we want to visualize the data.
+
To visualize the data sent to Ubidots, we have to use the ''Dashboards'' section, where we can configure how we want to visualize the data.
  
Click the Dash board
+
First, click the ''Dashboards'' link. Click the "+" symbol on the right upper corner. Then you will get the "How would you like to see your data?" question and different options below it:
Click the + “symbol on the right upper corner  
+
*Chart
Then you will get “How would you like to see your data?and different option below this question like Chart, metric, map, indicator, controller etc
+
* Metric
 +
*Map
 +
*Indicator
 +
*Controller
 +
*...
 +
[[File:XUELK-AN-IIoT-8.png|thumb|center|600px]]
  
  
[[File:XUELK-AN-IIoT-8.png|thumb|center|600px|caption]]
+
In this example, the option ''chart'' was selected. As such, several further options are available:
 +
[[File:XUELK-AN-IIoT-9.png|thumb|center|600px]]
  
  
In my case, I have selected the first option chart, in this case there are several option to use
+
For all of the variables, the ''Line chart'' option was chosen. The following image shows how the data visualization looks like:
 +
[[File:XUELK-AN-IIoT-10.png|thumb|center|600px]]
  
 +
====Events and notifications====
 +
Ubidots allows sending notifications—for instance in the form of text messages (SMS) or 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>).
  
[[File:XUELK-AN-IIoT-9.png|thumb|center|600px|caption]]
+
To configure notification options, click enter the ''Events'' section.
 +
[[File:XUELK-AN-IIoT-11.png|thumb|center|600px]]
  
  
In my case, I have selected the first option (Line chart) then confirm and I have done the same for all my three variables and the dash board after sending data looks the below one
+
Then sekect the device (<code>My_device_1</code> in the example) ...
 +
[[File:XUELK-AN-IIoT-12.png|thumb|center|600px]]
  
  
[[File:XUELK-AN-IIoT-10.png|thumb|center|600px|caption]]
+
... and click the variable you wish to configure the notification for.
 +
[[File:XUELK-AN-IIoT-13.png|thumb|center|600px]]
  
  
====Notification setting (event scheduling setting)====
+
After selecting the variable, we will define the condition that triggers the notification. In this case, it is triggered when the <code>heartbeat</code> variable is less than 4:
Sending sms or email to authorized user based on the event configured on the cloud.
+
[[File:XUELK-AN-IIoT-14.png|thumb|center|600px]]
In the Event section, we can set a trigger, sms or an email to get
+
[[File:XUELK-AN-IIoT-15.png|thumb|center|600px]]
notification based our interest.
 
  
  
[[File:XUELK-AN-IIoT-11.png|thumb|center|600px|caption]]
+
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.
  
When we click the “Even option “, we will get the following 
+
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].
  
  
[[File:XUELK-AN-IIoT-12.png|thumb|center|600px|caption]]
 
  
 +
[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.
  
Then click the device (with the name already created, in this case mine device name = my_device_1) and select the variable.
+
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>
  
  
[[File:XUELK-AN-IIoT-13.png|thumb|center|600px|caption]]
+
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>
  
  
After selecting the variable, we will put the if then statement
+
Install Mosquitto
 +
<pre class="board-terminal">
 +
sudo apt-get update
 +
sudo apt-get install mosquitto
 +
</pre>
  
  
[[File:XUELK-AN-IIoT-14.png|thumb|center|600px|caption]]
+
Install Mosquitto developer libraries to develop MQTT clients
 +
<pre class="board-terminal">
 +
sudo apt-get install libmosquitto-dev
 +
</pre>
  
  
After putting a value to the if – then statement, we will select a means to get notification
+
Execute the following command to install Mosquitto client packages
 +
<pre class="board-terminal">
 +
sudo apt-get install mosquitto-clients
 +
</pre>
  
  
[[File:XUELK-AN-IIoT-15.png|thumb|center|600px|caption]]
+
Ensure that Mosquitto broker is running
 +
<pre class="board-terminal">
 +
sudo service mosquitto status
 +
</pre>
  
  
Then, we will put a statement (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
+
To verify that the broker is running properly, you can perform this simple test.
  
 +
Open a terminal and issue this command to subscribe the topic <code>mqtt</code>
 +
<pre class="board-terminal">
 +
mosquitto_sub -h localhost -t "mqtt" -v
 +
</pre>
  
[[File:XUELK-AN-IIoT-16.png|thumb|center|600px|caption]]
 
  
 +
Open another terminal and issue the given below command to publish message to the topic <code>mqtt</code>
 +
<pre class="board-terminal">
 +
mosquitto_pub -h localhost -t "mqtt" -m "Hello MQTT"
 +
</pre>
  
In this way, we can connect our device (SBC Lynx) to the ubidots cloud with Ubidot’s python api client and send data to the cloud then visualize it on the cloud in way we configured and also get notification by means of different ways.
+
Now the message <code>Hello MQTT</code> will be displayed in the first terminal where the topic <code>mqtt</code> was subscribed.
  
 
==References==
 
==References==

Latest revision as of 11:37, 5 January 2021

Info Box
SBC Lynx-top.png Applies to SBC Lynx
Cloud-computing-banner.jpg Applies to IoT
Warning-icon.png 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. Warning-icon.png

History[edit | edit source]

Version Date Notes
0.5.0 May 2017 First draft
0.6.0 May 2017 Added section "Configuring SBC Lynx as an MQTT broker"

Introduction[edit | edit source]

SBC Lynx is extremely flexible in terms of communication interfaces and I/O ports. When used in combination with a Linux distribution such as Debian, it is an ideal solution to implement compact highly-integrated cost-effective gateways/supervisors for Industrial Internet of Things applications (IIoT).

IIoT is a vast field that includes several disciplines. At field level, the typical IIoT system requires

  • collecting data from different in nature networks and fieldbuses (an RS485 bus, an Ethernet LAN, an IO-Link port, etc.)
  • uploading the data to the cloud over an Internet connection.

This application note provides some examples of hardware and software configurations that can be used for these purposes. Also, it shows how to harness the versatility of SBC Lynx to integrate on the same platform even processing and controlling functionalities. [1]

The examples were tested on an SBC Lynx board equipped with optional wireless module and that runs Debian distribution, as described here.


[1] It is worth remembering that SBC Lynx supports IEC 61131-3 compliant soft-PLC engines as well, such as Axel LogicLab.

Cloud interfacing[edit | edit source]

At the time of this writing, tens of cloud platforms are available on the market addressing IoT and IIoT applications. [1] Some of them provide free accounts for small projects or evaluation purposes.

The following sections describe how to interface an SBC Lynx-based gateway to some of such platforms.


[1] See for example this section.

Ubidots[edit | edit source]

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. 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 this application note.

Connecting and uploading data to Ubidots[edit | edit source]

As stated before, it is assumed that the board runs a Debian distribution:

root@arm:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.7 (jessie)
Release: 8.7
Codename: Jessie

To connect to the Ubidots platform, a client written in Python will be used. The client will make use of the Ubidots' client library (https://pypi.python.org/pypi/ubidots/). To install it, please issue the following commands as root user:

apt-get update
apt-get upgrade
apt-get install python-setuptools
easy_install pip
pip install ubidots

On the cloud side, we need to have a user account on the ubidots.com platform and get the API (a unique key for each account ) and token from the website, very simple.


Go to the website of the Ubidots cloud and click the sign up option on the right upper corner of the website to create the account.


XUELK-AN-IIoT-1.png


To get the API token for the just created account, go to the right upper corner of the home page and click on the username. Then you will see four options which are My Profile, API Credentials, Docs and Log Out.


XUELK-AN-IIoT-2.png


Click the API Credentials. The API token (fwSetosAgIG3d128YdzP5fi4hADzWU in this example) is a string which will be used later to initialize the API client instance.

XUELK-AN-IIoT-3.png


To create and initialize an API Client instance, use the following code:

from ubidots import ApiClient
api = ApiClient(token='fwSetosAgIG3d128YdzP5fi4hADzWU')


On the cloud side, it is necessary to create the variables that will store the values uploaded by the SBC Lynx. In the example, three variables are created: Fall_sensor, Flood_sensor and Temp_sensor. To create variables, there are three options in the upper center of the home page of the Ubidots interface, as shown below.

XUELK-AN-IIoT-4.png


Click the device option, then we will get the following:

XUELK-AN-IIoT-5.png


Click the device and add a variable:

XUELK-AN-IIoT-6.png


After adding the variables, we need their IDs. To get them, put the cursor on bottom side of each variable box. Then, you will see "I" option. Click it to get the ID.

To create an instance of the variable on the SBC Lynx side, use the following format code:

my_variable = api.get_variable('<variable ID>')

To upload a value to the Ubidots platform, we can use a code like this:

new_value = my_variable.save_value({'value': <value>})

Following is a code snippet that uploads random data to the platform:

from ubidots import ApiClient
import random
api = ApiClient(token='fwSetosAgIG3d128YdzP5fi4hADzWU')
my_variable_1 = api.get_variable('58cfe99b7625427aeab8a5e8')
test_value_1 = random.uniform(0,1)
test_value_1 = my_variable_1.save_value({'value':test_value_1})
my_variable_2 = api.get_variable('58d0df2f7625427ae8065765')
test_value_2 = random.randint(1,10)
test_value_2 = my_variable_2.save_value({'value':test_value_2})
my_variable_3 = api.get_variable('58d0f2d77625427ae6d4847f')
test_value_3 = random.randint(1,10)
test_value_3 = my_variable_3.save_value({'value':test_value_3})

Visualizing data on the cloud dashboards[edit | edit source]

To visualize the data sent to Ubidots, we have to use the Dashboards section, where we can configure how we want to visualize the data.

First, click the Dashboards link. Click the "+" symbol on the right upper corner. Then you will get the "How would you like to see your data?" question and different options below it:

  • Chart
  • Metric
  • Map
  • Indicator
  • Controller
  • ...
XUELK-AN-IIoT-8.png


In this example, the option chart was selected. As such, several further options are available:

XUELK-AN-IIoT-9.png


For all of the variables, the Line chart option was chosen. The following image shows how the data visualization looks like:

XUELK-AN-IIoT-10.png

Events and notifications[edit | edit source]

Ubidots allows sending notifications—for instance in the form of text messages (SMS) or 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 (heartbeat).

To configure notification options, click enter the Events section.

XUELK-AN-IIoT-11.png


Then sekect the device (My_device_1 in the example) ...

XUELK-AN-IIoT-12.png


... and click the variable you wish to configure the notification for.

XUELK-AN-IIoT-13.png


After selecting the variable, we will define the condition that triggers the notification. In this case, it is triggered when the heartbeat variable is less than 4:

XUELK-AN-IIoT-14.png
XUELK-AN-IIoT-15.png


Last, we compose the message we want to be emailed every time the notification is triggered.

XUELK-AN-IIoT-16.png

Device-to-device communications[edit | edit source]

Configuring SBC Lynx as an MQTT broker[edit | edit source]

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.).

MQTT-architecture.png

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 this link.


[1] https://www.ibm.com/developerworks/cloud/library/cl-mqtt-bluemix-iot-node-red-app/

Installing the broker[edit | edit source]

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 SBC Lynx running Debian Jessie distribution. First, import the repository package signaling key:

wget  http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquito-repo.gpg.key 


Make the reposioty available for the mqtt:

cd /etc/apt/sources.lit.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list


Install Mosquitto

sudo apt-get update
sudo apt-get install mosquitto


Install Mosquitto developer libraries to develop MQTT clients

sudo apt-get install libmosquitto-dev


Execute the following command to install Mosquitto client packages

sudo apt-get install mosquitto-clients


Ensure that Mosquitto broker is running

sudo service mosquitto status


To verify that the broker is running properly, you can perform this simple test.

Open a terminal and issue this command to subscribe the topic mqtt

mosquitto_sub -h localhost -t "mqtt" -v


Open another terminal and issue the given below command to publish message to the topic mqtt

mosquitto_pub -h localhost -t "mqtt" -m "Hello MQTT"

Now the message Hello MQTT will be displayed in the first terminal where the topic mqtt was subscribed.

References[edit | edit source]

List of IoT cloud platforms (not exhaustive)[edit | edit source]

  • mnubo
  • Oracle
  • Swarm
  • Axeda
  • OpenRemote
  • Etherios
  • ioBridge
  • SAP Internet of Things Solutions
  • Zatar
  • ThingWorx
  • Arrayent
  • Sine-Wave Technologies
  • Ayla Networks
  • Echelon
  • EVRYTHNG
  • Exosite
  • Xively
  • Marvell
  • Carriots
  • Arkessa
  • GroveStreams
  • CeNSE by HP
  • ARM
  • Nimbits
  • Open Sen.se
  • Paraimpu 15
  • Sociot.al
  • NewAer
  • SensorCloud
  • ThingSpeak
  • Yaler
  • Jasper
  • XobXob
  • Linkafy
  • Revolv
  • Wind River
  • Wovyn
  • InfoBright
  • Contiki
  • 2lemetry
  • AllJoyn
  • InterDigital
  • Superflux Internet of Things Academy (IoTA)
  • HarvestGeek
  • MediaTek Labs
  • Streamlite LTE
  • Bosch Software Innovations Suite
  • Geras
  • Ubidots
  • Opensensors.IO
  • Tinamous
  • Temboo
  • Eyehub
  • Nearbus
  • Exosite
  • Emoncms
  • Gemalto
  • IBM Watson
  • Microsoft Azure
  • Amazon AWS
  • Senseiot
  • Parse
  • SICS
  • Element blue
  • Sparkfun
  • Kaa
  • Salesforce
  • PRDIX