Connect an MXChip IoT DevKit device to your Azure IoT Central application
This article describes how, as a device developer, to connect a MXChip IoT DevKit (DevKit) device to your Microsoft Azure IoT Central application.
Before you begin
To complete the steps in this article, you need the following:
- An Azure IoT Central application created from the Sample Devkits application template. For more information, see Create your Azure IoT Central Application.
- A DevKit device. To purchase a DevKit device, visit MXChip IoT DevKit.
An application created from the Sample Devkits application template includes a MXChip device template with the following characteristics:
|Field name||Units||Minimum||Maximum||Decimal places|
|Display name||Field name||Units||Decimal places||Minimum||Maximum||Initial|
|Display name||Field name||On text||Off text||Initial|
|Type||Display name||Field name||Data type|
|Device property||Die number||dieNumber||number|
Add a real device
In your Azure IoT Central application, add a real device from the MXChip device template and make a note of the device connection string. For more information, see Add a real device to your Azure IoT Central application.
Prepare the DevKit device
For DevKit device troubleshooting guidance, see IoT DevKit get started.
To prepare the DevKit device:
Download the latest pre-built Azure IoT Central firmware for the MXChip from the releases page on GitHub. The download filename on the releases page looks like
Connect the DevKit device to your development machine using a USB cable. In Windows, a file explorer window opens on a drive mapped to the storage on the DevKit device. For example, the drive might be called AZ3166 (D:).
Drag the iotCentral.bin file onto the drive window. When the copying is complete, the device reboots with the new firmware.
When the DevKit device restarts, the following screen displays:
WiFi name: AZ3166_?????? mac:???? Ready to connect
If the screen displays a MAC address consisting of only zeros, press the Reset button on the device.
The device is now in access point (AP) mode. You can connect to this WiFi access point from your computer or mobile device.
On your computer, phone, or tablet connect to the WiFi network name shown on the screen of the device. When you connect to this network, you do not have internet access. This state is expected, and you are only connected to this network for a short time while you configure the device.
Open your web browser and navigate to http://192.168.0.1/start. The following web page displays:
In the web page, add the name of your WiFi network, your WiFi network password, and the connection string of your device. Select all the available telemetry measurements.
You made a note of the connection string in the "Before you begin" section in this article.
After you choose Configure Device, you see this page:
Press the Reset button on your device.
To reconfigure the device to use a different WiFi network, connection string, or telemetry measurement, press both the A and B buttons on the board simultaneously.
View the telemetry
When the DevKit device restarts, the screen on the device shows:
- The number of telemetry messages sent.
- The number of failures.
- The number of desired properties received and the number of reported properties sent.
Shake the device increment the number of reported properties sent. The device sends a random number as the Die number device property.
You can view the telemetry measurements and reported property values, and configure settings in Azure IoT Central:
Make sure that Builder Mode is off.
Use Device Explorer to navigate to the Measurements page for the real MXChip device you added:
On the Measurements page, you can see the telemetry coming from the MXChip device:
On the Properties page, you can view the last die number reported by the device:
On the Settings page, you can update the settings on the MXChip device:
Download the source code
If you want to explore and modify the device code, you can download it from GitHub. If you plan to modify the code, you should follow these instructions to prepare the development environment for your desktop operating system.
To download the source code, run the following command on your desktop machine:
git clone https://github.com/Microsoft/microsoft-iot-central-firmware.git
The previous command downloads the source code to a folder called
If git is not installed in your development environment, you can download it from https://git-scm.com/download.
Review the code
Use Visual Studio Code, which was installed when you prepared your development environment, to open the
AZ3166 folder in the
To see how the telemetry is sent to the Azure IoT Central application, open the main_telemetry.cpp file in the source folder.
buildTelemetryPayload creates the JSON telemetry payload using data from the sensors on the device.
sendTelemetry in the iotHubClient.cpp to send the JSON payload to the IoT Hub your Azure IoT Central application uses.
To see how property values are reported to the Azure IoT Central application, open the main_telemetry.cpp file in the source folder.
telemetryLoop sends the doubleTap reported property when the accelerometer detects a double tap. It uses the
sendReportedProperty function in the iotHubClient.cpp source file.
The code in the iotHubClient.cpp source file uses functions from the Microsoft Azure IoT SDKs and libraries for C to interact with IoT Hub.
For information about how to modify, build, and upload the sample code to your device, see the readme.md file in the
Now that you have learned how to connect a DevKit device to your Azure IoT Central application, here are the suggested next steps: