5393 views|3 replies

1452

Posts

1

Resources
The OP
 

[ST MEMS waterproof pressure sensor LPS27HHW review] + comparison and application between 2 drivers (and final report) [Copy link]

 This post was last edited by jinglixixi on 2021-2-11 01:14

Because the driver of LPS27HHW was blocked, the evaluation process was slowed down. Fortunately, with the guidance and help of the administrator, I finally got the solution in the relevant post of littleshrimp.

1. Comparison between LPS27HHW and LPS22HH

Both LPS22HH and LPS27HHW are air pressure sensors, but each has its own characteristics. Therefore, they are compared from the following points.

1) Appearance comparison

Figure 1 LPS22HH sensor

Figure 2 LPS27HHW sensor

From the appearance, we can see that both sensors are placed on the development board for use due to their small size, and both are connected to double-row 12-pin pin headers for user use. However, LPS27HHW is more outstanding than LPS22HH in its waterproof performance of rear membrane design.

2) Performance comparison

name

LPS22HH

LPS27HHW

Measuring range

260 ~ 1260 hPa

260 ~ 1260 hPa

Communication interface

IC, Serial, SPI

SPI, IC or MIPI I3C

Operating voltage

1.7V ~ 3.6V

1.7V ~ 3.6V

Measurement accuracy

24 bit precision

24 bit precision

ODR

1 ~ 200 Hz

1 ~ 200 Hz

Minimum current

4 μA

4 μA

Absolute pressure accuracy

0.5 hPa

0.5 hPa

Low pressure sensor noise

0.65 Pa

0.7 Pa

Package Type

Thin and small package

Waterproof packaging

2) Driver comparison

Although there are slight differences in hardware between LPS22HH and LPS27HHW, what are the differences in their software drivers?

In the main program:

The program structures of the two are exactly the same. The only difference is the names of the functions called. After all, the devices driven are different!

In LPS27HHW, there is a structure definition called ucf_line_t, but it is not used.

typedef struct {

uint8_t address;

uint8_t data;

} ucf_line_t;

In addition, the structure definitions of axis1bit16_t and axis1bit32_t are placed in the main program, while LPS22HH is placed in lps22hh_reg.h.

typedef union{

int16_t i16bit;

uint8_t u8bit[2];

} axis1bit16_t;

typedef union{

int32_t i32bit;

uint8_t u8bit[4];

}axis1bit32_t;

In driver.c:

The program structures of the two are exactly the same, the only difference is that the corresponding function names are different.

In driver.h:

The program structures of the two are exactly the same, the only difference is that the corresponding function names are different.

The ID values of LPS22HH and LPS27HHW are the same, see the following definition:

#define LPS22HH_ID 0xB3U

#define LPS27HHW_ID 0xB3U

In lps22hh_reg.h, there are additional structure definitions for axis3bit16_t and axis3bit32_t, but they are not used.

typedef union{

int16_t i16bit[3];

uint8_t u8bit[6];

} axis3bit16_t;

typedef union{

int32_t i32bit[3];

uint8_t u8bit[12];

} axis3bit32_t;

3) Comparative conclusion

In summary, we can conclude that the drivers of the two are universal, that is, the driver of LPS22HH can be used to drive LPS27HHW.

So what is the actual situation? After actual testing, this speculation is completely correct.

2. LPS27HHW Applications

In actual application, the connection relationship between LPS27HHW and STM32L452 is:

VDD --- 3.3V

Vdd_IO --- 3.3V

GND ---GND

SCL---PB8

SDA---PB9

The main program to realize the air pressure detection function is as follows:

int main(void)
{
 HAL_Init();
 SystemClock_Config();
 MX_GPIO_Init();
 MX_I2C1_Init();
 MX_USART2_UART_Init();
 lps22hh_ctx_t dev_ctx; //stmdev_ctx_t dev_ctx;
 dev_ctx.write_reg = platform_write;
 dev_ctx.read_reg = platform_read;
 dev_ctx.handle = &hi2c1;
 sprintf((char*)tx_buffer, "LPS22HH test\r\n");
tx_com( tx_buffer, strlen( (char const*)tx_buffer ) );
 OLED_Init();
 OLED_Clear();
 OLED_ShowString(8,0,"STM32L452",16);
 OLED_ShowString(8,2,"OLED & LPS27HHW",16);
 HAL_Delay(1000);
 HAL_Delay(1000);
 OLED_Clear();
 OLED_ShowString(8,0,"pres=",16);
 OLED_ShowString(8,2,"temp=",16);
 whoamI = 0;
 lps22hh_device_id_get(&dev_ctx, &whoamI);
 if ( whoamI != LPS22HH_ID )
 while(1);
 lps22hh_reset_set(&dev_ctx, PROPERTY_ENABLE);
 do {
 lps22hh_reset_get(&dev_ctx, &rst);
 } while (rst);
 lps22hh_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);
 lps22hh_data_rate_set(&dev_ctx, LPS22HH_10_Hz_LOW_NOISE);
 while (1)
 {
 lps22hh_reg_t reg;
 lps22hh_read_reg(&dev_ctx, LPS22HH_STATUS, (uint8_t *)®, 1);
   if(reg.status.p_da)
 {
 memset(data_raw_pressure.u8bit, 0x00, sizeof(int32_t));
 lps22hh_pressure_raw_get(&dev_ctx, data_raw_pressure.u8bit);
 pressure_hPa = lps22hh_from_lsb_to_hpa( data_raw_pressure.i32bit);
 sprintf((char*)tx_buffer, "pressure [hPa]:%6.2f\r\n", pressure_hPa);
 tx_com( tx_buffer, strlen( (char const*)tx_buffer ) );
 sprintf((char*)tx_buffer, "pres=%6.2fhPa", pressure_hPa);
 OLED_ShowString(8,0,tx_buffer,16);
 }

 if(reg.status.t_da)
 {
  memset(data_raw_temperature.u8bit, 0x00, sizeof(int16_t));
 lps22hh_temperature_raw_get(&dev_ctx, data_raw_temperature.u8bit);
 temperature_degC = lps22hh_from_lsb_to_celsius( data_raw_temperature.i16bit );
 sprintf((char*)tx_buffer, "temperature [degC]:%6.2f\r\n", temperature_degC );
 tx_com( tx_buffer, strlen( (char const*)tx_buffer ) );
 sprintf((char*)tx_buffer, "temp=%6.2fdegC", temperature_degC );
 OLED_ShowString(8,2,tx_buffer,16);
 }
 HAL_Delay(500);
 HAL_GPIO_WritePin(LD4_GPIO_Port, LD4_Pin, GPIO_PIN_RESET);
 HAL_Delay(500);
 HAL_GPIO_WritePin(LD4_GPIO_Port, LD4_Pin, GPIO_PIN_SET);
 }
}

The circuit connection for LPS27HHW detection is shown in FIG3 , and the detection result is shown in FIG4 .

Figure 3 Serial port detection connection

Figure 4 Serial port detection effect

When the OLED screen is connected, the display effect is shown in Figures 5 and 6.

Figure 5 OLED screen display interface

Figure 6 OLED screen display effect

With the above practical experience, I feel that the performance of LPS27HHW is still very good. It can detect the temperature of the environment while detecting the air pressure, which is suitable for use in small weather stations. If I have time later, I will transplant it to other development boards for use.

This post is from MEMS sensors

Latest reply

hPa is the unit given... OK   Details Published on 2021-2-25 22:23

赞赏

1

查看全部赞赏

 
 

1942

Posts

2

Resources
2
 

The review is well written. I like review posts like yours. Thank you for sharing! Looking forward to the follow-up

This post is from MEMS sensors
 
 
 

1452

Posts

1

Resources
3
 
w494143467 posted on 2021-2-17 15:06 The review is well written. I like review posts like yours. Thank you for sharing! Looking forward to the follow-up

This post is from MEMS sensors
 
 
 

7422

Posts

2

Resources
4
 

hPa is the unit given... OK

This post is from MEMS sensors
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list