DEV Community

Cover image for Stream Data using an Azure IoT Hub
Princesse Lawrie
Princesse Lawrie

Posted on

Stream Data using an Azure IoT Hub

Suppose you just bought a new car for your Uber business and will like to pick up signals from your new Uber car around the city to ensure it is not driven outside a predetermined zone, Azure IoT hub will be a great tool to this for you.

But first, what is an Azure IoT hub?

An IoT (Internet Of Things) is a network of physical devices that connect to and exchange data with other devices and services over the Internet or other network. Azure IoT Hub is a managed service hosted in the cloud that acts as a central message hub for communication between an IoT application and its attached devices. You can connect millions of devices and their backend solutions reliably and securely. Just to note here too that almost any device can be connected to an IoT hub.

In today's exercise we will be configuring an Azure IoT hub to authenticate a connection to an IoT device using Raspberry Pi simulator found online.

Step 1: Create an IoT Hub

Log in to Once signed in, type iot hub in the search bar and open


Next click on Create


Create a name for resource group and IoT hub name which should be globally unique, also for the rest of the instance details do not change the default settings.


Once done, click on Review + create. Then click Create.



Azure IoT Hub has been deployed successfully!


Step 2: Adding IoT device

Once the deployment is complete, click Go to resource. Then click Devices to enable us add an IoT device.


Next click on Add Device, add the name of the device in the Device ID - let's call it lawrieiot, any name works provided it is globally unique


Once that is filled click Save


Great! the IoT device is set up successfully


Step 3:Testing the device using a Raspberry Pi Simulator

Next we will click on the new device lawrieiot, locate the primary connection string and copy all the code or just click the copy to clipboard icon circled below


Open a new tab in your web browser and paste this link Next locate the placeholder in line 15 and replace it with the primary connection string copied earlier.


Select Run in the integrated console window to run the application.

You should see the following outcome that shows the sensor data and messages are sent to your IoT hub


The diode will be blinking and messages sent to the IoT hub


To access the messages, go back to IoT Hub Overview page, scroll down to Show data for last: and switch to 1 Hour. Refresh from time to time to have the most recent number of messages received


Good news! We just set up an Azure IoT Hub to collect sensor data from an IoT device.

NB: Ensure to remove the resource group to avoid additional costs.

Thanks for reading!!!

Top comments (0)