The following document describes the process of connecting an Arduino Yun system to Azure IoT Hub.
- Requirements
- Before you begin
- Setup the OpenWRT SDK
- Build the sample
- Deploy the sample
- Run the sample
- Computer with a Git client installed so that you can access the azure-iot-sdks code on GitHub.
- Arduino Yun board.
- Debian x86
Before you begin you will need to create and configure an IoT hub to connect to.
- Set up your IoT Hub.
- With your IoT hub configured and running in Azure, follow the instructions in Connecting your device to an IoT hub.
- Make note of the Connection String for your device from the previous step.
Note: You can skip this step if you just want to build the sample application without running it.
## Setup the development environmentThis section shows you how to set up a development environment for the Azure IoT device SDK for C on Arduino Yun.
Install dependencies under root/sudo.
apt-get install curl libcurl4-openssl-dev uuid-dev uuid g++ make cmake git unzip openjdk-7-jre libssl-dev libncurses-dev subversion
- Clone this repository (azure-iot-sdks) to the machine you are using.
- Open a shell and navigate to the folder c/build_all/arduino in your local copy of the repository.
- Run the
setup.sh
script to install the OpenWRT SDK and prerequisites. By default, the SDK will be installed at ~/openwrt/sdk - (Optional) Enter 'Y' to build the Azure IoT SDK.
This script builds the iothub_client and serializer libraries and their associated samples.
Note: you will not be able to run the samples until you configure them with a valid IoT Hub device connection string. For more information, see Run sample on Linux.
## Build the sample- Open the file c/serializer/samples/simplesample_http/simplesample_http.c in a text editor.
- Locate the following code in the file:
static const char* connectionString = "[device connection string]";
- Replace "[device connection string]" with the device connection string you noted earlier. Save the changes.
- The section "Send events" in the document How to use Device Explorer describes how to prepare the DeviceExplorer tool to receive device-to-cloud messages from the sample application.
- Run the
build.sh
script in the c/build_all/arduino directory.
- Open a shell and navigate to the installed OpenWRT SDK folder. By default, it is ~/openwrt/sdk.
- Transfer the package.
OpenWRT Yun Image:
scp bin/ar71xx/packages/azure-iot-sdks_1-1_ar71xx.ipk [email protected]:/tmp
LininoIO Yun Image:
scp bin/ar71xx/packages/azure-iot-sdks_1-1_ar71xx.ipk [email protected]:/tmp
The following instructions assumes the device is flashed with OpenWRT Yun. If you are using LininoIO, substitute arduino
with linino
and use the default password doghunter
.
- Open shell and enter
ssh [email protected]
Enter the device password. By default it is,arduino
for OpenWRT Yun Image ordoghunter
for LininoIO. - Install the package.
opkg install /tmp/azure-iot-sdks_1-1_ar71xx.ipk
- Navigate to /usr/share/azure-iot-sdk/samples
- run ./simplesample_http
- Use the DeviceExplorer utility to observe the messages IoT Hub receives from the simplesample_http application.
- See "Send cloud-to-device messages" in the document How to use Device Explorer for IoT Hub devices for instructions on sending messages with the DeviceExplorer utility.