page_type | description | languages | products | |||||
---|---|---|---|---|---|---|---|---|
sample |
Connecting a Realtek Ameba D device to Azure IoT using the Azure SDK for Embedded C |
|
|
This is a guide outlining how to run an Azure SDK for Embedded C IoT Hub telemetry sample on an Realtek AmebaD development board.
- Configuration instructions for the Arduino IDE to compile a sample using the Azure SDK for Embedded C.
- Configuration, build, and run instructions for the IoT Hub telemetry sample.
The following was run on Windows 10 and Ubuntu Desktop 20.04 environments, with Arduino IDE 1.8.12 and Realtek Boards module 3.0.7.
-
Have an Azure account created.
-
Have an Azure IoT Hub created.
-
Have a logical device created in your Azure IoT Hub using the authentication type "Symmetric Key".
NOTE: Device keys are used to automatically generate a SAS token for authentication, which is only valid for one hour.
-
Have the latest Arduino IDE installed.
-
Install the USB drivers for the Realtek AmebaD board.
- You might need to install a USB driver directly from https://www.ftdichip.com/Drivers/VCP.htm
-
Have the Realtek AmebaD board packages installed on Arduino IDE. Realtek boards are not natively supported by Arduino IDE, so you need to add them manually.
- Realtek boards are not natively supported by Arduino IDE, so you need to add them manually.
- Follow the instructions in the official Realtek AmebaD page.
-
Have one of the following interfaces to your Azure IoT Hub set up:
-
Azure Command Line Interface (Azure CLI) utility installed, along with the Azure IoT CLI extension.
On Windows:
Download and install: https://aka.ms/installazurecliwindows
PS C:\>az extension add --name azure-iot
On Linux:
$ curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash $ az extension add --name azure-iot
A list of all the Azure IoT CLI extension commands can be found here.
-
The most recent version of Azure IoT Explorer installed. More instruction on its usage can be found here.
NOTE: This guide demonstrates use of the Azure CLI and does NOT demonstrate use of Azure IoT Explorer.
-
-
Run the Arduino IDE.
-
Install the Azure SDK for Embedded C library.
- On the Arduino IDE, go to menu
Sketch
,Include Library
,Manage Libraries...
. - Search for and install
azure-sdk-for-c
.
- On the Arduino IDE, go to menu
-
Open the Realtek AmebaD sample.
- On the Arduino IDE, go to menu
File
,Examples
,azure-sdk-for-c
. - Click on
az_realtek_amebaD
to open the sample.
- On the Arduino IDE, go to menu
-
Configure the Realtek AmebaD sample.
Enter your Azure IoT Hub and device information into the sample's
iot_configs.h
. -
Connect the Realtek AmebaD board to your USB port.
-
On the Arduino IDE, select the board and port.
- Go to menu
Tools
,Board
and selectAmeba ARM (32-bits) Boards
/RTL8722DM/RTL8722CSM
. - Go to menu
Tools
,Port
and select the port to which the microcontroller is connected.
- Go to menu
-
Upload the sketch.
- Go to menu
Sketch
and click onUpload
.
- Go to menu
-
Monitor the MCU (microcontroller) locally via the Serial Port.
-
Go to menu
Tools
,Serial Monitor
.If you perform this step right away after uploading the sketch, the serial monitor will show an output similar to the following upon success:
Connecting to WIFI SSID buckaroo .......................WiFi connected, IP address: 192.168.1.123 Setting time using SNTP..............................done! Current time: Thu May 28 02:55:05 2020 Client ID: mydeviceid Username: myiothub.azure-devices.net/mydeviceid/?api-version=2018-06-30&DeviceClientType=c%2F1.0.0 Password: SharedAccessSignature sr=myiothub.azure-devices.net%2Fdevices%2Fmydeviceid&sig=placeholder-password&se=1590620105 MQTT connecting ... connected.
-
-
Monitor the telemetry messages sent to the Azure IoT Hub using the connection string for the policy name
iothubowner
found under "Shared access policies" on your IoT Hub in the Azure portal.$ az iot hub monitor-events --login <your Azure IoT Hub owner connection string in quotes> --device-id <your device id>
Expected telemetry output:
Starting event monitor, filtering on device: mydeviceid, use ctrl-c to stop... { "event": { "origin": "mydeviceid", "payload": "payload" } } { "event": { "origin": "mydeviceid", "payload": "payload" } } { "event": { "origin": "mydeviceid", "payload": "payload" } } { "event": { "origin": "mydeviceid", "payload": "payload" } } { "event": { "origin": "mydeviceid", "payload": "payload" } } { "event": { "origin": "mydeviceid", "payload": "payload" } } ^CStopping event monitor...
The Azure IoT service certificates presented during TLS negotiation shall always be validated, on the device, using the appropriate trusted root CA certificate(s).
The Azure SDK for C Arduino library automatically installs the root certificate used in the United States regions, and adds it to the Arduino sketch project when the library is included.
For other regions (and private cloud environments), please use the appropriate root CA certificate.
For important information and additional guidance about certificates, please refer to this blog post from the security team.
- The error policy for the Embedded C SDK client library is documented here.
- File an issue via Github Issues.
- Check previous questions or ask new ones on StackOverflow using the
azure
andc
tags.
This project welcomes contributions and suggestions. Find more contributing details here.
This Azure SDK for C Arduino library is licensed under MIT license.
Azure SDK for Embedded C is licensed under the MIT license.