11static const char *
const TAG =
"xgzp68xx.sensor";
13static const uint8_t CMD_ADDRESS = 0x30;
14static const uint8_t SYSCONFIG_ADDRESS = 0xA5;
15static const uint8_t PCONFIG_ADDRESS = 0xA6;
16static const uint8_t READ_COMMAND = 0x0A;
19 switch (oversampling) {
44 uint8_t oldconfig = 0;
48 ESP_LOGD(TAG,
"oversampling to %s: oldconfig = 0x%x newconfig = 0x%x",
60 uint16_t temperature_raw = 0;
66 ESP_LOGE(TAG,
"Failed to read sensor data! Error code: %i", success);
74 ESP_LOGV(TAG,
"Got raw pressure=%" PRIu32
", raw temperature=%u, K value=%u", pressure_raw, temperature_raw,
78 float pressure_in_pa = (float) (((int32_t) pressure_raw << 8) >> 8);
79 pressure_in_pa /= (float) (this->
k_value_);
81 float temperature = ((float) (int16_t) temperature_raw) / 256.0f;
83 if (this->pressure_sensor_ !=
nullptr)
84 this->pressure_sensor_->publish_state(pressure_in_pa);
86 if (this->temperature_sensor_ !=
nullptr)
87 this->temperature_sensor_->publish_state(
temperature);
92 uint8_t config1 = 0, config2 = 0;
103 ESP_LOGD(TAG,
"sys_config 0x%x, p_config 0x%x", config1, config2);
107 ESP_LOGCONFIG(TAG,
"XGZP68xx:");
108 LOG_SENSOR(
" ",
"Temperature: ", this->temperature_sensor_);
109 LOG_SENSOR(
" ",
"Pressure: ", this->pressure_sensor_);
110 if (this->pressure_sensor_ !=
nullptr) {
113 LOG_I2C_DEVICE(
this);
115 ESP_LOGE(TAG,
" Connection failed");
117 LOG_UPDATE_INTERVAL(
this);
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_timeout(const std voi set_timeout)(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
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
XGZP68XXOversampling last_pressure_oversampling_
void dump_config() override
XGZP68XXOversampling pressure_oversampling_
@ ERROR_OK
No error found during execution of method.
XGZP68XXOversampling
Enum listing all oversampling options for the XGZP68XX.
@ XGZP68XX_OVERSAMPLING_32768X
@ XGZP68XX_OVERSAMPLING_1024X
@ XGZP68XX_OVERSAMPLING_256X
@ XGZP68XX_OVERSAMPLING_8192X
@ XGZP68XX_OVERSAMPLING_2048X
@ XGZP68XX_OVERSAMPLING_4096X
@ XGZP68XX_OVERSAMPLING_16384X
@ XGZP68XX_OVERSAMPLING_512X
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.