Setting up Azure IoT Hub for your Meadow projects
You can finally configure your Meadow projects with Azure using IoT Hub! This guide will guide you step by step of what you need to do generate a sas access token that you’ll add on your project to communicate with azure to send and receive data.
Step 1: Create a Resource Group
In your Azure portal, you’ll first need to create a Resource Group if you dont have one, click the Create a resource button and look for a Resource Group to open the creation page.
We’re naming it meadow-resource-group as an example, and selecting (US) West US for the region, but you can choose any name and region you want.
Step 2: Create an IoT Hub
Go into your new Resource Group, and click the Create button and look for IoT Hub
In the IoT Hub creation page, we named it meadow-iot-hub, we chose the same region and the Free tier for testing purposes. Click Review + create.
Step 3: Add a Device
Now go to your newly create IoT Hub and on the left side menu, go to Devices and add a new device.
In this example we named a device meadow-device
You can leave all other values as is and click the Save button.
Step 4: Create a SAS Token
Back in your IoT Hub, look for the Shared access policies section on the left side menu under Security Settings, and in there click on the iothubowner item to open a detail page and copy the Primary connection string somewhere, you will need it to create a SAS token.
Now open a Azure terminal, and you’ll need to enter the following command to create a sas token:
az iot hub generate-sas-token --hub-name meadow-iot-hub --device-id meadow-device --resource-group meadow-resource-group --login '[paste primary connection string here]'
Once its done, it will return you a string you’ll need to copy and use it on your Meadow project:
john [ ~ ]$ az iot hub generate-sas-token --hub-name meadow-iot-hub --device-id meadow-device --resource-group meadow-resource-group --login 'HostName=meadow-iot-hub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=........'
{
"sas": "SharedAccessSignature sr=..."
}
That’s all for this guide! Be sure to copy over your sas token and paste it on your Meadow projects to integrate it with Azure IoT Hub.