20static const char *
const TAG =
"bmp581";
22static const LogString *oversampling_to_str(
Oversampling oversampling) {
23 switch (oversampling) {
25 return LOG_STR(
"None");
33 return LOG_STR(
"16x");
35 return LOG_STR(
"32x");
37 return LOG_STR(
"64x");
39 return LOG_STR(
"128x");
45static const LogString *iir_filter_to_str(
IIRFilter filter) {
48 return LOG_STR(
"OFF");
56 return LOG_STR(
"16x");
58 return LOG_STR(
"32x");
60 return LOG_STR(
"64x");
62 return LOG_STR(
"128x");
69 ESP_LOGCONFIG(TAG,
"BMP581:");
71 switch (this->error_code_) {
75 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
78 ESP_LOGE(TAG,
"Unknown chip ID");
81 ESP_LOGE(TAG,
"Reset failed");
84 ESP_LOGE(TAG,
"Get status failed");
87 ESP_LOGE(TAG,
"IIR Filter failed to prime with initial measurement");
90 ESP_LOGE(TAG,
"Error %d", (
int) this->error_code_);
95 LOG_UPDATE_INTERVAL(
this);
97 ESP_LOGCONFIG(TAG,
" Measurement conversion time: %ums", this->
conversion_time_);
130 this->error_code_ =
NONE;
131 ESP_LOGCONFIG(TAG,
"Running setup");
139 ESP_LOGE(TAG,
"Reset failed");
155 ESP_LOGE(TAG,
"Read chip ID failed");
164 if (chip_id != BMP581_ASIC_ID) {
165 ESP_LOGE(TAG,
"Unknown chip ID");
178 ESP_LOGE(TAG,
"Failed to read status register");
187 if (!(this->
status_.bit.status_nvm_rdy)) {
188 ESP_LOGE(TAG,
"NVM not ready");
197 if (this->
status_.bit.status_nvm_err) {
198 ESP_LOGE(TAG,
"NVM error detected");
212 ESP_LOGE(TAG,
"Failed to write interrupt source register");
234 ESP_LOGE(TAG,
"Failed to write oversampling register");
254 ESP_LOGE(TAG,
"Failed to write IIR configuration registers");
263 ESP_LOGE(TAG,
"Failed to prime the IIR filter with an initial measurement");
295 ESP_LOGVV(TAG,
"Requesting measurement");
298 ESP_LOGW(TAG,
"Requesting forced measurement failed");
320 ESP_LOGW(TAG,
"Failed to read temperature and pressure; skipping update");
327 ESP_LOGW(TAG,
"Failed to read temperature; skipping update");
358 ESP_LOGD(TAG,
"Data not ready, sensor is in standby mode");
365 ESP_LOGE(TAG,
"Failed to read interrupt status register");
398 ESP_LOGE(TAG,
"Failed to write oversampling register");
406 ESP_LOGE(TAG,
"Failed to write IIR source register");
416 ESP_LOGE(TAG,
"Failed to request a forced measurement");
428 ESP_LOGE(TAG,
"IIR priming measurement was not ready");
436 ESP_LOGE(TAG,
"Failed to write IIR source register");
452 ESP_LOGW(TAG,
"Data not ready, skipping this update");
460 ESP_LOGW(TAG,
"Failed to read measurement");
467 int32_t
raw_temp = (int32_t) data[2] << 16 | (int32_t) data[1] << 8 | (int32_t) data[0];
481 ESP_LOGW(TAG,
"Data not ready, skipping this update");
489 ESP_LOGW(TAG,
"Failed to read measurement");
496 int32_t
raw_temp = (int32_t) data[2] << 16 | (int32_t) data[1] << 8 | (int32_t) data[0];
500 int32_t raw_press = (int32_t) data[5] << 16 | (int32_t) data[4] << 8 | (int32_t) data[3];
501 pressure = (float) (raw_press / 64.0);
513 ESP_LOGE(TAG,
"Failed to write reset command");
524 ESP_LOGE(TAG,
"Failed to read interrupt status register");
574 this->
int_source_.bit.drdy_data_reg_en = data_ready_enable;
585 this->
osr_config_.bit.osr_t = temperature_oversampling;
586 this->
osr_config_.bit.osr_p = pressure_oversampling;
BedjetMode mode
BedJet operating mode.
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message="unspecified")
void status_clear_warning()
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
IIRFilter iir_temperature_level_
IIRFilter iir_pressure_level_
sensor::Sensor * pressure_sensor_
union esphome::bmp581::BMP581Component::@42 status_
union esphome::bmp581::BMP581Component::@45 osr_config_
union esphome::bmp581::BMP581Component::@43 dsp_config_
bool read_temperature_(float &temperature)
bool write_oversampling_settings_(Oversampling temperature_oversampling, Oversampling pressure_oversampling)
union esphome::bmp581::BMP581Component::@41 int_status_
bool write_interrupt_source_settings_(bool data_ready_enable)
bool read_temperature_and_pressure_(float &temperature, float &pressure)
sensor::Sensor * temperature_sensor_
Oversampling pressure_oversampling_
union esphome::bmp581::BMP581Component::@46 odr_config_
Oversampling temperature_oversampling_
@ ERROR_COMMUNICATION_FAILED
bool write_iir_settings_(IIRFilter temperature_iir, IIRFilter pressure_iir)
void dump_config() override
bool write_power_mode_(OperationMode mode)
enum esphome::bmp581::BMP581Component::ErrorCode NONE
union esphome::bmp581::BMP581Component::@40 int_source_
bool start_measurement_()
bool check_data_readiness_()
union esphome::bmp581::BMP581Component::@44 iir_config_
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len, bool stop=true)
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
void publish_state(float state)
Publish a new state to the front-end.
@ BMP581_MEASUREMENT_DATA
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delay(uint32_t ms)