Based on STM32CUBEMX driver TMOS module STHS34PF80 (1) ---- get ID

overview

The STHS34PF80 is an uncooled, factory calibrated infrared motion and presence detection sensor operating between 5 µm and 20 µm.
The STHS34PF80 sensor is designed to measure the amount of infrared radiation emitted by objects within the field of view. This information is digitally processed by an ASIC, which can be programmed to monitor for motion, presence or overheating conditions.
With its excellent sensitivity, the STHS34PF80 can detect the presence of a human body at a distance of up to 4 meters without the need for optical lenses.
The STHS34PF80 is available in a small 3.2 x 4.2 x 1.455 (maximum) mm 10-pin LGA package.

Recently, I am taking courses of ST and Renesas RA. If you need samples, you can add a group application: 6_15061293.
insert image description here
The STHS34PF80 is an infrared sensor that can be used to detect the presence of stationary and moving objects, as well as over-temperature conditions. It uses unique TMOS technology to measure infrared radiation from objects to detect their presence or motion when they are within the field of view.
An optical bandpass filter is deposited on the sensor, limiting its operating range to the wavelength range of 5 microns to 20 microns, making it insensitive to visible light and other frequency bands.
The sensor is based on a matrix of floating vacuum thermal transistor MOS (TMOS) connected together and operating as a single sensing element. Thanks to ST's unique MEMS fabrication technology, advanced thermal isolation is achieved, enabling the sensor to convert the smallest temperature changes into electrical signals, which are then fed to the ASIC.
The sensor is divided into two parts, one exposed to infrared radiation and the other shielded. By taking a differential reading between the two parts, the effect of sensor self-heating is eliminated.
The STHS34PF80 integrates a high-precision temperature sensor to measure the ambient temperature and measure the precise infrared radiation of objects.
The ASIC also implements dedicated intelligent processing to detect/distinguish between stationary and moving objects and can assert dedicated interrupts.
Different output data rates (ODR) are available, ranging from 0.25 Hz to 30 Hz, as well as single-shot measurement modes.
The STHS34PF80 is equipped with an I²C/3-wire SPI interface and is housed in an SMD mount compatible OLGA 3.2 x 4.2 x 1.455 mm 10L package.
The field of view guaranteed by the package is 80°.
insert image description here

sample application

https://www.wjx.top/vm/OhcKxJk.aspx#

video tutorial

https://www.bilibili.com/video/BV11u4y1X7JY/

Based on STM32CUBEMX driver TMOS module STHS34PF80 (1) ---- get ID

Complete code download

https://download.csdn.net/download/qq_24312945/88216813

all functions

● Key Features
○ High Sensitivity Infrared Presence and Motion Detection Sensor
○ Up to 4m without Lens for Objects Dimensions 70 x 25 cm² ○
Integrated Silicon IR Filter
○ SMD Friendly
○ Capable of Detecting Stationary Objects
○ Ability to Distinguish Between Stationary and Moving Objects
○ 80° Field of View
○ Factory Calibration
○ Low Battery
○ Embedded Smart Algorithms for Presence/Motion Detection
Electrical Specifications ○
Supply Voltage: 1.7V to 3.6V
○ Supply Current: 10µA
○ 2-Wire I²C / 3-wire SPI serial interface
○ Programmable ODR (0.25 Hz to 30 Hz)
○ One-shot mode
Sensing specifications
○ IR sensitivity: 2000 LSB/°C
○ RMS noise: 25 LSB rms
○ Operating wavelength: 5 µm to 20 µm
○ Local temperature sensor accuracy: ±0.3℃
● Package size
○ LGA 10-lead, 3.2 x 4.2 x 1.455 (max) mm
○ ECOPACK and RoHS compliant
insert image description here

interface

The schematic diagram of the STHS34PF80 module interface is shown below, which supports IIC or SPI communication.
insert image description here

Minimum System Diagram

insert image description here

Generate STM32CUBEMX

Serial port configuration

Check the schematic diagram, PA9 and PA10 are set as the serial ports of the development board.
insert image description here

Configure the serial port.
insert image description here

IIC configuration

In this application, the STS34PF80 module communicates with the main controller through the I2C (IIC) interface. Specifically, the I2C pins of the STS34PF80 module are connected to two IO ports of the main controller, PB6 (pin B6) and PB7 (pin B7).

insert image description here

Configure the IIC as normal mode, and the speed is 100k.
insert image description here

IO port settings

The STS34PF80IO settings are shown below.
In IIC mode, CS needs to give a high level.
insert image description here
The official IIC wiring is as follows.
insert image description here
insert image description here

PA8 needs to be configured as output mode, the default is high level, and PA7 is configured as input mode.

insert image description here

Serial port redirection

Open the magic wand, check MicroLIB

insert image description here

In main.c, add the header file. If you don’t add it, an identifier “FILE” is undefined error will appear.

/* USER CODE BEGIN Includes */
#include "stdio.h"
/* USER CODE END Includes */

Function declaration and serial port redirection:

/* USER CODE BEGIN PFP */
int fputc(int ch, FILE *f){
    
    
	HAL_UART_Transmit(&huart1 , (uint8_t *)&ch, 1, 0xFFFF);
	return ch;
}
/* USER CODE END PFP */

module address

The default device address of the STHS34PF80 module is 1011010 (0x5A). A device address is an identifier used to identify and communicate with a particular device. By setting the device address of the VL6180 module to 1011010 (0x5A), you can ensure normal communication and control with the module.
insert image description here

reference demo

Here, refer to the case released by ST on GITHUB for modification.
https://github.com/STMicroelectronics/sths34pf80-pid/blob/master/sths34pf80_reg.c
object presence detection demo.
https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/sths34pf80_STdC/examples/sths34pf80_tmos_presence_detection.c

IIC write function

The corresponding driver program in the reference example program is sths34pf80_write_reg(), as shown below.
insert image description here
It can be seen from the above table that the address is 101 1010 (0x5A), if it is a write operation, then the specific address is 1011 0100 (0xB4).

/**
  * @brief  读取数据
  *
  * @param  add   模块地址
  * @param  reg   寄存器地址
  * @param  data  buffer 缓冲区
  * @param  len   读取长度
  * @retval ret   正常返回HAL_OK
  *
  */
uint8_t sths34pf80_read_reg(uint8_t add,uint8_t reg,  uint8_t * data, uint8_t len)
{
    
    
	uint8_t ret;
	ret=HAL_I2C_Mem_Read(&hi2c1 ,(add<<1)|1,reg,I2C_MEMADD_SIZE_8BIT,data,len,0xffff);

	return ret;
}

IIC read function

The corresponding driver program in the reference example program is sths34pf80_read_reg(), as shown below.
insert image description here

It can be known from the above table that the address is 101 1010 (0x5A), if it is a read operation, then the specific address is 1011 0101 (0xB5).

/**
  * @brief  写入数据
  *
  * @param  add   模块地址
  * @param  reg   寄存器地址
  * @param  data  buffer 缓冲区
  * @param  len   写入长度
  * @retval ret   正常返回HAL_OK
  *
  */
uint8_t sths34pf80_write_reg(uint8_t add,uint8_t reg, uint8_t * data, uint8_t len)
{
    
    
		uint8_t ret;
		HAL_I2C_Mem_Write(&hi2c1 ,(add<<1)|0,reg,I2C_MEMADD_SIZE_8BIT,data,len,0xffff);
	return ret;

}

Reference program initialization

insert image description here

get id

Refer to the corresponding ID acquisition driver program in the sample program, as shown below.
insert image description here

You can view 0x0F to obtain the ID, and the read value should be 0xD3.
insert image description here

The read function is as follows.

/**
  * @brief  获取设备ID
  *
  * @param  add      设备地址
  * @param  val      设备ID.
  * @retval ret   		正常返回HAL_OK
  *
  */

uint8_t STHS34PF80_getChipID(uint8_t add)
{
    
    
  uint8_t temp[1]={
    
    0};
	sths34pf80_read_reg(add,STHS34PF80_WHO_AM_I,temp,1);
  return temp[0];
}

main function

  /* USER CODE BEGIN 2 */

	uint8_t STHS34PF80_ID =STHS34PF80_getChipID(STHS34PF80_ADDRESS);
	printf("STHS34PF80_ID=0x%x\n",STHS34PF80_ID);	
	
  /* USER CODE END 2 */

Guess you like

Origin blog.csdn.net/qq_24312945/article/details/132264784