Verify Device-to-Cloud Communication

Now you will verify that device-to-cloud communication is taking place by using the Serial Monitor in Visual Studio Code and checking your Azure Portal.

  1. Ensure that you have your GetStarted project opened in Visual Studio Code and that your device is connected to you PC.
  2. In Visual Studio Code, examine the status bar that runs along the bottom of the window.
  3. Hover your mouse pointer over each of the buttons on the status bar. You should see label appear that identifies the purpose associated with the buttons.
  4. Use the button labels to locate the following buttons:
    • Show Board Config
    • Open Serial Monitor
    • Select Serial Port
    The Open Serial Monitor button is the button displaying the icon that looks like a power plug.
  1. In Visual Studio Code, on the bottom status bar, click the Select Serial Port button.
  2. At the top of the Visual Studio Code window, notice the prompt asking you to “Select a serial port”.
  3. At the prompt, select the COM port labeled STMicroelectronics You may recall seeing the STMicroelectronics name pop up when you were configuring your MXChip device. The STMicroelectronics driver is used to communicate with the MXChip AZ3166 device.
  4. On the bottom status bar, click the Baud Rate button, and then click 115200 If your application is running successfully, you see something similar to the following:
  1. Open a browser window and navigate to your Azure portal: portal.azure.com You should see your dashboard and the Resources tile. If you don’t, verify that you are logged in with the Azure account and subscription that you are using.
  2. Open your IoT Hub, and review the information displayed on the Overview blade.
  3. Notice that the IoT Hub Usage tile shows you that messages are arriving at your IoT Hub.

Register Your MXChip Device with IoT Hub

Every IoT hub has an identity registry that stores information about the devices that are permitted to connect to it. Before a device can connect to an IoT hub, there must be an entry for that device in the IoT hub’s identity registry. A device must also authenticate with the IoT hub based on credentials stored in the identity registry.

In this task, you will register your MXChip AZ3166 device with your IoT Hub.

  1. Ensure that you have the GetStarted sample open in Visual Studio Code and that your MXChip AZ3166 device is connected to your PC.
  2. In the Visual Studio Code window, press Ctrl + P.
  3. At the prompt, to select the task that will provision your device, type task c and then click cloud-provision
  1. When prompted within the command line instructions, select the Azure subscription that you are using, and then press Enter The provisioning process will then check your subscription for an IoT Hub that it can use.
  2. When prompted within the command line instructions, select the IoT Hub that you created earlier, and then press Enter. You should see an option to select the hub that you created.
  3. When prompted that the provisioning process is complete, press Enter. You device, which has been named AZ3166, has now been registered with your IoT Hub. You can open you Azure portal to verify that it was created.
  4. Open a browser window and navigate to your Azure portal.
  5. On your dashboard, use your Resources tile to open your IoT Hub. Click the IoT Hub resource to open it.
  6. On the Overview blade, notice that the IoT Hub Usage tile now indicates that you have 1 IoT Device.
  7. On the left-side menu, click *IoT devices.
  8. Notice that a device has been created with the device ID set to “AZ3166”.

Configure the MXCHip Dev Environment

Now it’s time to set up the development environment

  1. Download and install the Arduino IDE
    • Windows: Use Windows Installer version Important: Do not select the installer for the Windows App, select the Windows installer version. The Windows installer is a .exe file that will install the Arduino IDE to the C:\Program Files (x86) folder location.You can download and save the installer before running it if you want – it is named something similar to the following: arduino-1.8.8-windows.exe
  2. Launch Visual Studio Code
  3. Open the Extensions panel with the keyboard shortcut Ctrl + Shift + X
  4. Search for azure workbench
  5. Click on the Azure IoT Device Workbench extension
  6. Click Install
  7. Once the extension is finished installing, click Reload
  8. Open the Visual Studio Code preferences with the keyboard shortcut Ctrl + ,
  9. Click the {} icon in the upper right hand corner of the window to edit the JSON
  10. Add the following JSON to your User settings file.

“arduino.path”: “C:\\Program Files (x86)\\Arduino”, “arduino.additionalUrls”: “https://raw.githubusercontent.com/VSChina/azureiotdevkit_tools/master/package_azureboard_index.json”,

On the File menu, click Save All, and then close and restart Visual Studio Code. When Visual Studio Code restarts you may see some installation tasks launch. Follow the on-screen instruction to complete the installation process if needed.

  1. On the File menu, click Save All, and then close and restart Visual Studio Code. When Visual Studio Code restarts you may see some installation tasks launch. Follow the on-screen instruction to complete the installation process if needed.
  2. Press F1 to open the command palette
  3. Type Board Manager
  4. Select Arduino: Board Manager and press Enter
  5. In the search box, type az3166 Note: There should be one item titled MXChip – Microsoft Azure IoT Developer Kit by Microsoft Developer.
  6. Select the latest version from the drop down, and then click Install

ST-Link Configuration

The USB interface used to communicate with your MXChip is ST-Link.

Windows

Download and install USB driver from STMicro.

Next time i will show you how to register your MXChip device with IoT hub.