mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-31 01:21:36 +08:00
drivers/hygrometer/sht3x: extend alert range (#21521)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* Copyright (c) 2021 PX4 Development Team. All rights reserved.
|
* Copyright (c) 2021-2023 PX4 Development Team. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -195,6 +195,24 @@ int SHT3X::init_sensor()
|
|||||||
|
|
||||||
PX4_INFO("Connected to SHT3x sensor, SN: %ld", _sht_info.serial_number);
|
PX4_INFO("Connected to SHT3x sensor, SN: %ld", _sht_info.serial_number);
|
||||||
|
|
||||||
|
// Modify ALERT range values to minimalize ALERT led heating.
|
||||||
|
|
||||||
|
// def temp(t):
|
||||||
|
// return ((t+45)*(2**16-1))/175
|
||||||
|
// def hum(h):
|
||||||
|
// return (h/100)*(2**16-1)
|
||||||
|
//
|
||||||
|
// hex((int(hum(80))>>9<<9) | (int(temp(60))>>7))
|
||||||
|
|
||||||
|
uint8_t sh[] {0xff, 0xe2};
|
||||||
|
uint8_t ch[] {0xfb, 0xdc};
|
||||||
|
uint8_t sl[] {0x00, 0x0e};
|
||||||
|
uint8_t cl[] {0x04, 0x14};
|
||||||
|
write_data(SHT3x_CMD_ALERT_W_SET_HIGH, sh, 2); // 100%, 120C
|
||||||
|
write_data(SHT3x_CMD_ALERT_W_CLEAR_HIGH, ch, 2); // 98%, 118C
|
||||||
|
write_data(SHT3x_CMD_ALERT_W_SET_LOW, sl, 2); // 0%, -40C
|
||||||
|
write_data(SHT3x_CMD_ALERT_W_CLEAR_LOW, cl, 2); // 2%, -38C
|
||||||
|
|
||||||
return PX4_OK;
|
return PX4_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,9 +53,13 @@
|
|||||||
|
|
||||||
#define SHT3X_CMD_READ_STATUS 0xF32D
|
#define SHT3X_CMD_READ_STATUS 0xF32D
|
||||||
#define SHT3X_CMD_CLEAR_STATUS 0x3041
|
#define SHT3X_CMD_CLEAR_STATUS 0x3041
|
||||||
#define SHT3x_CMD_PERIODIC_2HZ_MEDIUM 0x2220
|
#define SHT3x_CMD_PERIODIC_2HZ_MEDIUM 0x2220
|
||||||
#define SHT3x_CMD_FETCH_DATA 0xE000
|
#define SHT3x_CMD_FETCH_DATA 0xE000
|
||||||
#define SHT3x_CMD_READ_SN 0x3780
|
#define SHT3x_CMD_READ_SN 0x3780
|
||||||
|
#define SHT3x_CMD_ALERT_W_SET_HIGH 0x611D
|
||||||
|
#define SHT3x_CMD_ALERT_W_SET_LOW 0x6100
|
||||||
|
#define SHT3x_CMD_ALERT_W_CLEAR_HIGH 0x6116
|
||||||
|
#define SHT3x_CMD_ALERT_W_CLEAR_LOW 0x610B
|
||||||
|
|
||||||
|
|
||||||
using namespace time_literals;
|
using namespace time_literals;
|
||||||
|
|||||||
Reference in New Issue
Block a user