cancel
Showing results for 
Search instead for 
Did you mean: 

How to get started with ST infrared sensor STHS34PF80

Denise SANFILIPPO
ST Employee

Summary

In this knowledge article, we show how to get started with the new ST infrared sensor STHS34PF80, considering both the hardware and software tools.

Introduction

 

Ecosystem for ST IR sensorEcosystem for ST IR sensor

 

To get started with the new infrared sensor STHS34PF80, two options are available: Let us deep dive into the two options, which use the evaluation kit STEVAL-MKI231KA.
 

Overview of STEVAL-MKI231KAOverview of STEVAL-MKI231KA

 

1. Evaluation tools

 

STHS34PF80 Evaluation toolsSTHS34PF80 Evaluation tools

 

The evaluation kit is made up of an electronic and a mechanical part.
  • The electronic part includes: the evaluation board, a DIL24 adapter, and a flex cable to connect the evaluation board to the DIL24.
  • The mechanical part consists of an ad hoc plastic holder (with screws and nuts) and a particular lens coming from the Fresnel Factory.
In the first part of the article, we are going to use the electronic part only. The mechanical part comes later.
 
We are starting from connecting the evaluation kit to the professional MEMS tool board STEVAL-MKI109V3, and the board to the PC through a USB cable. On the PC, we need to make sure the latest version of Unico-GUI is installed. If you do not have it installed, you can download it from the ST website (currently, the latest version is 9.16).
 
Launching Unico-GUI, we can select the STEVAL-MKI231KA kit for the infrared sensor.
 

Unico-GUIUnico-GUI

 

In the options tab of Unico you can configure some settings like the output data rate, the number of averages for ambient and object temperature.

 

Options tab of Unico-GUIOptions tab of Unico-GUI

 

You can also enable the T_object compensation, a compensation algorithm based on ambient temperature data, to improve the accuracy of the object temperature data.
This procedure is effective only for compensating the temperature changes that occur in the environment in thermal coupling with the sensor. For example, changes in the temperature of the PCB on which the sensor is mounted.
 
More details on the compensation are available inside section 4.6 of the application note AN5867.
 
The easy configuration button of the Unico-GUI allows you to configure the device with some default settings. The tool starts receiving data from the board by pressing the START button.
In the plots you can see the T_Ambient and T_Object signals and all the derivative signals computed in the device: like T_Presence, T_Motion and T_Ambient_shock.
 

Plots: T_Ambient and T_Object signalsPlots: T_Ambient and T_Object signals

 

All this data is read from the sensor output register on the professional MEMS tool board, which communicates to the PC through USB.
 
Let us now consider a simple demo, in which we can see a person entering the field of view of the infrared sensor.
 

A person entering the field of view of the infrared sensor STHS34PF80A person entering the field of view of the infrared sensor STHS34PF80

 

When the person enters, both the motion and the presence flag rises. However, while the motion flag goes down after the person has stopped moving, the presence flag remains high as long as the person is inside the field of view.
Then, we see the person exiting the field of view of the sensor. First, we can see the motion flag rising again, indicating the user is moving. When the person exits the field of view, the presence flag goes down.
Later, the motion flag goes down, too.

 

A person exits the field of view of IR sensor STHS34PF80.A person exits the field of view of IR sensor STHS34PF80.

 

In this case, we have used just the default settings, but of course you can improve the detection playing with different parameters.
In the Smart digital algorithms tool, you can configure some parameters for the internal algorithms: threshold and hysteresis for presence detection, motion detection, and T_ambient shock detection.
 

Smart Digital Algorithms toolSmart Digital Algorithms tool

 

In the same window also the low-pass filter settings are available, those filters act directly on the three detection algorithms.
Find out more on the embedded presence, motion, and ambient temperature shock detection in the datasheet and the application note documents of the infrared sensor.
These algorithms are embedded in the device, so the current consumption is low.
 
If you want to have higher performance in terms of accuracy of the detection, a software library can be used. 
Before that, let us see another tool available in Unico-GUI for the infrared sensor.
It is the Offline tuning tool, which allows to find an optimal configuration for the different parameters based on some data logs previously acquired.
 

Offline tuning toolOffline tuning tool

 

Presence, motion, and ambient shock detection algorithms have been ported to software models and integrated in this tool for offline analysis and parameters tuning.
The board connection in this case is not mandatory.
 
The user can upload a recorded log for parameter tuning by loading a labeled csv or tab-spaced log file (including a header row with labels).
Once the T_Object ID or/and T_Ambient ID header labels are selected, the START button for log processing is enabled.
By clicking on the START button, the presence, the motion, and the T_Ambient shock detection algorithms are executed, using selected parameters values.
The register configuration (.ucf) file can be saved / loaded using the load / save configuration (.ucf) buttons.
 
Processing results can be exported into a text file by using the "save data (.txt)" button.
If the board is connected, the displayed parameter values on the GUI can be read from the device or stored in it by using the read / write configuration buttons.
 
The advantage of using this tool is to use just one single logging instance of your application use case. By iterating the fine-tuning of the algorithm, you can find the best parameters for your application.

 

2. Development tools

 

Development toolsDevelopment tools

 

Let us talk about the STM32 Open Development Environment, which includes a dedicated library for the infrared sensor. We are going to use the new X-NUCLEO-IKS4A1 expansion board, mounting it on top of a NUCLEO-F401RE board.

In this case, we are not using the DIL24 adapter, as the flat cable can be directly connected to the evaluation board. Then, the X-NUCLEO-IKS4A1 expansion board can be plugged to the Nucleo board (in this case it is the F401RE). Finally, the Nucleo board can be connected to the PC through USB.

 

X-NUCLEO-IKS4A1X-NUCLEO-IKS4A1

 

3. X-CUBE-MEMS1 expansion pack

To use the infrared sensor with the Nucleo board we need a dedicated firmware, which is included in the X-CUBE-MEMS1 expansion pack.

After downloading this package from the ST website, you can navigate to the /Projects/ folder. Here you can find the project for the different Nucleo boards supported. We select /Nucleo F401../


X-CUBE-MEMS1 expansion pack: folder /Nucleo F401../X-CUBE-MEMS1 expansion pack: folder /Nucleo F401../

 

Then /Applications/CUSTOM/PresenceDetection…. Here you can find the source code of the firmware, which you can open by different environments including IAR, Kiel and STM32CubeIDE.

 

X-CUBE-MEMS1: the source code of the firmware is available for different environments including IAR, Kiel and STM32CubeIDEX-CUBE-MEMS1: the source code of the firmware is available for different environments including IAR, Kiel and STM32CubeIDE

 

There is also a folder /Binary/ containing the .bin file of the prebuilt firmware, which can be directly loaded to the Nucleo board.
 

The binary .bin file of the prebuilt firmware is availableThe binary .bin file of the prebuilt firmware is available

 

To use the binary, you can drag and drop the prebuilt .bin file from the “Binary” folder to your Nucleo board folder. You can find more information about the loaded application in the user manual UM3169, which is available on our website.
 

4. Test custom firmware with Unicleo-GUI

 

Unicleo-GUIUnicleo-GUI

 

The application, which we have loaded through the firmware binary in the X-CUBE-MEMS1 expansion pack, shows how to use the presence detection library. The goal is to obtain object presence and motion data, using an infrared sensor only. The data is sent from the Nucleo board using UART to a connected PC.
On the PC we can use the software Unicleo-GUI, which is a graphical user interface for the X-CUBE software expansions and STM32 Nucleo expansion boards.
 
After a connection has been established:
  • The user can view raw ambient and object temperature [LSB] data from the infrared temperature sensor.
  • The user can view compensated object temperature [LSB] and its change rate [LSB] together with Object presence and motion detection flags.
  • The user can store the data in a .csv file.

5. InfraredPD library

Here are some details of the presence detection library integrated in the firmware that we are testing with Unicleo, taken from the user manual UM3169.

 

Block diagram of InfraredPD libraryBlock diagram of InfraredPD library

 

This library performs:

  • A compensation of the ambient temperature changes in the object temperature
  • A motion detection.
  • An advanced presence detection.

To compensate for the ambient temperature variations:

  • The library can replicate the linear algorithm embedded in the device.
  • Or it can run a nonlinear algorithm, which performs a better compensation with fast ambient temperature variations.

The algorithm for motion detection is similar to the one embedded in the device. While the algorithm for presence detection is more robust. It improves presence detection when some drifts in the Tobject signal are observed. Such drifts are usually related to the temperature changes of the environment in the field of view of the sensor only. But it is not related to the temperature changes of the environment in thermal contact with the sensor.
 

6. STM32CubeIDE project available in the X-CUBE-MEMS1 expansion pack

 

STM32CubeIDE project available in the X-CUBE-MEMS1 expansion packSTM32CubeIDE project available in the X-CUBE-MEMS1 expansion pack

 

In the X-CUBE-MEMS1 expansion pack, we have previously downloaded from the ST website, you can find the source code of the firmware, which includes the PresenceDetection library.
You can open the source code with a development environment if you wish to make modifications.
Here we chose to open the project with STM32CubeIDE, which allows to build the source code and flash the firmware on the Nucleo board. Note that the PresenceDetection library is included as a binary in this firmware. However, you can modify the configuration parameters from the firmware source code.

7. Lenses

 

The TMOS63-10 lens is provided for the STHS34PF80 infrared sensorThe TMOS63-10 lens is provided for the STHS34PF80 infrared sensor

 

To improve the performance of the infrared sensor, some specific lens can be used for a specific application.
In the STEVAL-MKI231KA kit, the TMOS63-10 lens is provided for the STHS34PF80 infrared sensor. You can use this or other lens depending on your application. Together with the lens, a holder is also provided in the STEVAL-MKI231KA kit. The purpose of the holder is to maintain the correct distance between lens and sensor. The smooth part of the lens is the part capturing light, so it should mount to be external (The smooth part should face outwards). Finally, it is possible to put some screws on the bottom side, and nuts on the top side.


For further information about hardware implementation, you can check the other documents available on the product STHS34PF80 official webpage. For instance, there is an application note (document AN5983) with some important considerations useful when developing custom hardware or performing integration. A lens like the TMOS63-10 is a spot lens that has a FoV of plus and minus 5 degrees (making a total of 10 degrees). This can increase the detection range up to 15 meters.
 

8. Standard C drivers on GitHub

If you have any custom hardware and need to develop a specific driver for our infrared sensor, check the GitHub repository to find a platform independent driver for the STHS34PF80 device.
 

GitHub repository to find a platform independent driver for the STHS34PF80GitHub repository to find a platform independent driver for the STHS34PF80

 

Conclusion

We have seen how to get started with the new ST infrared sensor STHS34PF80 and its ecosystem, including both hardware and software tools.
You can find a dedicated webinar on the topic at this link: The key to smart occupancy detection: the new edge processing infrared sensor
 

Related links

UM3169 Getting started with InfraredPD presence and motion detection library in X-CUBEMEMS1 expansion for STM32Cube

GitHub repository for platform independent drivers

Unico-GUI

Version history
Last update:
‎2023-12-27 06:10 AM
Updated by:
Contributors