你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【STEVAL-STWINKT1B】:05读取LPS22HH气压

[复制链接]
〃聪聪哥哥 发布时间:2026-3-30 15:43

一:LPS22HH基本知识:

LPS22HH是一款超小型压阻式绝对压力传感器,它兼具数字输出气压计的功能。该设备包含一个传感元件以及一个集成电路接口,该接口可通过I2C、MIPI13CSM或SPI方式从传感元件与应用程序进行通信。
该传感元件用于检测绝对压力,由ST公司开发的专用工艺制造的悬吊膜构成
LPS22HH现已提供全模、带孔LGA封装(HLGA)版本。该产品保证可在从-40°C至+85°C的温度范围内稳定运行。该封装带有孔洞设计,以便外部压力能够触及传感元件。

二:软件代码如下所示:

void lps22hh_init( void )
{
  /* Initialize mems driver interface */
  dev_ctx.write_reg = platform_write;
  dev_ctx.read_reg = platform_read;
//  dev_ctx.mdelay = platform_delay;
  dev_ctx.handle = &SENSOR_BUS;
  /* Initialize platform specific hardware */
  platform_init();
  /* Wait sensor boot time */
  platform_delay(BOOT_TIME);
  /* Check device ID */
  whoamI = 0;
  lps22hh_device_id_get(&dev_ctx, &whoamI);

  if ( whoamI != LPS22HH_ID )
    while (1); /*manage here device not found */

  /* Restore default configuration */
  lps22hh_reset_set(&dev_ctx, PROPERTY_ENABLE);

  do {
    lps22hh_reset_get(&dev_ctx, &rst);
  } while (rst);

  /* Enable Block Data Update */
  lps22hh_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);
  /* Set Output Data Rate */
  lps22hh_data_rate_set(&dev_ctx, LPS22HH_10_Hz_LOW_NOISE);
}

2.2 读取函数,以及数据处理部分函数:

void lps22hh_read_data_polling(void)
{

  /* Read samples in polling mode (no int) */
    /* Read output only if new value is available */
    lps22hh_read_reg(&dev_ctx, LPS22HH_STATUS, (uint8_t *)&reg.status, 10);

    if (reg.status.p_da) {
    memset(&data_raw_pressure, 0x00, sizeof(uint32_t));
        lps22hh_pressure_raw_get(&dev_ctx, &data_raw_pressure);
        pressure_hPa = lps22hh_from_lsb_to_hpa( data_raw_pressure);
        sprintf((char *)tx_buffer, "ST-LPS22HH Pressure:%6.2f hpa\r\n", pressure_hPa);
        tx_com( tx_buffer, strlen( (char const *)tx_buffer ) );
    }

    if (reg.status.t_da) {
        memset(&data_raw_temperature, 0x00, sizeof(int16_t));
        lps22hh_temperature_raw_get(&dev_ctx, &data_raw_temperature);
        temperature_degC = lps22hh_from_lsb_to_celsius(
                            data_raw_temperature );
        sprintf((char *)tx_buffer, "ST-LPS22HH Temperature :%6.2f ℃\r\n",
                temperature_degC );
        tx_com( tx_buffer, strlen( (char const *)tx_buffer ) );
    }
}

三:串口数据读取部分:

03-4.png

03-2.png
03-4.png
收藏 评论0 发布时间:2026-3-30 15:43

举报

0个回答

所属标签

相似分享

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版