CREATE IoT HUB TO CONNECT TO AN IOT DEVICE USING RASPBERRY PI SIMULATOR
Tags: devops, beginners, azure, cloudcomputing
Published: 2023-09-20 11:00:50

STEP 1: In the smart search box, type IOT HUB and click on the grayed area which is highlighted.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ii0lwgjccqc7p2ys51v.png)

STEP 2: click on create and you will be directed to a new tab

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gu6sx9wr1pr8q7txs0r0.png)

STEP 3: Fill the descriptions in the tab.

* Resource group: If you don't have one you can create a new one but if you do have one, just select your resource group in the resource group tab.

* IoT hub name: Give your IoT hub a name that is okay with you.

* Region: Select a region that you want. remember to put cost in place when doing this.

then click on review + create. You wait for it to deploy

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sg5le06iv1x7v5dqc6u8.png)

STEP 4: Open google and search for https://azure-samples.github.io/ A raspberry pi Azure simulator will open for you.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pgyefqkkh8kq8gouq5ag.png)

STEP 5: After it's done deploying, click on go to resource


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mmta79z8mo9xo73bcoln.png)

STEP 6: Click on device


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mh9qa2oife6ghzcohc0j.png)

STEP 7: For you to create a new device, click on add device 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/btd9coy6xl4izwmym0rh.png)

STEP 8: Just give a name to your device ID and leave the rest on default and click on save.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/akbuys8k68wtopwxjeha.png)

STEP 9: Check the box and click on your device name


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ae27zk2w9ci2o15lajgu.png)

STEP 10: scroll down to Primary connection string and copy the key. 

The primary connection string is a string of characters or text used to establish a connection to a database or other networked service. It contains information that allows a client application or program to connect to the service.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f6rqcotu0r12mr6tt9g6.png)

Step 11: Go to your raspberry pi simulator page, on line 15, clear what you see inside the quotes and just leave the quotes sign. then paste your primary connection string inside the quotes.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w0tzm28au8nksfmuxxi0.png)

STEP 12: Click run. when you do, you wil notice the simulator blinking, it means it has started working and sending messages.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/abqdi1129cwo8cogs2y6.png)

To check if it is sending messages, go back to your Azure tab and click on devices.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ii885aj63r83gxyoh7b.png)

Click on overview


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i4xtxk9pvhdopty71rl3.png)

Scroll down and check IoT Hub usage box and look at the messages used today, you will notice it keeps increasing.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k1kecujdlee3mclii94b.png)

You are welcome!