platform | device | language |
---|---|---|
arduino ide |
arduino wifi shield 101 |
c |
About this document
This document describes the process of connecting an Arduino WiFi Shield 101 or MKR1000 based system to the Azure IoT Hub. 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.
- A computer with the Arduino IDE version 1.6.6 or later installed.
- One of the following:
- Setup your IoT hub
- Provision your device and get its credentials
The sample won't run on older 8-bit AVR-based Arduinos (like the UNO or Mega 2560). A modern 32-bit ARM Cortex M0+ MCU is required (e.g. Atmel’s SAMD21 MCU).
This section shows you how to set up a development environment for the Azure IoT device SDK with the Arduino or Genuino WiFi 101 shield or MKR1000 board.
- Open the Arduino IDE and install the following libraries using the
Library Manager
, which can be accessed viaSketch -> Include Library -> Managed Libraries ...
WiFi101
RTCZero
AzureIoT
- Flash the root certificate of the Azure IoT hub host,
<name>.azure-devices.net
found in Connection String from earlier, using the instructions available on the "Firmware/Certificates updater for the Arduino Wifi 101 Shield" page.
- In the Arduino IDE, select
Arduino/Genuino MKR1000
orArduino/Genuino Zero (Programming Port)
as the board in theTools -> Board
menu. - Open the
simplesample_http
example in the Arduino IDE,File -> Examples -> AzureIoT -> sdk -> simplesample_http
- In
simplesample_http.ino
, update the following line with your WiFi accesspoint's SSID:char ssid[] = "yourNetwork"; // your network SSID (name)
- Update the following line with your WiFi accesspoint's password:
char pass[] = "secretPassword"; // your network password (use for WPA, or use as key for WEP)
- Locate the following code in the
simplesample_http.c
:static const char* connectionString = "[device connection string]";
- Replace
[device connection string]
with the device connection string you noted earlier. - Locate the following code in the
simplesample_http.c
:myWeather->DeviceId = "myFirstDevice";
- Replace
"myFirstDevice"
with the name you gave to the device earlier. - Save the changes. Press the
Verify
button in the Arduino IDE to build the sample sketch.
- Follow the steps from the build section.
- If you are using the Zero, connect the board to the WiFi Shield 101 and then connect the programming port of the board to your computer with a USB cable. For the MKR1000, connect the board to your computer with a USB cable.
- Select serial port associated with the board in the
Tools -> Port
menu. - Press the
Upload
button in the Arduino IDE to build and upload the sample sketch.
-
Follow the steps from the deploy section.
-
See Manage IoT Hub to learn how to observe the messages IoT Hub receives from the simplesample_http application and how to send cloud-to-device messages to the simplesample_http application.