Temperature Gauge

In this project, we will program the STM32 to act as a basic temperature gauge. We will use Embedded C to program the STM32 using HAL libraries to interface it with an SHT2X Temperature and Humidity sensor. This project will use the Platform IO Core (CLI) to compile the C code for our STM32 and manage all the dependencies.
Let's start with creating a new STM32 instance on Simuli Virtual Lab.
First, log in to your Simuli account and navigate to the Simuli Virtual Lab. Here we will create a new emulated instance of the STM32. Click on the Launch button under STM32 to get started.
This will open the configuration menu. First, provide a name for the project. Then, we will add the SHT2X Temperature and Humidity Sensor by selecting them from the list of available components. Finally, review that the name for the project and the selected sensors are correct and click on the Launch button.
Once we have clicked on the Launch button, a new instance of the STM32 will be created. It can take a few minutes, so be patient. Once the new instance is ready, an Open button will be visible. Click on this button to open and start working with our STM32.
A new tab with the development environment opens upon clicking Open. On the left side, we have the code editor window along with the terminal at the bottom. On the right side, we have our STM32 Nucleo board with a terminal for interacting with the board and the SHT2X sensor.
The code for the project has been made available via GitHub. To get the code, we just need to clone the repository into our instance. Before cloning, change the terminal directory to /workspace Type the following commands in the terminal:
cd /workspace
git clone
All the required project files will now be cloned to a local folder with the same name. We first need to go into that folder and we will be ready to compile our code. Type the following command in the terminal.
cd /workspace/STM32-temp-gauge/
The main project files along with the drivers available in the src folder. To view any of these files just click on it to open it in our IDE.
We will now use Platform IO to compile our project. Type the following command in the terminal.
pio run
The first time this command is run, Platform IO will download and install the relevant framework and toolchains required for the STM32. This process will take a few seconds.
Now Platform IO will compile our code and output a firmware.bin file. We need to copy this firmware file from the .pio/build/nucleo_f411re to /workspace. Usually you would need to use the cp command, but we have created a custom command called load-firmware for ease of use. Just write the following command and the firmware.bin file will be copied to the workspace folder.
Once we have copied the firmware.bin file, all we need to do is to reset the STM32 by pressing the red button above the STM32.
We now have a basic temperature gauge with 5 LEDs with each corresponding to a change of 10°C in temperature.