A step-by-step guide to create a practical IoT solution using Azure IoT Hub with the IoT Plug and Play App.
Step 1: Create an Azure IoT Hub
Log into Azure Portal: Go to Azure Portal.
Search for IoT Hub: In the search bar, type IoT Hub and select it.
Create a new IoT Hub:
Click on Create.
Choose the Subscription and Resource Group.
Enter a unique IoT Hub Name.
Select the Region closest to your location.
Choose a Pricing Tier (start with the free tier if available).
Review and click Create.
Step 2: Register an IoT Device
Navigate to IoT Hub: Once the hub is deployed, go to your IoT Hub.
Add a Device:
In the left-hand menu, select IoT Devices under Explorers.
Click New.
Provide a Device ID (e.g., MySimulatedDevice).
Leave other settings as default and click Save.
Copy the Connection String:
After the device is registered, click on it to view details.
Copy the Primary Connection String for later use.
Step 3: Simulate a Device Using the Raspberry Pi Web Simulator
Before diving into creating a simulated IoT device with the IoT Plug and Play App, you can use the Raspberry Pi Web Simulator to visualize and understand how IoT devices send data to Azure IoT Hub.
Access the Simulator:
Open the Raspberry Pi Web Simulator in your browser.
Configure the Simulator:
Copy the Primary Connection String of the IoT device created in Step 2.
Paste the connection string into the const connectionString
variable in the simulator’s code section.
Run the Simulation:
Click Run to start the simulation.
Observe the simulated telemetry data (e.g., temperature and humidity readings) being sent to your IoT Hub.
Monitor the Data:
on the same page where you created a new device there is supposed to be a send message to verify that the messages are being received at the end of the raspberry.
Step 4: Simulate the IoT Device
Install IoT Plug and Play App:
Download and install the IoT Plug and Play App.
Connect the App to IoT Hub:
click on scan QR code
click on manual connect
select IoT Hub device connection string
Open the app and enter the Primary Connection String from Step 2.
Click Connect.
Simulate Telemetry:
Define telemetry messages (e.g., temperature, humidity).
Set the message interval and click Start to simulate the data.
Step 5: Set Up Azure Blob Storage
Create a Storage Account:
In Azure Portal, search for Storage Accounts.
Click Create, provide the required details, and click Review + Create.
Create a Blob Container:
Go to your Storage Account.
Select Containers and click + Container.
Name the container (e.g., iotdata) and set the Public Access Level to Private.
Step 6: Route Telemetry Data to Blob Storage
Set Up a Message Route:
Go to your IoT Hub.
Navigate to Message Routing under Messaging.
Click + Add to create a new route:
Name the route (e.g., ToBlobStorage).
Set Data Source to Device Telemetry Messages.
Under Endpoint, choose + Add > Storage.
Connect to Blob Storage:
Select the storage account and the blob container created earlier.
Save and activate the route.
Fo you to upload from your phone successfully you will need to configure file upload in your IoT solution before using it
Step 7: Monitor the Data Flow
Send Data:
Start the simulated device in the IoT Plug and Play App.
Monitor messages being sent to IoT Hub.
Check Blob Storage:
Navigate to your blob container in the Azure Portal.
Verify that telemetry data files are being stored as AVRO or other specified formats.
Conclusion
This project demonstrates the power of Azure IoT Hub as a comprehensive platform for building and managing IoT solutions. By setting up an IoT Hub, simulating devices, sending telemetry data, and uploading files to Azure Blob Storage, we’ve covered critical aspects of IoT workflows. The inclusion of the Raspberry Pi web simulator makes this project accessible to beginners while maintaining relevance for professionals looking to understand cloud-connected IoT systems.