RTOS-Based Interfacing of IR(Infrared) and DHT(Digital Humidity and Temperature) Sensors With STM32F446RE Nucleo-board

by marushikasuri in Circuits > Electronics

392 Views, 2 Favorites, 0 Comments

RTOS-Based Interfacing of IR(Infrared) and DHT(Digital Humidity and Temperature) Sensors With STM32F446RE Nucleo-board

MARU.png

In the realm of embedded systems, the integration of sensors plays a pivotal role in enabling smart and responsive functionalities. The proposed solution embarks on the development of an integrated system harnessing the power of the STM32 Nucleo-F446RE development board. This system seamlessly amalgamates an infrared (IR) sensor and a DHT11 temperature and humidity sensor, forming a comprehensive monitoring platform.

The core objective of this endeavor is to orchestrate a meticulously crafted firmware, designed to orchestrate efficient data acquisition, processing, and interfacing between the sensors and the STM32 microcontroller. A pivotal component facilitating this orchestration is the utilization of a Real-Time Operating System (RTOS), which acts as the backbone for task management, ensuring smooth and concurrent execution of critical operations.

Supplies

  1. STM32F446RE Nucleo-Board
  2. IR(Infrared) Sensor
  3. DHT(Digital Humidity and Temperature)Sensor
  4. LED
  5. Connecting Wires

Download STM32CubeIDE

1.png

The initial step involves downloading of the desired software-STM32CUBEIDE for the execution.

Download link: https://www.st.com/en/development-tools/stm32cubeide.html


Create STM32 Project

  1. Open the STM32CubeIDE.
  2. Launch the IDE(Integrated Development Environment).
  3. Go to File>New STM32 Project.
  4. STM32 Target Selection box will appear.
  5. Under Board selector, select the desired Nucelo-board(STM32F446RE).
  6. Select Next.
  7. Give a name to your STM32 Project. Keep the other settings as default. Select Finish.

Setting Up STM32CubIDE Project

Screenshot 2024-05-05 011905.png

A similar prompt will appear.

A .ioc format file will be created with the name of the project and will be displayed on the screen.

Under this, we will configure the entire project.


Pinout & Configuration

Screenshot 2024-05-05 012915.png

Under Pinout & Configuration:

  1. Go to System Core>SYS. Under MODE>Timebase Source> TIM1.
  2. Go to Timers> Select TIM6.
  3. Under Connectivity> USB_OTG_FS. Under Mode>Device Only.

Creating Tasks

Screenshot 2024-05-05 014236.png
  1. Under Pinout & Configuration> Middleware and Software Packs> FREERTOS.
  2. Select Mode>CMSIS_V1(CMSIS is the library for free RTOS).
  3. Under Configuration>Tasks and Queues> Create Tasks and assign priorities to each task.
  4. Here we have 3 tasks: one is the default task, Task02 and Task 03.
  5. Add 2 tasks and assign high priority to task02(IR Sensor) and lower priority to Task03(DHT Sensor).
  6. Go to Clock Configuration>Resolve clock issues.

Go to Pinout View

Screenshot 2024-05-05 015307.png
  1. Select GPIO_INPUT for Pin PA0(Connected to IR Sensor).
  2. GPIO_INPUT for Pin PA1(DHT Sensor).
  3. GPIO_OUTPUT for Pin PB5(Connected to LED).

Code Generation

Go to Device Configuration Tool Code Generation and generate the code. A main.c file will be generated. Keep all parameters as default.

Add commands in the code as per your requirement.

Further steps:

  1. Build the project(Ctrl+B).
  2. Check for errors and warnings.
  3. Setup the hardware.
  4. Connect it with your IDE using Male to MINI-B Cable.
  5. Run the project.
  6. Check the output on Teraterm serial monitor.


You just learnt how to interface IR and DHT Sensor using STM32F446RE Nucleo board on STM32CubeIDE using FREERTOS.


Keep learning! Keep creating! Keep innovating!