The Internet of Things (IoT) is revolutionizing how we interact with the physical world. From monitoring environmental conditions to optimizing industrial processes, connected devices are generating a wealth of data with immense potential. But how do you bridge the gap between these physical devices and the digital realm for analysis and action?
This blog post guides you through building a practical IoT solution using Microsoft Azure's powerful services: Azure IoT Hub and Azure Blob Storage. We'll walk you through the steps involved in setting up an IoT Hub, registering a device, and simulating the device to send telemetry data to Blob Storage for further analysis.
Prerequisites:
- An Azure subscription (you can get a free trial at [https://azure.microsoft.com/en-in/free ]
- Basic understanding of IoT concepts and Azure services
Step 1: Step up an Azure IoT Hub
- Create an Azure resource group
Log in to the Azure portal and search for "Resource group."
Provide a name for your resource group
Choose a Region.
Click "Review + Create"
Then 'Create'
Step 2: Create an Azure IoT Hub
In the search box, type IoT Hub and select it from the list.
Select your subscription
Use the newly created Resource group
Enter a unique name for your IoT hub
Choose a free or pay-as-you-go pricing tier based on your needs.
Click on Review and Create
Review the configuration and click on 'Create'.
Step 3: Register a device in IoT Hub
Navigate to your newly created IoT Hub in the Azure Portal.
On your left side options, click on devices
Select '+Add' to register a new device
Step 4: Configure the Device
Device ID: Enter a unique device ID.
Authentication Type: Select Symmetric key.
Auto-generate keys: Ensure this option is checked
Connect this device to IoT hub: Enabled
Save the Device : Click'Save'
Get the Device Connection String: Click on the device to view its connection string. Copy the primary connection string as you will need it for the simulated device.
Step 5:Simulate Device Telemetry:
Here's where the fun begins! We will be using IoT plug and Play app
Launch the "IoT Plug and Play" app on your Android/ios device.
You'll have two connection options:
Scan QR Code: If you enabled QR code generation during Plug and Play setup in Azure, use your device's camera to scan the displayed code
IoT Hub device connection string: If you prefer a manual approach, you click on connect 'manually'.
How would u like to connect? Click IoT hub device string
Connection info: On the IoT hub device connection string, paste the primary connection string earlier copied
Click 'Connect'
- Congratulations! Your Android/ios device is now connected to your Azure IoT Hub using the IoT Plug and Play model. This paves the way for exciting possibilities! You can develop custom Android/ios applications that leverage the device's sensors and capabilities to interact with the cloud.
Step 6: Set Up Azure Blob Storage
- Create a Storage Account: In the Azure portal, type storage accounts on the search and click on storage accounts on d drop down menu
2. Configure the Storage:
Click on '+Create'
Resource Group: Use the same resource group as your IoT Hub.
Storage Account Name: Enter a unique name in small letters.
Region: Choose the same region as your IoT Hub
Leave other default settings except otherwise
3. Review and Create: Click on 'Review + Create'
4. Create: Review the configuration and Click 'Create'
5. Create a Container:
After the storage account is created, navigate to it.
On the left side menu after Data storage, select Containers and create a new container.
Click on +container
Step 7: Route Telemetry Data to Blob Storage
- Set up a route in the IoT hub: On the left side of the menu, click on message routing and click on '+Add'
2. Create Storage Endpoint:
Name: Enter a name for the endpoint.
On the Endpoint type drop menu, choose 'storage'
Container: Select the container you created.
Encoding: You can leave the default setting or choose JSON
Leave default setting and click next
3. Configure the route:
Name: Enter a name for the route.
Source: Select Device Telemetry Messages.
4. Save the Route: After configuring the endpoint, save the route.
Conclusion
You have now successfully set up an IoT solution using Azure IoT Hub, registered a device, simulated telemetry data, and routed that data to Azure Blob Storage. This setup can be expanded and customized based on your specific IoT solution requirements.
Top comments (0)