DEV Community

Cover image for Building a Practical IoT Solution with Azure IoT Hub: From Device Setup to Telemetry Data Storage
Oluwatobiloba Akinbobola
Oluwatobiloba Akinbobola

Posted on

Building a Practical IoT Solution with Azure IoT Hub: From Device Setup to Telemetry Data Storage

Introduction

In an era where connectivity is the heartbeat of modern innovation, the Internet of Things (IoT) stands at the forefront, linking billions of physical devices and enabling seamless data exchange. Azure IoT Hub is pivotal in this ecosystem as a managed cloud service that provides reliable and secure communication between IoT applications and devices. With over ten billion devices already connected worldwide and multiplying, Azure IoT Hub simplifies scaling to manage vast networks efficiently. This service is the foundation for numerous applications, from smart homes to industrial automation and healthcare, helping businesses enhance productivity, drive data-driven decision-making, and open up new revenue streams.

Architectural diagram

Image description

Step 1: Set Up an Azure IoT Hub

  1. Create an Azure IoT Hub Instance:

    • Sign in to your Azure portal. Azure portal
    • In the left sidebar, click on Create a resource > Internet of Things > IoT Hub. IoT Hub
    • Fill out the basic details:
      • Subscription: Choose your subscription.
      • Resource Group: Create a new resource group or select an existing one.
      • Region: Select the region closest to you or your data center.
      • IoT Hub Name: Provide a unique name for your IoT Hub.
      • Pricing and Scale: Choose the Free tier or any suitable tier based on your needs. Basics
    • Click Review + Create and then Create. Review + Create
  2. Access Your IoT Hub Connection String:
    Go to resources

    • Once the IoT Hub is deployed, go to the Overview section and copy the Connection string from the Access keys tab. You’ll need this later to connect the simulated device. Connection string

Step 2: Register a Device

  1. Navigate to the Device Management Section:
    • In your IoT Hub instance, click on IoT devices under Device Management.
  2. Add a New Device: New Device
    • Click + New to add a new device.
    • Provide a Device ID (e.g., my-iot-device).
    • Set the Authentication type to Symmetric key (this is the default option).
    • Click Save to register the device. Device ID
  3. Copy the Device Connection String:
    • After registering the device, select it and go to Device details. Device details
    • Copy the Primary connection string as you will use it to simulate the device. Primary connection string
    • Access Raspberri Pi online simulator, consisting of the Assembly Area, Coding Area and the Integrated console window via the link
https://azure-samples.github.io/raspberry-pi-web-simulator/#GetStarted
Enter fullscreen mode Exit fullscreen mode
  • Edit line number 15 of the coding area by replacing [Your IoT hub device connection string]with the Primary connection string Primary connection
  • Select run
  • On the existing Azure IoT hub space created, send a message to Raspberri Pi by selecting Message to device Message to device
  • Type the message in the Message Body box, then Click Send Message
  • Stop the Raspberri Pi Integrated console window to view the message sent. Message Raspberri Pi

Create IoT Hub, connect Android IoT Plug and send File data

Step 1: Download IOT Plug and Play App

https://apkpure.com/iot-plug-and-play/com.iot_pnp
Enter fullscreen mode Exit fullscreen mode
  • Install the IoT App> Scan OR code > Connect via IoT device connection string> Upload a file Connect IoT Upload image Telemetry

Step 2: Create an Azure Blob Storage Account

  1. Add Message routing
    • In Hub settings icon, select Message routing then click +Add Message routing
    • Fill out Endpoint details. In the Azure storage container, Pick a container Pick a container
  2. Set Up Blob Storage (if not available):

    • Navigate to Create a resource > Storage > Storage account. Storage account
    • Complete the form with:
      • Subscription: Your subscription.
      • Resource Group: Choose the existing resource group or create a new one.
      • Storage account name: Provide a unique name.
      • Region: Match it with your IoT Hub region.
      • Performance and Redundancy: Choose the desired options (e.g., Standard and Locally redundant storage (LRS)). Locally redundant storage (LRS)
    • Click Review + Create and then Create.
  3. Create a Container:
    Container

    • Go to your newly created storage account. Click Containers under Data storage. Data storage
    • Click + Container, name it (e.g., myiotcontainer1), and set the access level to Private. + Container File Upload
  4. Upload a file (from step 1 Android App)

    • Go to your Azure IoT Hub> Container Container check
    • IoT Hub iotdevice

Under Device-to-cloud messages, you can check if the telemetry data is being received.

  • Verify that JSON files are appearing as the device sends telemetry data. Blob Image Image Blob uploaded

Conclusion

Building an IoT solution with Azure IoT Hub shows how technology can enable real-time data transfer and transform industries. By connecting millions of devices securely, it supports smarter, safer, and more connected environments. With this foundation, you can explore other Azure capabilities like IoT Central, IoT Edge, and Digital Twins to expand your IoT ecosystem. Embracing IoT with Azure means leading in innovation and operational excellence.

Top comments (0)