Implementing Azure IoT Project

Once the project has been configured, Go to Simuli Virtual Lab and start the Raspberry Pi instance we just created. Click on the Open button Under the instance name. A new tab with the built-in development environment opens up. On the left side, we have the code editor window along with the terminal at the bottom. On the right side, we have our Raspberry pi with the sensors below it.

Now go to the terminal and type the following commands to install pip, which is the python package manager.

sudo apt update
sudo apt-get install python-pip

Once that is done we will use pip to install the azure-iot-device package, which is needed for our program to communicate with the azure device created in the portal. Type the following command to install the package.

pip install azure-iot-device

The code for the project has been made available via GitHub. To get the code, we need to clone the repository into our instance. Type the following command in the terminal:

git clone

All the required project files will now be cloned to a local folder with the same name. Let's change the working directory of the terminal to that folder.

cd RaspberryPi-Azure

Open the file in the IDE by clicking on it in the File Explorer pane. Here we need to configure the CONNECTION_STRING. Copy the primary connection string from your device and replace <Primary Connection String> with it.

CONNECTION_STRING = "<Primary Connection String>" 

Now we are ready to run our program. Type the following command in the terminal.


The real-time temperature and humidity readings will now be recorded and sent to Azure IoT Hub.

Last updated