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:
Log in to https://portal.azure.com/
Click on + Create a resource and search for IoT Hub.
Click Create and fill in the necessary information:
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.
Step 2: Register a Device in the IoT Hub
Navigate to Your IoT Hub:
In the Azure Portal, go to your newly created IoT Hub.
Add a Device:
Under Explorers, select IoT devices.
Click on + New.
Enter the device ID of your choice (e.g. Abidemi-smartphone).
Click Save.
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.
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.
After editing, click on run.
Then click on Message to device:
Type any message in the message box and click on send message as seen below:
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
Click on connect manually
In the IoT Hub device connection string, enter the your primary connection string key.
Click on connect.
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:
Enter endpoint type, pick storage.
Fill in Endpoint name of your choice.
Click on pick a container.
We have to create a new storage and container because we don’t have anyone created before now.
Enter storage name and other basics:
Click on the storage you just created to create a container.
Click +container, enter the container name and click.
We are back to creating our endpoint route, click encoding with JSON
Click create + next.
STAGE 4: Step 1: create a route.
Enter the route name and data source as seen below:
Click on test route.
Create +add enrichments.
Step 2: Create enrichment.
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.
On your device, click on image upload, then click on select image to upload to Azure storage.
Then select a file to upload.
Step 6: Verify Data in Blob Storage
Check Blob Storage:
After uploading your fine from your device, navigate to your Blob Storage container.
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.