platform | device | language |
---|---|---|
mlinux |
multiconnect conduit |
c |
- Introduction
- Step 1: Prerequisites
- Step 2: Prepare your Device
- Step 3: Build and Run the Sample
- Tips
- Next Steps
About this document
This document describes how to connect MultiConnect Conduit device running mLinux with Azure IoT SDK. This multi-step process includes:
- Configuring Azure IoT Hub
- Registering your IoT device
- Build and deploy Azure IoT SDK on device
You should have the following items ready before beginning the process:
- Prepare your development environment
- Setup your IoT hub
- Provision your device and get its credentials
- MultiConnect Conduit device.
- A host computer or virtual machine running Linux with a connection to your MultiConnect Conduit
- mLinux C/C++ Toolchain
Follow the appropriate Getting Started guide for your Conduit to connect to the same network as your host PC
-
If you have not already done so, install the mLinux C/C++ Toolchain
-
From a terminal on the host, load the cross compilation environment using:
$ source /<path to sdk>/environment-setup-arm926ejste-mlinux-linux-gnueabi
By default this would be::
$ source /opt/mlinux/<version>/environment-setup-arm926ejste-mlinux-linux-gnueabi
-
Download the Microsoft Azure IoT Device SDK for C to the board by issuing the following command on the host
git clone --recursive https://github.com/Azure/azure-iot-sdk-c.git
-
The MultiConnect Conduit supports AMQP, HTTP and MQTT. Edit the example file for the protocol(s) you wish to use using any text editor of your choice:
-
AMQP
azure-iot-sdk-c/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqp.c
-
HTTP
azure-iot-sdk-c/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_http.c
-
MQTT
azure-iot-sdk-c/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_mqtt.c
-
-
Find the following place holder for IoT connection string:
static const char* connectionString = "[device connection string]";
-
Replace the above placeholder with device connection string you obtained in Step 1 and save the changes.
-
Create a new file "toolchain.cmake" in the azure-iot-sdk-c directory and enter the text
INCLUDE(CMakeForceCompiler) SET(CMAKE_SYSTEM_NAME Linux) SET(CMAKE_SYSTEM_PROCESSOR ARM) SET(CMAKE_SYSTEM_VERSION 1) SET(CROSS_COMPILE arm-mlinux-linux-eabi-) SET(CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT}) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-
Build the SDK using following command.
./build_all/linux/build.sh --toolchain-file toolchain.cmake
-
Transfer the compiled example(s) to your MultiConnect Conduit:
scp ./cmake/iotsdk_linux/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqp admin@<MultiConnect Conduit IP address>:~/ scp ./cmake/iotsdk_linux/iothub_client/samples/iothub_client_sample_http/iothub_client_sample_http admin@<MultiConnect Conduit IP address>:~/ scp ./cmake/iotsdk_linux/iothub_client/samples/iothub_client_sample_mqtt/iothub_client_sample_mqtt admin@<MultiConnect Conduit IP address>:~/
-
Open a terminal connection to your MultiConnect Conduit over ssh or microUSB
-
Run the sample by issuing the command for the protocol you wish to run:
~/iothub_client_sample_amqp ~/iothub_client_sample_http ~/iothub_client_sample_mqtt
-
See Manage IoT Hub to learn how to observe the messages IoT Hub receives from the application.
- See Manage IoT Hub to learn how to send cloud-to-device messages to the application.
-
If you just want to build the serializer samples, run the following commands:
cd ./c/serializer/build/linux make -f makefile.linux all
You have now learned how to run a sample application that collects sensor data and sends it to your IoT hub. To explore how to store, analyze and visualize the data from this application in Azure using a variety of different services, please click on the following lessons:
- Manage cloud device messaging with iothub-explorer
- Save IoT Hub messages to Azure data storage
- Use Power BI to visualize real-time sensor data from Azure IoT Hub
- Use Azure Web Apps to visualize real-time sensor data from Azure IoT Hub
- Weather forecast using the sensor data from your IoT hub in Azure Machine Learning
- Remote monitoring and notifications with Logic Apps