6static constexpr const char *
const TAG =
"lps22";
8static constexpr uint8_t WHO_AM_I = 0x0F;
9static constexpr uint8_t LPS22HB_ID = 0xB1;
10static constexpr uint8_t LPS22HH_ID = 0xB3;
11static constexpr uint8_t CTRL_REG2 = 0x11;
12static constexpr uint8_t CTRL_REG2_ONE_SHOT_MASK = 0b1;
13static constexpr uint8_t STATUS = 0x27;
14static constexpr uint8_t STATUS_T_DA_MASK = 0b10;
15static constexpr uint8_t STATUS_P_DA_MASK = 0b01;
16static constexpr uint8_t TEMP_L = 0x2b;
17static constexpr uint8_t PRES_OUT_XL = 0x28;
18static constexpr uint8_t REF_P_XL = 0x28;
19static constexpr uint8_t READ_ATTEMPTS = 10;
20static constexpr uint8_t READ_INTERVAL = 5;
21static constexpr float PRESSURE_SCALE = 1.0f / 4096.0f;
22static constexpr float TEMPERATURE_SCALE = 0.01f;
27 if (value != LPS22HB_ID && value != LPS22HH_ID) {
28 ESP_LOGW(TAG,
"device IDs as %02x, which isn't a known LPS22HB or LPS22HH ID", value);
34 ESP_LOGCONFIG(TAG,
"LPS22:");
38 LOG_UPDATE_INTERVAL(
this);
41static constexpr uint32_t INTERVAL_READ = 0;
46 value |= CTRL_REG2_ONE_SHOT_MASK;
55 const uint8_t expected_status_mask = STATUS_T_DA_MASK | STATUS_P_DA_MASK;
56 if ((value & expected_status_mask) != expected_status_mask) {
57 ESP_LOGD(TAG,
"STATUS not ready: %x", value);
68 int16_t encoded =
static_cast<int16_t
>(
encode_uint16(t_buf[1], t_buf[0]));
69 float temp = TEMPERATURE_SCALE *
static_cast<float>(encoded);
virtual void mark_failed()
Mark this component as failed.
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") void set_interval(const std voi set_interval)(const char *name, uint32_t interval, std::function< void()> &&f)
Set an interval function with a unique name.
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") bool cancel_interval(const std boo cancel_interval)(const char *name)
Cancel an interval function.
ErrorCode write_register(uint8_t a_register, const uint8_t *data, size_t len) const
writes an array of bytes to a specific register in the I²C device
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len)
reads an array of bytes from a specific register in the I²C device
uint8_t read_attempts_remaining_
sensor::Sensor * temperature_sensor_
void dump_config() override
sensor::Sensor * pressure_sensor_
void publish_state(float state)
Publish a new state to the front-end.
Providing packet encoding functions for exchanging data with a remote host.
constexpr uint32_t encode_uint24(uint8_t byte1, uint8_t byte2, uint8_t byte3)
Encode a 24-bit value given three bytes in most to least significant byte order.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.