Search by Tags

Azure IoT device SDKs for Linux

 
Applicable for

Compare with Revision




Subscribe for this article updates

Overview

The Azure IoT device SDKs are available for multiple platforms & programming languages. The following SDKs are supported by the Toradex Linux images:

  • C#
  • Javascript (node.js)
  • Java

Below are instructions to quickly evaluate the various Azure IoT device SDKs on Toradex modules flashed with a V2.5 (or later) Linux image. These instructions require that you setup an Azure IoT Hub instance. Additionally, the Azure IoT Hub Device Explorer is used to verify functionality in all the proceeding examples.

C# with Mono

Setup Mono on the Device

Install Mono & related packages:

opkg update
opkg install mono mono-dev ca-certificates openssl

Import trusted certificates:

mono /usr/lib/mono/4.5/mozroots.exe --import --sync

Build C# Example Applications

On your host computer, use the Azure IoT C# Application Development guides to build an example C# application (e.g. DeviceClientHttpSample).

Execute C# Example Application

Transfer the compiled C# example application to the device.

Start the Device Explorer application on your host machine.

Execute the C# example application (i.e. DeviceClientHttpSample.exe) on the device using Mono:

mono DeviceClientHttpSample.exe

Javascript with Node.js

Setup Node.js & the Azure IoT Javascript Libraries on the Device

Install Node.js & related packages:

opkg update
opkg install nodejs nodejs-npm python python-simplejson

Copy all the files from the Azure github samples directory into a directory of your choice. Then, inside this directory, install the required Node packages.

npm install

Configure & Execute Example Node.js Application

Edit the example javascript file(s) (e.g. simple_sample_http.js):

vi simple_sample_device.js

and locate the following line to change [IoT Device Connection String] to your connection string as provided by your IoT hub instance:

var connectionString = '[IoT Device Connection String]';

Start the Device Explorer application on your host machine.

Execute the sample application using Node.js:

node simple_sample_device.js

Java with OpenJDK

Setup the OpenJDK 7 JRE on the Device

Configure additional package repositories on the device and install the OpenJDK 7 JRE and associated dependencies:

wget -P /etc/opkg/ http://feeds.toradex.com/extra/2.5/conf/all/extra.conf
opkg update
opkg install openjdk-7-jre openssl

Import trusted certificates:

wget https://www.geotrust.com/resources/root_certificates/certificates/Equifax_Secure_Certificate_Authority.pem
wget https://cacert.omniroot.com/bc2025.crt
/usr/lib/jvm/java-7-openjdk/jre/bin/keytool -keystore ~/cacerts -importcert -alias equifaxsecureca -file  Equifax_Secure_Certificate_Authority.pem
/usr/lib/jvm/java-7-openjdk/jre/bin/keytool -keystore ~/cacerts -importcert -alias baltimorecybertrustca -file bc2025.crt
/usr/lib/jvm/java-7-openjdk/jre/bin/keytool -list -keystore ~/cacerts

Build Example Java Applications

On your host computer, use the Azure IoT Java Application Development guides to build an example Java application (e.g. send-event.java).

Execute Java Example Application

Transfer the compiled Java example application to the device.

Start the Device Explorer application on your host machine.

Execute the Java example application (i.e. send-event-X.X.X-with-deps.jar) on the device using the OpenJDK JRE - change [IoT Device Connection String] to the connection string as provided by your IoT hub instance:

java -Djavax.net.ssl.trustStore=~/cacerts -jar send-event-X.X.X-with-deps.jar "[IoT Device Connection String]" "5" "https"