Use Cloud Explorer for Visual Studio to send and receive messages between your device and IoT Hub
Cloud Explorer is a useful Visual Studio extension that enables you to view your Azure resources, inspect their properties and perform key developer actions from within Visual Studio. This article focuses on how to use Cloud Explorer to send and receive messages between your device and your IoT Hub.
Some of the features mentioned in this article, like cloud-to-device messaging, device twins, and device management, are only available in the standard tier of IoT hub. For more information about the basic and standard IoT Hub tiers, see How to choose the right IoT Hub tier.
What you will learn
You will learn how to use Cloud Explorer for Visual Studio to monitor device-to-cloud messages and to send cloud-to-device messages. Device-to-cloud messages could be sensor data that your device collects and then sends to your IoT Hub. Cloud-to-device messages could be commands that your IoT Hub sends to your device. For example, blink an LED that is connected to your device.
What you will do
- Use Cloud Explorer for Visual Studio to monitor device-to-cloud messages.
- Use Cloud Explorer for Visual Studio to send cloud-to-device messages.
What you need
- An active Azure subscription.
- An Azure IoT Hub under your subscription.
- Microsoft Visual Studio 2017 Update 8 or later
- Cloud Explorer component from Visual Studio Installer (selected by default with Azure Workload)
Update Cloud Explorer to latest version
The Cloud Explorer component from Visual Studio Installer only supports monitoring device-to-cloud and cloud-to-device messages. In order to send messages to device or cloud, you download and install the latest Cloud Explorer.
Sign in to access your IoT Hub
In Visual Studio Cloud Explorer window, click the Account Management icon. You can open the Cloud Explorer window from View > Cloud Explorer menu.
Click Manage Accounts in Cloud Explorer.
Click Add an account... in the new window to sign in to Azure for the first time.
After you sign in, your Azure subscription list will be shown. Select the Azure subscriptions you want to view and click Apply.
Expand Your subscription > IoT Hubs > Your IoT Hub, the device list will be shown under your IoT Hub node.
Monitor device-to-cloud messages
To monitor messages that are sent from your device to your IoT Hub, follow these steps:
Right-click your IoT Hub or device and select Start Monitoring D2C Message.
The monitored messages will be shown in the IoT Hub output pane.
To stop monitoring, right-click on any IoT Hub or device and select Stop Monitoring D2C Message.
Send cloud-to-device messages
To send a message from your IoT Hub to your device, follow these steps:
Right-click your device and select Send C2D Message.
Enter the message in input box.
Results will be shown in the IoT Hub output pane.
You’ve learned how to monitor device-to-cloud messages and send cloud-to-device messages between your IoT device and Azure IoT Hub.
To continue to get started with Azure IoT Hub and to explore all extended IoT scenarios, see the following: