Skip navigation
Home > All Places > WICED Studio Wi-Fi/Combo > WICED Studio Wi-Fi/Combo Forums > Blog > Authors MichaelF_56
MichaelF_56

MQTT with Microsoft Azure

Posted by MichaelF_56 Moderator Sep 26, 2017

Microsoft Azure is a cloud computing service created by Microsoft for building, testing, deploying, and managing applications and services through a global network of Microsoft-managed data centers. It provides a service called “Azure IoT Hub” for implementing Internet of Things solutions. IoT Hub enables devices to communicate with the IoT Hub device endpoints using the MQTT v3.1.1 protocol on port 8883 or MQTT v3.1.1 over WebSocket protocol on port 443. IoT Hub requires all device communication to be secured using TLS/SSL (hence, IoT Hub doesn’t support non-secure connections over port 1883). A device can use the MQTT protocol directly to connect to an IoT hub. To monitor/trigger the messages exchanged between cloud and device, Device Explorer tool can be used.

 

This Help Article discusses how to use CYW943907AEVAL1F EVK for connecting to Azure IoT Hub.

 

Create an account in portal.azure.com. Create an IoT Hub and note down the generated connection string.

  1. Open the pub_sub_azure.zip file provided along with this post in WICED Studio 5.1 or above.
  2. Open the file wifi_config_dct.h to configure the Device Configuration Table (DCT). Modify the values of the macros CLIENT_AP_SSID and CLIENT_AP_PASSPHRASE to match your Wi-Fi access point SSID and password respectively. Ensure that the AP is connected to the internet.
  3. In pub_sub_azure.c file, following macros are defined to connect to the Azure IoT Hub.

#define   IOT_HUB_NAME                              " "

Update the name of the Azure IoT Hub in above macro.

                 #define   DEVICE_NAME                                " "

                 Update the name of the device.

                 #define   PASSWORD                                     " "

Open Device Explorer tool. In Configuration tab, paste the connection string of your IoT Hub. Click onUpdate and then click on Generate SAS (Shared Access Signature).

 

 

To create a device, go to Management tab and click on Create.

 

 

In the pop-up window, type the Device ID (device name). Click on Create.

 

 

To obtain password, select your device in Management tab and click on SAS Token.

 

 

In the pop-up window, type TTL(days) (message expiration time) as 365 and click on Generate.

 

 

You will get password in the format shown above as SharedAccessSignature.

 

After updating the above macros, create make target, run & download program to WICED device.

To verify the output in Device Explorer, select the device you have created in Management tab. Go to Data. Click on the checkbox Start time & click on Monitor.

 

 

Go to Messages to Device. Type the text in box Message and click on Send. You should see that message on WICED device CYW943907AEVAL1F.

 

 

 

Created by SheetalJ_96

Filter Blog

By date:
By tag: