| platform | ubuntu |
|---|---|
| device | ankaa |
| language | c |
- Introduction
- Step 1: Prerequisites
- Step 2: Prepare your Device
- Step 3: Build and Run the Sample
- Tips
About this document
This document describes how to connect Ankaa device running Ubuntu 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:
- Computer with Git client installed and access to the azure-iot-sdks GitHub public repository.
- Ankaa device.
- Setup your IoT hub
- Provision your device and get its credentials
- Install the Ubuntu operating system on your Ankaa device.
- Connect the Ankaa board to your desktop machine using the USB mini cable and open a terminal emulator program such as Tera Term on your desktop machine and switch ON the device. You have to create a new Serial port connection from Setup->Serial Port and set the parameters:
- Port number where you have connected the device to PC.
- Baud Rate = 115200
- Data = 8 bits
- Parity = noneStop = 1 bit
- Flow Control = none
- When prompted, log in with username root, and password root. The root account is necessary in order to install some libraries required by the device SDK.
- If you want to connect your Ankaa to your Wired network connect it using an ethernet cable to the device ethernet port. For Wireless connection, Ankaa have it's own WiFi module so there is no need to connect any WiFi dongle.
- You need to determine the IP address of your Ankaa in order to connect over the network. To connect the network, follow the steps under Ethernet or WiFi for the corresponding connection type from the document "esomimx6_ubuntu_peripheral_test_user_manual.pdf"
Run the following commands in the terminal window connected to your Ankaa device.
-
Install the prerequisite packages for the Microsoft Azure IoT Device SDK for C by issuing the following commands from the command line on your board:
sudo apt-get update sudo apt-get install -y curl libcurl4-openssl-dev build-essential cmake gitIf you get errors running sudo, make sure your root password is set as described above.
Note: Right-click in a Tera Term terminal window to paste the copied text.
Note: This setup process requires cmake version 2.8.12 or higher.
You can verify the current version installed in your environment using the following command:
cmake --versionThis library also requires gcc version 4.9 or higher. You can verify the current version installed in your environment using the following command:
gcc --versionFor information about how to upgrade your version of gcc on Ubuntu 14.04, see http://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-4-9-on-ubuntu-14-04.
-
Download the Microsoft Azure IoT Device SDK for C to the board by issuing the following command on the board::
git clone --recursive https://github.com/Azure/azure-iot-sdks.git -
Edit the following file using any text editor of your choice:
For AMQP protocol:
azure-iot-sdks/c/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqp.cFor HTTP protocol:
azure-iot-sdks/c/iothub_client/samples/iothub_client_sample_http/iothub_client_sample_http.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.
-
Build the SDK samples using the following command:
sudo ./azure-iot-sdks/c/build_all/linux/build.sh
-
Run the sample by issuing following command:
For AMQP protocol:
~/cmake/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqpFor HTTP protocol:
~/cmake/c/iothub\_client/samples/iothub_client_sample_http/iothub_client_sample_http -
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 iothub_client, go to the cmake output directory and navigate to the iothub_client/samples folder then run the following command:
make -f Makefile all