A Beginners Guide on How to connect a Raspberry Pi Simulator to a Device on IoT Hub
Tags: iot, iothub, raspberrypisimulator, azureiothub
Published: 2023-04-28 15:09:20

**Internet of Things**
IoT, Internet of Things, is the ability of connected devices to communicate with each other.
Azure IoT Hub is a bidirectional messaging centre that is hosted in the cloud where messages from an IoT application and its attached IoT devices are collected over the internet. The internet can be used to connect any device that can be compatible with the required sensor and software.

Lets move on to our task of the day!

**STEPS**
(1) Log in to your Azure Portal with your azure account


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

(2) Type IoT Hub in the Search box and click on the IoT hub displayed

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


(3) Click on Create

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


(4) Complete the following details as outlined:
**Project Details**
**Subscription:** Azure Pass Subscription(as the case may be)
**Resource Group:** Create a resource group .I will name it AprilWorkload 

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

**Instance Details:**I will use YemmyIoT
**Region:** Select the Region where you want the IoT Hub to reside. Here, I will select East US

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


**Leave the **Tier and Daily Message Limit** at default
I.e **Tier:** Standard
    **Daily Message Limit:**400,000

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


(5) Click on Review and Create
  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mfssuyo5pfptl4p2rvkz.png)


(6) Click on Create and wait for it to be fully deployed
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4az0f905chzviaguazmj.png)

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



(7) Go To Resource

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


At this point note the followings:
IoT Hub Usage:
Message Used Today:0
IoT Device:0
These indicates that no message has been sent and no device has been connected

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


(8) On the IoT Hub created, click on Devices and then click Add Device

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

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



Under the Device ID, create a name for the device.I will name it Abby
Leave other parameters at default and click on Save

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


(9) Click on IoT device **Abby** just added to the IoT Hub

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


(10) Go to the Primary Connection String, click on the eye symbol to view the Connection String and then copy the String

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


(11) At this point we will need to connect a Raspberry Pi Simulator. Go to your web browser and search for it.
Select "Raspberry Pi Azure IoT Web Simulator". 

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


A Raspberry Pi  Simulator enables you to test out your projects without the the use of a physical Raspberry Pi. This is because the Raspberry Pi and other electronic components in your project are digitally emulated.It is economical while it also saves time and effort.

(12) Go to the Raspberry Pi Simulator opened on your browser, and replace the placeholder in **Line 15** with the Primary Connection String you copied in Step 10 above

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

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

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




(13) Click on Run so that the Raspberry Pi Simulator start sending messages to the IoT Hub

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


The Red light of the Simulator will start blinking indicating that messages is being sent to the Azure IoT Hub

(14) For confirmation of the messages sent as evidence that the Raspberry Pi has been connected to the Azure IoT Hub, go back to the Overview page on the IoT Hub, check the IoT Hub Usage

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


    Message Used Today: 239
     IoT Device: 1
Ohla! Messages has been sent. The Raspberry Pi Simulator has been connected to the Azure IoT Hub