DEV Community

Toluwani Oluwaloseyi
Toluwani Oluwaloseyi

Posted on

HOW TO CREATE AN AZURE IoT HUB AND CONFIGURE THE HUB TO AUTHENTICATE A CONNECTION TO AN IoT DEVICE USING RASPBERRY PI SIMULATOR

Image description

The Azure Internet of Things (IoT) is a collection of Microsoft-managed cloud services, edge components, and SDKs that let you connect, monitor, and control your IoT assets at scale. An IoT solution is made up of IoT devices that communicate with cloud services.

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. Almost any device can be connected to an IoT hub.

Raspberry Pi Simulator can serve as the 'Internet Gateway' for IoT devices. When powered by a Cloud network, it acts as a web server for uploading and transiting sensor data on IoT platforms.

Step 1:

Visit portal.azure.com, login or sign up if you don't have an account, you can get a free account at azure.microsoft.com/en-us/free/

Step 2:

Search for IoT Hub and click on create

Image description

Step 3:

1.Subscription: Choose the subscription where you wish to create the resource.
2.Resource group: Choose the resource group where you wish to create the resource. If you wish to create a new group click on create a new option.
3.IoT Hub name: Enter a preferred unique name.
4.Region: Select the location where you wish to create the account.
Click on "Review and Create"

Image description

Step 4:

Click on "create"

Image description

Step 5:

Your IoT Hub has been created, so click on "Go to Resource"

Image description

Step 6:

To connect an IoT Device, Click on "Devices", then "add device"

Image description

Image description

Step 7:

Choose a device ID name(I used my name). Every other thing should be left on default, then click on save.
Your IoT Device has been created.

Image description

Image description

Step 8:

To Connect your IoT device to a Raspberry Pi Simulator, open a new tab and search for Raspberry Pi Azure IoT Online Simulator. After opening it, you'll notice that there's no blinking on the red stuff and that's because it is switched off but after we work with, it'll be switched on and begin to blink.

Image description

Step 9:

Go back to Azure Portal, Click on the IoT Device that was added.
1.Go to 'primary connection string'.
2.Click on it to show then copy to clipbord

Image description

Image description

Step 10:

Go back to the Raspberry Pi Simulator, look at line number 15 - remove the place holder Your IoT hub device connection string without touching the apostrophes

Image description

Step 11:

Paste in between the apostrophes, what was copied from the 'primary connection string in step 9.

Image description

Step 12:

Click on run, you'll also notice that the red button is now switched on and blinking and the Raspberry Pi is now sending messages to the IoT device and Hub.

Image description

Image description

Please note: To be sure that the device has been connected, go back to the azure portal and click on the IoT hub you created, then click on "overview", you'll be able to monitor the IoT hub usage and the number of messages coming in.

Image description

Thanks for reading...

Top comments (0)