SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Azure IoT Hub on a Toradex
Colibri VF61 – Part 1:
Sending data to the cloud
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 2
CHAIRMAN
Introduction
The concept of the Internet of Things is intrinsically related to
the sending of data to the internet and its so called cloud
services. People from the electronics field are everyday more
easily connecting devices to the cloud as the evolution of technology is allowing the
use of smaller and less power-consuming electronics as time goes by. Still there is an
unanswered question for many of these electronics developers: how to make all of the
gathered data useful? Because that is what the Internet of Things is about.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 3
CHAIRMAN
There are some examples of real applications taken from the Microsoft website in
order to share a preview of what the IoT can represent: there is an elevator company
using the internet of things to improve and give predictive maintenance; an
automation company using IoT to have insights from the oil and gas industry's
supply chain, along with predictive maintenance; and a company that uses IoT to
predict drivers behaviors and optimize car utilization. By the end of this series of
articles, it is expected that the reader might have enough information and tools ready
to deploy applications that retrieve insights and/or optimize its overall system – not
only an amount of data stacked, but some useful output!
Azure is the Microsoft cloud services platform and it provides an amount of
applications such as databases, virtual machines, app services, machine learning,
data stream analysis, media and CDN services, big data solutions, among many
others, including the IoT Hub.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 4
CHAIRMAN
By itself, the vastness of services offered is already a good reason to use the Azure
services, but Microsoft goes one step ahead and compare its services with the
Amazon Web Services to reinforce that their solution is the better – a strong
statement that only users and time will confirm, or the other way around. Among the
reasons to use their services is the security offered, the easiness of integration and
the gentle learning curve.
The main goal of this article is to develop an IoT application, from the reading of field
sensors to the presentation of results and the retrieving of business intelligence. The
hardware used to collect the sensors data and send it to the cloud is: a Toradex Colibri
VF61 SoM + the Iris Carrier Board, since Toradex is an Azure IoT certified partner. .
This is, therefore, an advantage, once Toradex is an Azure IoT Certified Partner.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 5
CHAIRMAN
The application should get some sensors data and send it to an IoT service from the
Microsoft Azure cloud solution, called Azure IoT Hub. Once the data is being received on
the cloud, it can be processed in many ways by other Microsoft Azure services. That is
what will be done in the second part of this article series, but for now the focus will be
on how to configure the Azure IoT Hub and send messages to it.
The chosen IoT environment was the monitoring of a car. For demonstration purposes,
sensors were attached to a remote controlled car, to which a Toradex customized SBC
was also embedded. In the image 1 it is possible to see the picture of the demo and the
image 2 holds a block representation of the aimed application.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 6
CHAIRMAN
Image 1: The remote controlled car
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 7
CHAIRMAN
Image 2: Block diagram of the application
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 8
CHAIRMAN
The programming language chosen to develop the target application is the
Javascript along with Node.js: a server-side (which in this case is the Toradex
embedded system) Javascript interpreter built on the Chrome's V8 engine. Its
choice was based on the availability of libraries provided by the Azure Iot Hub
SDKs. It should be noticed that the IoT Hub SDKs are under heavy development,
with changes being made every new release (at least for Node), and it should be
taken under consideration. The release version of the Azure IoT Node packages
being used in this article is the version 1.0.1.
The setup of the whole environment, from the programming of the embedded
system to the configuration of Azure in order to receive data was divided in three
steps, described in this article:
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 9
CHAIRMAN
• Configuration of the Azure environment
• Adding devices and sending messages to the IoT Hub
• Programming the Toradex embedded system application
Configuration of the Azure environment
The first step needed to start developing the whole system is to create an Azure
account: a free account can be created from the Azure website as a 30 day trial. Than
a fixed amount of azure credits can be used to deploy applications that use the Azure
services without charge; also, the IoT Hub has a free version dedicated to
development, with limited resources, also free of charge, even beyond the trial
period. For more details about the pricing and the IoT Hub per se, the IoT Hub page
can be visited.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 10
CHAIRMAN
After setting an Azure account, it is first needed to create an IoT Hub. For that,
the Azure portal should be accessed using the newly created account and the
options +New > Internet of Things > Azure IoT Hub selected. The configuration
screen for the new IoT Hub is shown in image 3. The option "Free" should be
selected in the Pricing and scale tier; a new resource group should be created in
the Resource Group field and the Location selected must match the location of the
other services to be deployed later. Any Name can be chosen and the IoT Hub
Units and Device-to-cloud partitions fields cannot be edited in the free version.
After clicking create, the service will be deployed – and it might take a few
seconds.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 11
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 12
CHAIRMAN
That being done, the IoT Hub should appear in the Dashboard, that is, the main
Azure Portal page. After clicking it, a page like in the image 4 should open: there
will be some Essentials information such as the region of the IoT Hub; an Usage
section that gives a feedback to the system administrator regarding how many
messages were sent from devices to this service and the number of registered
devices; and a Monitoring section where the number of messages received over
time are displayed.
Image 3: Creating an IoT Hub from the Azure Portal
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 13
CHAIRMAN
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 14
CHAIRMAN
Image 4: IoT Hub main panel
Still on the panel from image 4, in order to gain access to the service from other
applications, the Shared access policies option over the Settings tab should be selected.
In the new tab Shared access policies that will open, there will be a policy called
"iothubowner", which has all possible permissions to this IoT Hub and it should be
clicked. The iothubowner tab will open and its Connection string – primary key should
be copied for later usage: it is the key that will allow management and monitoring of
this IoT Hub devices in the next steps. The tabs described in this paragraph to get the
connection string are illustrated in the image 5.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 15
CHAIRMAN
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 16
CHAIRMAN
Adding devices and sending messages to the IoT Hub
Now that everything is configured in the cloud, the iothub-exporer tool needs to be
installed on the development machine so that devices can be added to the IoT Hub.
There is another tool named Device Explorer, only available for Windows systems,
so if Windows is being used in the development machine, this option might be
checked out. Since in this article the Ubuntu 14.04 is being used, I will stick to the
iothub-explorer. It should be noted that the Node version running needs to be at
least 0.12.x (it says a version 4.x or higher is needed for all the features to work),
but at the time this article was written, the apt-get tool was currently installing
some 0.10.x version. To solve this issue, the Node Version Manager (NVM) and,
subsequently, the Node version 0.12.9 were installed. From the terminal, the
iothub-explorer can be installed using the NPM (Node Package Manager):
Image 5: Getting the iothubowner connection string
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 17
CHAIRMAN
leonardo@leonardo:~$ npm install iothub-explorer@latest
Then the iothub-explorer can be run with the help option to see its usage possibilities:
leonardo@leonardo:~$ iothub-explorer help
As it can be seen in the terminal from the previous command, among the iothub-
explorer options there are create and monitor-events. In order to use this tool, the
connection string acquired in the image 5 must be used. First of all, a device named
"tdx_iot_car" will be created, as in the command below. Note the option –connection-
string that displays the device connection string (not to be confused with the IoT Hub
connection string). It should be copied since it is the key used to connect this newly
created device to the IoT Hub, by enabling the Colibri VF61 application to send
messages to the Hub.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 18
CHAIRMAN
leonardo@leonardo:~$ iothub-explorer "HostName=toradex.azure-
devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=putyoursharedacc
esskeyfromtheconnectionstringhere" create tdx_iot_car --connection-string
Created device tdx_iot_car
-
deviceId: tdx_iot_car
generationId: 635931262207620183
etag: MA==
connectionState: Disconnected
status: enabled
statusReason: null
connectionStateUpdatedTime: 0001-01-01T00:00:00
statusUpdatedTime: 0001-01-01T00:00:00
lastActivityTime: 0001-01-01T00:00:00
cloudToDeviceMessageCount: 0
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 19
CHAIRMAN
authentication:
SymmetricKey:
primaryKey: somesharedaccesskeyreturned
secondaryKey: somesecondaryaccesskeyreturned
-
connectionString: HostName=toradex.azure-
devices.net;DeviceId=tdx_iot_car;SharedAccessKey=somesharedaccesskeyreturned
Programming the Toradex embedded system application
Now a Colibri VF61 SoM + Iris Carrier Board should be set. In this article a pre-build
image (Colibri_VF_LinuxConsoleImageV2.5) that can be downloaded here was used.
Instructions on how to flash the image to the Colibri module can be found here. In
order to install the Node.js, the NPM package and git, the following instructions were
issued – be aware that it might take a few minutes to complete, especially the curl
instruction:
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 20
CHAIRMAN
The repository where are the packages installer and the node file regarding this
article example – send_data.js – can be cloned into the the board. To clone and install
the node packages, the following commands must be run:
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 21
CHAIRMAN
Now the code that sends data to the IoT Hub can be run, but first let's explain some
points about it: it is used the HTTP protocol to provide communication, but the AMQP
and MQTT protocols are also supported; The variable named connectionString value
must be the same string got from a few steps above, while creating the device with the
iothub-explorer:
var connectionString = "HostName=toradex.azure-
devices.net;DeviceId=tdx_iot_car;SharedAccessKey=somesharedaccesske
yreturned"
Inside the setInterval() loop many values are randomly created to be sent to the IoT
Hub as if it were data from some sensors, such as temperature, distance from an
ultrasonic sensor, acceleration and gyro, some gps coordinates and the date/time
from the board.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 22
CHAIRMAN
How to get this data from real sensors will be addressed in the next article from this
series. The JSON.Stringify() function generates a JSON encoded string from the data
and it is encapsulated in a Message object to be sent. Below an example of a a JSON
formatted string is presented:
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 23
CHAIRMAN
In case everything goes well, the callback function from the sendEvent() method
should not print anything to the console while the code is running. The following
command runs the Colibri VF61 code and displays the feedback message
continuously printed to the console when all goes right:
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 24
CHAIRMAN
As a feedback to guarantee that the data is being received, the IoT Hub section of the
Azure Portal should update the daily message count and the monitoring graph should
present with a spike, as shown in image 6. Note that it might take from a few seconds to
more than a minute until this information gets updated in the portal.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 25
CHAIRMAN
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 26
CHAIRMAN
Image 6: Checking in the Azure Portal that data is being received
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 27
CHAIRMAN
To see the data stream that is coming into the IoT Hub, the iothub-explorer tool
may be used. To achieve this, the monitor-events option must be used with the
device id. Note that, for this to work, the Colibri VF61 application must be running
at the same time that the iothub-explorer, whereas to see the statistics from the
Azure Portal there is no need for it. The image 7 displays the iothub-explorer
receiving the data while the board was sending it simultaneously. The command to
monitor the events is displayed above, before the image:
leonardo@leonardo:~$ iothub-explorer
"your_iothub_connection_string" monitor-events yourdevice
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 28
CHAIRMAN
Image 7: Receiving data from the board into the iothub-explorer
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 29
CHAIRMAN
The Microsoft Azure website has plenty of documentation about the Iot Hub as more
information is needed to develop more complex and/or robust applications. There are
things such as creating a device, or getting messages sent from devices to the Hub, that
can be accomplished programatically – refering to the documentation is a good way to
obtain more information on the matter. Also, in the next article the focus will be in
interfacing some sensors to the Colibri VF61 + Iris Carrier Board and than, as real data
is sent to the IoT Hub, it can be used as an input to other Azure services that can
generate insights and/or add some control variables to the deployed application.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 30
CHAIRMAN
I hope it was a helpful introductory article on how to join a Toradex SBC solution with
the Azure IoT Hub service and that you may find it useful! Also, I would like to thank the
Grupo Viceri team from Brazil for their expertise regarding Azure and Business
Intelligence, that led to the partnership that which resulted in the IoT Car project. See
you soon in the next article.
This blog post was originally featured on Embarcados.com in Portuguese. See here.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 31
Thank
you!

Weitere ähnliche Inhalte

Andere mochten auch

Andere mochten auch (20)

Big data streaming with Apache Spark on Azure
Big data streaming with Apache Spark on AzureBig data streaming with Apache Spark on Azure
Big data streaming with Apache Spark on Azure
 
Enterprise Data Workflows with Cascading and Windows Azure HDInsight
Enterprise Data Workflows with Cascading and Windows Azure HDInsightEnterprise Data Workflows with Cascading and Windows Azure HDInsight
Enterprise Data Workflows with Cascading and Windows Azure HDInsight
 
Azure Stream Analytics : Analyse Data in Motion
Azure Stream Analytics  : Analyse Data in MotionAzure Stream Analytics  : Analyse Data in Motion
Azure Stream Analytics : Analyse Data in Motion
 
2016-08-25 TechExeter - going serverless with Azure
2016-08-25 TechExeter - going serverless with Azure2016-08-25 TechExeter - going serverless with Azure
2016-08-25 TechExeter - going serverless with Azure
 
Going serverless
Going serverlessGoing serverless
Going serverless
 
Azure HDInsight
Azure HDInsightAzure HDInsight
Azure HDInsight
 
Software scope
Software scopeSoftware scope
Software scope
 
Azure functions
Azure functionsAzure functions
Azure functions
 
Open up to a better learning ecosystem
Open up to a better learning ecosystemOpen up to a better learning ecosystem
Open up to a better learning ecosystem
 
Spark on Azure HDInsight - spark meetup seattle
Spark on Azure HDInsight - spark meetup seattleSpark on Azure HDInsight - spark meetup seattle
Spark on Azure HDInsight - spark meetup seattle
 
Building big data solutions on azure
Building big data solutions on azureBuilding big data solutions on azure
Building big data solutions on azure
 
Microsoft Azure For Solutions Architects
Microsoft Azure For Solutions ArchitectsMicrosoft Azure For Solutions Architects
Microsoft Azure For Solutions Architects
 
Going serverless
Going serverlessGoing serverless
Going serverless
 
Industrial Internet of Things in Cleantech
Industrial Internet of Things in CleantechIndustrial Internet of Things in Cleantech
Industrial Internet of Things in Cleantech
 
DC Spark bake off - Realtime TCP Packet Analysis using Spark and Azure Event ...
DC Spark bake off - Realtime TCP Packet Analysis using Spark and Azure Event ...DC Spark bake off - Realtime TCP Packet Analysis using Spark and Azure Event ...
DC Spark bake off - Realtime TCP Packet Analysis using Spark and Azure Event ...
 
Getting started with azure event hubs and stream analytics services
Getting started with azure event hubs and stream analytics servicesGetting started with azure event hubs and stream analytics services
Getting started with azure event hubs and stream analytics services
 
Spark in yarn managed multi-tenant clusters
Spark in yarn managed multi-tenant clustersSpark in yarn managed multi-tenant clusters
Spark in yarn managed multi-tenant clusters
 
Azure Stream Analytics
Azure Stream AnalyticsAzure Stream Analytics
Azure Stream Analytics
 
Big data solutions in azure
Big data solutions in azureBig data solutions in azure
Big data solutions in azure
 
Event Hub & Azure Stream Analytics
Event Hub & Azure Stream AnalyticsEvent Hub & Azure Stream Analytics
Event Hub & Azure Stream Analytics
 

Ähnlich wie Azure IoT Hub on a Toradex Colibri VF61 – Part 1 - Sending data to the cloud

The Security Of Cloud Computing
The Security Of Cloud ComputingThe Security Of Cloud Computing
The Security Of Cloud Computing
Julie May
 
Seminar_report on Microsoft Azure Service
Seminar_report on Microsoft Azure ServiceSeminar_report on Microsoft Azure Service
Seminar_report on Microsoft Azure Service
ANAND PRAKASH
 
A unified dashboard for collaborative robot management system
A unified dashboard for collaborative robot management systemA unified dashboard for collaborative robot management system
A unified dashboard for collaborative robot management system
Conference Papers
 

Ähnlich wie Azure IoT Hub on a Toradex Colibri VF61 – Part 1 - Sending data to the cloud (20)

IoT Parking Lot Demo on Toradex Modules
IoT Parking Lot Demo on Toradex ModulesIoT Parking Lot Demo on Toradex Modules
IoT Parking Lot Demo on Toradex Modules
 
Simplifying IoT App Development - A Whitepaper by RapidValue
Simplifying IoT App Development - A Whitepaper by RapidValueSimplifying IoT App Development - A Whitepaper by RapidValue
Simplifying IoT App Development - A Whitepaper by RapidValue
 
Azure IoT Hub on a Toradex Colibri VF61 – Part 2 - Interfacing sensors and th...
Azure IoT Hub on a Toradex Colibri VF61 – Part 2 - Interfacing sensors and th...Azure IoT Hub on a Toradex Colibri VF61 – Part 2 - Interfacing sensors and th...
Azure IoT Hub on a Toradex Colibri VF61 – Part 2 - Interfacing sensors and th...
 
Learn how to make your IoT pilot projects and POCs successful
Learn how to make your IoT pilot projects and POCs successfulLearn how to make your IoT pilot projects and POCs successful
Learn how to make your IoT pilot projects and POCs successful
 
ONLINE FOOD ORDERS THROUGH WHATSAPP AUTOMATION BOT
ONLINE FOOD ORDERS THROUGH WHATSAPP AUTOMATION BOTONLINE FOOD ORDERS THROUGH WHATSAPP AUTOMATION BOT
ONLINE FOOD ORDERS THROUGH WHATSAPP AUTOMATION BOT
 
IOT Based Smart City: Weather, Traffic and Pollution Monitoring System
IOT Based Smart City: Weather, Traffic and Pollution Monitoring System      IOT Based Smart City: Weather, Traffic and Pollution Monitoring System
IOT Based Smart City: Weather, Traffic and Pollution Monitoring System
 
Windows Azure(Pr-1).ppt.pptx
Windows Azure(Pr-1).ppt.pptxWindows Azure(Pr-1).ppt.pptx
Windows Azure(Pr-1).ppt.pptx
 
The Security Of Cloud Computing
The Security Of Cloud ComputingThe Security Of Cloud Computing
The Security Of Cloud Computing
 
Seminar_report on Microsoft Azure Service
Seminar_report on Microsoft Azure ServiceSeminar_report on Microsoft Azure Service
Seminar_report on Microsoft Azure Service
 
IBM Bluemix Nice Meetup #1 - CEEI NCA - 20160630 -
IBM Bluemix Nice Meetup #1 - CEEI NCA - 20160630 - IBM Bluemix Nice Meetup #1 - CEEI NCA - 20160630 -
IBM Bluemix Nice Meetup #1 - CEEI NCA - 20160630 -
 
Cloud computing in iot seminar report
Cloud computing in iot seminar reportCloud computing in iot seminar report
Cloud computing in iot seminar report
 
Modular Embedded Design to Accelerate IoT Proliferation
Modular Embedded Design to Accelerate IoT ProliferationModular Embedded Design to Accelerate IoT Proliferation
Modular Embedded Design to Accelerate IoT Proliferation
 
Ultimate list of 50 Best IoT platforms of 2019
Ultimate list of 50 Best  IoT platforms of 2019Ultimate list of 50 Best  IoT platforms of 2019
Ultimate list of 50 Best IoT platforms of 2019
 
8 pre launch steps to go with the web rtc based application development
8 pre launch steps to go with the web rtc based application development8 pre launch steps to go with the web rtc based application development
8 pre launch steps to go with the web rtc based application development
 
IRJET- IoT based Vending Machine with Cashless Payment
IRJET- IoT based Vending Machine with Cashless PaymentIRJET- IoT based Vending Machine with Cashless Payment
IRJET- IoT based Vending Machine with Cashless Payment
 
A unified dashboard for collaborative robot management system
A unified dashboard for collaborative robot management systemA unified dashboard for collaborative robot management system
A unified dashboard for collaborative robot management system
 
IRJET- Smart Parking System using IoT
IRJET- Smart Parking System using IoTIRJET- Smart Parking System using IoT
IRJET- Smart Parking System using IoT
 
Iot App Demt (2).pdf
Iot App Demt (2).pdfIot App Demt (2).pdf
Iot App Demt (2).pdf
 
IRJET - Multitenancy using Cloud Computing Features
IRJET - Multitenancy using Cloud Computing FeaturesIRJET - Multitenancy using Cloud Computing Features
IRJET - Multitenancy using Cloud Computing Features
 
Programming IoT Gateways with macchina.io
Programming IoT Gateways with macchina.ioProgramming IoT Gateways with macchina.io
Programming IoT Gateways with macchina.io
 

Mehr von Toradex

Mehr von Toradex (20)

Toradex Strengthens Custom Solutions Offering with Acquisition of Linear Comp...
Toradex Strengthens Custom Solutions Offering with Acquisition of Linear Comp...Toradex Strengthens Custom Solutions Offering with Acquisition of Linear Comp...
Toradex Strengthens Custom Solutions Offering with Acquisition of Linear Comp...
 
プレスリリース:ToradexがJapan IT Week【春】2024年に出展
プレスリリース:ToradexがJapan IT Week【春】2024年に出展プレスリリース:ToradexがJapan IT Week【春】2024年に出展
プレスリリース:ToradexがJapan IT Week【春】2024年に出展
 
Introducing Aquila: The Next Generation Toradex SoM Family
Introducing Aquila: The Next Generation Toradex SoM FamilyIntroducing Aquila: The Next Generation Toradex SoM Family
Introducing Aquila: The Next Generation Toradex SoM Family
 
Join Toradex at Japan IT Week Spring 2024
Join Toradex at Japan IT Week Spring 2024Join Toradex at Japan IT Week Spring 2024
Join Toradex at Japan IT Week Spring 2024
 
Toradex announces Titan Eval Kit w/ NXP's i.MX 95 - Early Access Program
Toradex announces Titan Eval Kit w/ NXP's i.MX 95 - Early Access ProgramToradex announces Titan Eval Kit w/ NXP's i.MX 95 - Early Access Program
Toradex announces Titan Eval Kit w/ NXP's i.MX 95 - Early Access Program
 
ToradexがJapan IT Week【春】2023年に出展
ToradexがJapan IT Week【春】2023年に出展ToradexがJapan IT Week【春】2023年に出展
ToradexがJapan IT Week【春】2023年に出展
 
NXP Semiconductors elevates Toradex to Platinum Partner status
NXP Semiconductors elevates Toradex to Platinum Partner statusNXP Semiconductors elevates Toradex to Platinum Partner status
NXP Semiconductors elevates Toradex to Platinum Partner status
 
Webinar: Secure Offline and Online Updates for Linux Devices
Webinar: Secure Offline and Online Updates for Linux DevicesWebinar: Secure Offline and Online Updates for Linux Devices
Webinar: Secure Offline and Online Updates for Linux Devices
 
Toradex opens office in Tokyo, reaffirming its growth strategy in the Asia-Pa...
Toradex opens office in Tokyo, reaffirming its growth strategy in the Asia-Pa...Toradex opens office in Tokyo, reaffirming its growth strategy in the Asia-Pa...
Toradex opens office in Tokyo, reaffirming its growth strategy in the Asia-Pa...
 
Toradex launches Verdin featuring NXP i.MX 8M Mini/Nano SoMs
Toradex launches Verdin featuring NXP i.MX 8M Mini/Nano SoMsToradex launches Verdin featuring NXP i.MX 8M Mini/Nano SoMs
Toradex launches Verdin featuring NXP i.MX 8M Mini/Nano SoMs
 
Ethernet Compliance Testing at Toradex
Ethernet Compliance Testing at ToradexEthernet Compliance Testing at Toradex
Ethernet Compliance Testing at Toradex
 
Webinar On-demand: Introducing the new Colibri SoM based on the NXP i.MX 6ULL...
Webinar On-demand: Introducing the new Colibri SoM based on the NXP i.MX 6ULL...Webinar On-demand: Introducing the new Colibri SoM based on the NXP i.MX 6ULL...
Webinar On-demand: Introducing the new Colibri SoM based on the NXP i.MX 6ULL...
 
Starting with OpenCV on i.MX 6 Processors
Starting with OpenCV on i.MX 6 ProcessorsStarting with OpenCV on i.MX 6 Processors
Starting with OpenCV on i.MX 6 Processors
 
Cloud-Aided Yocto Build Speedup
Cloud-Aided Yocto Build SpeedupCloud-Aided Yocto Build Speedup
Cloud-Aided Yocto Build Speedup
 
Toradex Global Video Montage
Toradex Global Video MontageToradex Global Video Montage
Toradex Global Video Montage
 
Considerations on usage of Computer on Modules for Applications inside Emerge...
Considerations on usage of Computer on Modules for Applications inside Emerge...Considerations on usage of Computer on Modules for Applications inside Emerge...
Considerations on usage of Computer on Modules for Applications inside Emerge...
 
Customizable Embedded 3D Surround View Turn-Key Solution on Apalis iMX6 SoM
Customizable Embedded 3D Surround View Turn-Key Solution on Apalis iMX6 SoMCustomizable Embedded 3D Surround View Turn-Key Solution on Apalis iMX6 SoM
Customizable Embedded 3D Surround View Turn-Key Solution on Apalis iMX6 SoM
 
288 Core ARM® and 13’824 CUDA Core Microserver Cluster with Toradex Apalis Sy...
288 Core ARM® and 13’824 CUDA Core Microserver Cluster with Toradex Apalis Sy...288 Core ARM® and 13’824 CUDA Core Microserver Cluster with Toradex Apalis Sy...
288 Core ARM® and 13’824 CUDA Core Microserver Cluster with Toradex Apalis Sy...
 
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
 
Developing Real-Time Systems on Application Processors
Developing Real-Time Systems on Application ProcessorsDeveloping Real-Time Systems on Application Processors
Developing Real-Time Systems on Application Processors
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Azure IoT Hub on a Toradex Colibri VF61 – Part 1 - Sending data to the cloud

  • 1. Azure IoT Hub on a Toradex Colibri VF61 – Part 1: Sending data to the cloud
  • 2. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 2 CHAIRMAN Introduction The concept of the Internet of Things is intrinsically related to the sending of data to the internet and its so called cloud services. People from the electronics field are everyday more easily connecting devices to the cloud as the evolution of technology is allowing the use of smaller and less power-consuming electronics as time goes by. Still there is an unanswered question for many of these electronics developers: how to make all of the gathered data useful? Because that is what the Internet of Things is about.
  • 3. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 3 CHAIRMAN There are some examples of real applications taken from the Microsoft website in order to share a preview of what the IoT can represent: there is an elevator company using the internet of things to improve and give predictive maintenance; an automation company using IoT to have insights from the oil and gas industry's supply chain, along with predictive maintenance; and a company that uses IoT to predict drivers behaviors and optimize car utilization. By the end of this series of articles, it is expected that the reader might have enough information and tools ready to deploy applications that retrieve insights and/or optimize its overall system – not only an amount of data stacked, but some useful output! Azure is the Microsoft cloud services platform and it provides an amount of applications such as databases, virtual machines, app services, machine learning, data stream analysis, media and CDN services, big data solutions, among many others, including the IoT Hub.
  • 4. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 4 CHAIRMAN By itself, the vastness of services offered is already a good reason to use the Azure services, but Microsoft goes one step ahead and compare its services with the Amazon Web Services to reinforce that their solution is the better – a strong statement that only users and time will confirm, or the other way around. Among the reasons to use their services is the security offered, the easiness of integration and the gentle learning curve. The main goal of this article is to develop an IoT application, from the reading of field sensors to the presentation of results and the retrieving of business intelligence. The hardware used to collect the sensors data and send it to the cloud is: a Toradex Colibri VF61 SoM + the Iris Carrier Board, since Toradex is an Azure IoT certified partner. . This is, therefore, an advantage, once Toradex is an Azure IoT Certified Partner.
  • 5. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 5 CHAIRMAN The application should get some sensors data and send it to an IoT service from the Microsoft Azure cloud solution, called Azure IoT Hub. Once the data is being received on the cloud, it can be processed in many ways by other Microsoft Azure services. That is what will be done in the second part of this article series, but for now the focus will be on how to configure the Azure IoT Hub and send messages to it. The chosen IoT environment was the monitoring of a car. For demonstration purposes, sensors were attached to a remote controlled car, to which a Toradex customized SBC was also embedded. In the image 1 it is possible to see the picture of the demo and the image 2 holds a block representation of the aimed application.
  • 6. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 6 CHAIRMAN Image 1: The remote controlled car
  • 7. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 7 CHAIRMAN Image 2: Block diagram of the application
  • 8. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 8 CHAIRMAN The programming language chosen to develop the target application is the Javascript along with Node.js: a server-side (which in this case is the Toradex embedded system) Javascript interpreter built on the Chrome's V8 engine. Its choice was based on the availability of libraries provided by the Azure Iot Hub SDKs. It should be noticed that the IoT Hub SDKs are under heavy development, with changes being made every new release (at least for Node), and it should be taken under consideration. The release version of the Azure IoT Node packages being used in this article is the version 1.0.1. The setup of the whole environment, from the programming of the embedded system to the configuration of Azure in order to receive data was divided in three steps, described in this article:
  • 9. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH June’16 9 CHAIRMAN • Configuration of the Azure environment • Adding devices and sending messages to the IoT Hub • Programming the Toradex embedded system application Configuration of the Azure environment The first step needed to start developing the whole system is to create an Azure account: a free account can be created from the Azure website as a 30 day trial. Than a fixed amount of azure credits can be used to deploy applications that use the Azure services without charge; also, the IoT Hub has a free version dedicated to development, with limited resources, also free of charge, even beyond the trial period. For more details about the pricing and the IoT Hub per se, the IoT Hub page can be visited.
  • 10. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 10 CHAIRMAN After setting an Azure account, it is first needed to create an IoT Hub. For that, the Azure portal should be accessed using the newly created account and the options +New > Internet of Things > Azure IoT Hub selected. The configuration screen for the new IoT Hub is shown in image 3. The option "Free" should be selected in the Pricing and scale tier; a new resource group should be created in the Resource Group field and the Location selected must match the location of the other services to be deployed later. Any Name can be chosen and the IoT Hub Units and Device-to-cloud partitions fields cannot be edited in the free version. After clicking create, the service will be deployed – and it might take a few seconds.
  • 11. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 11
  • 12. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 12 CHAIRMAN That being done, the IoT Hub should appear in the Dashboard, that is, the main Azure Portal page. After clicking it, a page like in the image 4 should open: there will be some Essentials information such as the region of the IoT Hub; an Usage section that gives a feedback to the system administrator regarding how many messages were sent from devices to this service and the number of registered devices; and a Monitoring section where the number of messages received over time are displayed. Image 3: Creating an IoT Hub from the Azure Portal
  • 13. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 13 CHAIRMAN
  • 14. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 14 CHAIRMAN Image 4: IoT Hub main panel Still on the panel from image 4, in order to gain access to the service from other applications, the Shared access policies option over the Settings tab should be selected. In the new tab Shared access policies that will open, there will be a policy called "iothubowner", which has all possible permissions to this IoT Hub and it should be clicked. The iothubowner tab will open and its Connection string – primary key should be copied for later usage: it is the key that will allow management and monitoring of this IoT Hub devices in the next steps. The tabs described in this paragraph to get the connection string are illustrated in the image 5.
  • 15. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 15 CHAIRMAN
  • 16. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 16 CHAIRMAN Adding devices and sending messages to the IoT Hub Now that everything is configured in the cloud, the iothub-exporer tool needs to be installed on the development machine so that devices can be added to the IoT Hub. There is another tool named Device Explorer, only available for Windows systems, so if Windows is being used in the development machine, this option might be checked out. Since in this article the Ubuntu 14.04 is being used, I will stick to the iothub-explorer. It should be noted that the Node version running needs to be at least 0.12.x (it says a version 4.x or higher is needed for all the features to work), but at the time this article was written, the apt-get tool was currently installing some 0.10.x version. To solve this issue, the Node Version Manager (NVM) and, subsequently, the Node version 0.12.9 were installed. From the terminal, the iothub-explorer can be installed using the NPM (Node Package Manager): Image 5: Getting the iothubowner connection string
  • 17. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 17 CHAIRMAN leonardo@leonardo:~$ npm install iothub-explorer@latest Then the iothub-explorer can be run with the help option to see its usage possibilities: leonardo@leonardo:~$ iothub-explorer help As it can be seen in the terminal from the previous command, among the iothub- explorer options there are create and monitor-events. In order to use this tool, the connection string acquired in the image 5 must be used. First of all, a device named "tdx_iot_car" will be created, as in the command below. Note the option –connection- string that displays the device connection string (not to be confused with the IoT Hub connection string). It should be copied since it is the key used to connect this newly created device to the IoT Hub, by enabling the Colibri VF61 application to send messages to the Hub.
  • 18. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 18 CHAIRMAN leonardo@leonardo:~$ iothub-explorer "HostName=toradex.azure- devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=putyoursharedacc esskeyfromtheconnectionstringhere" create tdx_iot_car --connection-string Created device tdx_iot_car - deviceId: tdx_iot_car generationId: 635931262207620183 etag: MA== connectionState: Disconnected status: enabled statusReason: null connectionStateUpdatedTime: 0001-01-01T00:00:00 statusUpdatedTime: 0001-01-01T00:00:00 lastActivityTime: 0001-01-01T00:00:00 cloudToDeviceMessageCount: 0
  • 19. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 19 CHAIRMAN authentication: SymmetricKey: primaryKey: somesharedaccesskeyreturned secondaryKey: somesecondaryaccesskeyreturned - connectionString: HostName=toradex.azure- devices.net;DeviceId=tdx_iot_car;SharedAccessKey=somesharedaccesskeyreturned Programming the Toradex embedded system application Now a Colibri VF61 SoM + Iris Carrier Board should be set. In this article a pre-build image (Colibri_VF_LinuxConsoleImageV2.5) that can be downloaded here was used. Instructions on how to flash the image to the Colibri module can be found here. In order to install the Node.js, the NPM package and git, the following instructions were issued – be aware that it might take a few minutes to complete, especially the curl instruction:
  • 20. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 20 CHAIRMAN The repository where are the packages installer and the node file regarding this article example – send_data.js – can be cloned into the the board. To clone and install the node packages, the following commands must be run:
  • 21. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 21 CHAIRMAN Now the code that sends data to the IoT Hub can be run, but first let's explain some points about it: it is used the HTTP protocol to provide communication, but the AMQP and MQTT protocols are also supported; The variable named connectionString value must be the same string got from a few steps above, while creating the device with the iothub-explorer: var connectionString = "HostName=toradex.azure- devices.net;DeviceId=tdx_iot_car;SharedAccessKey=somesharedaccesske yreturned" Inside the setInterval() loop many values are randomly created to be sent to the IoT Hub as if it were data from some sensors, such as temperature, distance from an ultrasonic sensor, acceleration and gyro, some gps coordinates and the date/time from the board.
  • 22. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 22 CHAIRMAN How to get this data from real sensors will be addressed in the next article from this series. The JSON.Stringify() function generates a JSON encoded string from the data and it is encapsulated in a Message object to be sent. Below an example of a a JSON formatted string is presented:
  • 23. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 23 CHAIRMAN In case everything goes well, the callback function from the sendEvent() method should not print anything to the console while the code is running. The following command runs the Colibri VF61 code and displays the feedback message continuously printed to the console when all goes right:
  • 24. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 24 CHAIRMAN As a feedback to guarantee that the data is being received, the IoT Hub section of the Azure Portal should update the daily message count and the monitoring graph should present with a spike, as shown in image 6. Note that it might take from a few seconds to more than a minute until this information gets updated in the portal.
  • 25. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 25 CHAIRMAN
  • 26. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 26 CHAIRMAN Image 6: Checking in the Azure Portal that data is being received
  • 27. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 27 CHAIRMAN To see the data stream that is coming into the IoT Hub, the iothub-explorer tool may be used. To achieve this, the monitor-events option must be used with the device id. Note that, for this to work, the Colibri VF61 application must be running at the same time that the iothub-explorer, whereas to see the statistics from the Azure Portal there is no need for it. The image 7 displays the iothub-explorer receiving the data while the board was sending it simultaneously. The command to monitor the events is displayed above, before the image: leonardo@leonardo:~$ iothub-explorer "your_iothub_connection_string" monitor-events yourdevice
  • 28. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 28 CHAIRMAN Image 7: Receiving data from the board into the iothub-explorer
  • 29. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 29 CHAIRMAN The Microsoft Azure website has plenty of documentation about the Iot Hub as more information is needed to develop more complex and/or robust applications. There are things such as creating a device, or getting messages sent from devices to the Hub, that can be accomplished programatically – refering to the documentation is a good way to obtain more information on the matter. Also, in the next article the focus will be in interfacing some sensors to the Colibri VF61 + Iris Carrier Board and than, as real data is sent to the IoT Hub, it can be used as an input to other Azure services that can generate insights and/or add some control variables to the deployed application.
  • 30. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 30 CHAIRMAN I hope it was a helpful introductory article on how to join a Toradex SBC solution with the Azure IoT Hub service and that you may find it useful! Also, I would like to thank the Grupo Viceri team from Brazil for their expertise regarding Azure and Business Intelligence, that led to the partnership that which resulted in the IoT Car project. See you soon in the next article. This blog post was originally featured on Embarcados.com in Portuguese. See here.
  • 31. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 31 Thank you!