DEV Community

Cover image for Create a IoT solution using Azure IoT Hub, and simulating the device to send telemetry data or files to Azure Blob Storage.
Seyi Lufadeju
Seyi Lufadeju

Posted on

Create a IoT solution using Azure IoT Hub, and simulating the device to send telemetry data or files to Azure Blob Storage.

Introduction

The Internet of Things (IoT) integrates physical devices, software, and connectivity to enable devices to send and receive data. Azure IoT Hub serves as a central communication hub for bi-directional communication between IoT devices and the Azure cloud. This guide will walk you through building a practical IoT solution where a simulated device sends telemetry data to Azure IoT Hub. The data is then routed to Azure Blob Storage for further processing or archival.

Step-by-Step Guide

Step 1: Set Up Azure IoT Hub

  • Log in to Azure Portal:

  • Navigate to Azure Portal.

  • Sign in with your Azure account.

  • Create an IoT Hub:

  • In the Azure Portal, search for "IoT Hub" in the search bar and select IoT Hub.

Image description

  • Click + Create.

Image description

Fill out the details:

  • Subscription: Select your Azure subscription.
  • Resource Group: Create a new resource group or use an existing one.
  • Region: Select the desired Azure region.
  • IoT Hub Name: Provide a unique name for your IoT Hub.
  • Click Review + Create and then Create.

Image description

Navigate to Your IoT Hub:

Once deployment is complete, go to your IoT Hub's dashboard.

Image description

Step 2: Register a Device

  • Add a Device in IoT Hub:

  • In the IoT Hub dashboard, go to Devices in the left-hand menu and click + New Device.

Image description

  • Provide a device ID (e.g., mySimulatedDevice).
  • For authentication type, select Symmetric key (default).
  • Click Save.

Image description

  • Copy Device Connection String:

  • Click on the newly created device to view its details.

  • Copy the Primary Connection String. This will be used in the device simulator.

Image description

Step 3: Simulate an IoT Device

  • Set Up Your Environment:
  • Install IOT Plug & PLay if you don’t already have it.
  • Create a new directory for your project.

  • connect using a manual connection

  • use Primary connection string to connect to the device

  • click connect

Image description

Image description

Step 5: Configure IoT Hub Routing to Blob Storage

  • Set Up a Blob Storage Endpoint:

Go to the IoT Hub dashboard and select Endpoints under Message routing.
Click + Add and select Storage container.

Image description

Provide the following:
Name: A unique name for the endpoint (e.g., BlobEndpoint).
Container: Select the container you created.
Click Create.

Image description
Add a Message Route:

  • Under Message routing, click + Add.
  • Fill out the details:
  • Name: A name for the route (e.g., ToBlobStorage).
  • Endpoint: Select the blob storage endpoint.
  • Data source: Select Device Telemetry Messages.
  • Click Save.

Image description

Step 6: connect your container for file upload

  • Under the Hub setting blade
  • Select file upload
  • Click on Select Azure Storage Container
  • Save

Image description

Image description

Upload any file from your connected IOT plug and play app and it should be uploaded successfully on your blob storage account

Image description

Conclusion
By following this guide, you have created an IoT solution where a simulated device sends telemetry data to Azure IoT Hub, which routes the data to Azure Blob Storage. This setup demonstrates the foundational steps of an IoT architecture and can be expanded with features like analytics, alerting, or integration with other Azure services.

Top comments (0)