20 static const char *
const TAG =
"bmp581";
22 static 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");
45 static 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,
" Communication with BMP581 failed!");
78 ESP_LOGE(TAG,
" BMP581 has wrong chip ID - please verify you are using a BMP 581");
81 ESP_LOGE(TAG,
" BMP581 failed to reset");
84 ESP_LOGE(TAG,
" BMP581 sensor status failed, there were NVM problems");
87 ESP_LOGE(TAG,
" BMP581's IIR Filter failed to prime with an initial measurement");
90 ESP_LOGE(TAG,
" BMP581 error code %d", (
int) this->error_code_);
95 LOG_UPDATE_INTERVAL(
this);
97 ESP_LOGCONFIG(TAG,
" Measurement conversion time: %ums", this->
conversion_time_);
107 ESP_LOGCONFIG(TAG,
" IIR Filter: %s", LOG_STR_ARG(iir_filter_to_str(this->
iir_pressure_level_)));
124 this->error_code_ =
NONE;
125 ESP_LOGCONFIG(TAG,
"Setting up BMP581...");
133 ESP_LOGE(TAG,
"BMP581 failed to reset");
149 ESP_LOGE(TAG,
"Failed to read chip id");
158 if (chip_id != BMP581_ASIC_ID) {
159 ESP_LOGE(TAG,
"Unknown chip ID, is this a BMP581?");
172 ESP_LOGE(TAG,
"Failed to read status register");
181 if (!(this->
status_.bit.status_nvm_rdy)) {
182 ESP_LOGE(TAG,
"NVM not ready after boot");
191 if (this->
status_.bit.status_nvm_err) {
192 ESP_LOGE(TAG,
"NVM error detected on boot");
206 ESP_LOGE(TAG,
"Failed to write interrupt source register");
228 ESP_LOGE(TAG,
"Failed to write oversampling register");
248 ESP_LOGE(TAG,
"Failed to write IIR configuration registers");
257 ESP_LOGE(TAG,
"Failed to prime the IIR filter with an intiial measurement");
289 ESP_LOGVV(TAG,
"Requesting a measurement from sensor");
292 ESP_LOGW(TAG,
"Failed to request forced measurement of sensor");
302 ESP_LOGVV(TAG,
"Measurement is expected to take %d ms to complete", this->
conversion_time_);
314 ESP_LOGW(TAG,
"Failed to read temperature and pressure measurements, skipping update");
321 ESP_LOGW(TAG,
"Failed to read temperature measurement, skipping update");
352 ESP_LOGD(TAG,
"Data is not ready, sensor is in standby mode");
359 ESP_LOGE(TAG,
"Failed to read interrupt status register");
392 ESP_LOGE(TAG,
"Failed to write oversampling register");
400 ESP_LOGE(TAG,
"Failed to write IIR source register");
410 ESP_LOGE(TAG,
"Failed to request a forced measurement");
422 ESP_LOGE(TAG,
"IIR priming measurement was not ready");
430 ESP_LOGE(TAG,
"Failed to write IIR source register");
446 ESP_LOGW(TAG,
"Data from sensor isn't ready, skipping this update");
454 ESP_LOGW(TAG,
"Failed to read sensor's measurement data");
461 int32_t
raw_temp = (int32_t) data[2] << 16 | (int32_t) data[1] << 8 | (int32_t) data[0];
462 temperature = (float) (raw_temp / 65536.0);
475 ESP_LOGW(TAG,
"Data from sensor isn't ready, skipping this update");
483 ESP_LOGW(TAG,
"Failed to read sensor's measurement data");
490 int32_t
raw_temp = (int32_t) data[2] << 16 | (int32_t) data[1] << 8 | (int32_t) data[0];
491 temperature = (float) (raw_temp / 65536.0);
494 int32_t raw_press = (int32_t) data[5] << 16 | (int32_t) data[4] << 8 | (int32_t) data[3];
495 pressure = (float) (raw_press / 64.0);
507 ESP_LOGE(TAG,
"Failed to write reset command");
518 ESP_LOGE(TAG,
"Failed to read interrupt status register");
568 this->
int_source_.bit.drdy_data_reg_en = data_ready_enable;
579 this->
osr_config_.bit.osr_t = temperature_oversampling;
580 this->
osr_config_.bit.osr_p = pressure_oversampling;
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
Oversampling pressure_oversampling_
bool write_iir_settings_(IIRFilter temperature_iir, IIRFilter pressure_iir)
bool read_temperature_(float &temperature)
void status_set_warning(const char *message="unspecified")
IIRFilter iir_pressure_level_
bool write_interrupt_source_settings_(bool data_ready_enable)
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
sensor::Sensor * temperature_sensor_
enum esphome::bmp581::BMP581Component::ErrorCode NONE
sensor::Sensor * pressure_sensor_
bool read_temperature_and_pressure_(float &temperature, float &pressure)
union esphome::bmp581::BMP581Component::@46 odr_config_
bool check_data_readiness_()
bool write_power_mode_(OperationMode mode)
void status_clear_warning()
BedjetMode mode
BedJet operating mode.
void publish_state(float state)
Publish a new state to the front-end.
void dump_config() override
union esphome::bmp581::BMP581Component::@42 status_
Oversampling temperature_oversampling_
union esphome::bmp581::BMP581Component::@45 osr_config_
IIRFilter iir_temperature_level_
bool start_measurement_()
union esphome::bmp581::BMP581Component::@44 iir_config_
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
virtual void mark_failed()
Mark this component as failed.
Implementation of SPI Controller mode.
union esphome::bmp581::BMP581Component::@43 dsp_config_
union esphome::bmp581::BMP581Component::@40 int_source_
bool write_oversampling_settings_(Oversampling temperature_oversampling, Oversampling pressure_oversampling)
union esphome::bmp581::BMP581Component::@41 int_status_
void IRAM_ATTR HOT delay(uint32_t ms)
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len, bool stop=true)