DEV Community

Cover image for Creating an IoT solution using Azure Hub, registering a device, and simulating the device to Azure Blob storage
Akinsooto Abidemi
Akinsooto Abidemi

Posted on

Creating an IoT solution using Azure Hub, registering a device, and simulating the device to Azure Blob storage

Creating a practical IoT solution using Azure IoT Hub involves several steps: setting up an IoT Hub, registering a device, and simulating the device to send telemetry data or files to Azure Blob Storage. Below is a step-by-step guide:

STAGE 1: **Step 1: Set Up an Azure IoT Hub
Create an Azure Account:**

If you don't have an Azure account, sign up at Azure Free Account.
Create an IoT Hub:

Image description

  • Click Create and fill in the necessary information:

Image description

Subscription: Select your Azure subscription.
Resource Group: Create a new resource group or select an existing one.
Region: Choose the region closest to you.
IoT Hub Name: Provide a unique name for your IoT Hub.
Click Review + create and then Create.

Image description

Step 2: Register a Device in the IoT Hub
Navigate to Your IoT Hub:

Image description

In the Azure Portal, go to your newly created IoT Hub.
Add a Device:
Under Explorers, select IoT devices.
Click on + New.

Image description

Enter the device ID of your choice (e.g. Abidemi-smartphone).
Click Save.

Image description

Step 3: Simulate a Device to Send Telemetry Data:
We will be using the raspberry-pi-web-simulator.
Here is the link: https://azure-samples.github.io/raspberry-pi-web-simulator/#GetStarted

On a browser, copy and paste the link on your browser.

Image description

Go to line 15 and edit the connection string using the primary connection string. Copy the primary connection string from the device created and paste it there.

Image description

After editing, click on run.

Image description

Then click on Message to device:

Image description

Type any message in the message box and click on send message as seen below:

Image description

STAGE 2: Download IoT Plug and Play application on your smart phone form your app store:

  • After downloading and installing, open the app
  • Click on Scan QR code

Image description

  • Click on connect manually
  • In the IoT Hub device connection string, enter the your primary connection string key.
  • Click on connect.

Image description

STAGE 3:
Create an endpoint:
In your IoT Hub, go to Endpoints under Message routing.
Click on messaging route, click on add
Fill in the necessary details:

Image description

  • Enter endpoint type, pick storage.
  • Fill in Endpoint name of your choice.
  • Click on pick a container.

Image description

We have to create a new storage and container because we don't have anyone created before now.

Image description

Enter storage name and other basics:

Image description

Click on the storage you just created to create a container.

Image description
Click +container, enter the container name and click.

Image description
Click on select.

Image description
We are back to creating our endpoint route, click encoding with JSON
Click create + next.

Image description

STAGE 4: Step 1: create a route.
Enter the route name and data source as seen below:

Image description

  • Click on test route.
  • Create +add enrichments.

Image description

Step 2: Create enrichment.

Image description

Image description

STAGE 5: Open your storage account in a new tab.
Then back to your IoThub, click on file upload to upload file from your device.

Image description

On your device, click on image upload, then click on select image to upload to Azure storage.
Then select a file to upload.

Image description

Step 6: Verify Data in Blob Storage
Check Blob Storage:
After uploading your fine from your device, navigate to your Blob Storage container.

Image description

You should see files containing the telemetry data sent from your simulated device.

By following these steps, you've successfully created an IoT solution using Azure IoT Hub that sends telemetry data to Azure Blob Storage.

Top comments (0)