15namespace bmp3xx_base {
17static const char *
const TAG =
"bmp3xx.sensor";
19static const LogString *chip_type_to_str(uint8_t chip_type) {
22 return LOG_STR(
"BMP 388");
24 return LOG_STR(
"BMP 390");
26 return LOG_STR(
"Unknown Chip Type");
33static const LogString *oversampling_to_str(
Oversampling oversampling) {
34 return OversamplingStrings::get_log_str(
static_cast<uint8_t
>(oversampling), OversamplingStrings::LAST_INDEX);
40static const LogString *iir_filter_to_str(
IIRFilter filter) {
41 return IIRFilterStrings::get_log_str(
static_cast<uint8_t
>(filter), IIRFilterStrings::LAST_INDEX);
45 this->error_code_ =
NONE;
48 ESP_LOGE(TAG,
"Failed to reset");
54 ESP_LOGE(TAG,
"Can't read chip id");
59 ESP_LOGCONFIG(TAG,
"Chip %s Id 0x%X", LOG_STR_ARG(chip_type_to_str(this->
chip_id_.reg)), this->chip_id_.reg);
62 ESP_LOGE(TAG,
"Unknown chip id - is this really a BMP388 or BMP390?");
71 ESP_LOGE(TAG,
"Can't read calibration data");
77 (float) compensation_params_.param_T1 / powf(2.0f, -8.0f);
94 ESP_LOGE(TAG,
"Failed to set IIR filter");
115 ESP_LOGE(TAG,
"Failed to set oversampling register");
126 LOG_STR_ARG(chip_type_to_str(this->
chip_id_.reg)), this->chip_id_.reg);
127 switch (this->error_code_) {
131 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
134 ESP_LOGE(TAG,
"Wrong chip ID (reported id: 0x%X) - please check if you are really using a BMP 388 or BMP 390",
138 ESP_LOGE(TAG,
"Failed to reset");
141 ESP_LOGE(TAG,
"Error code %d", (
int) this->error_code_);
144 ESP_LOGCONFIG(TAG,
" IIR Filter: %s", LOG_STR_ARG(iir_filter_to_str(this->
iir_filter_)));
145 LOG_UPDATE_INTERVAL(
this);
160 ESP_LOGV(TAG,
"Sending conversion request");
161 float meas_time = 1.0f;
167 ESP_LOGE(TAG,
"Failed start forced mode");
172 const uint32_t meas_timeout = uint32_t(ceilf(meas_time));
173 ESP_LOGVV(TAG,
"measurement time %" PRIu32, meas_timeout);
179 ESP_LOGW(TAG,
"Failed to read pressure and temperature - skipping update");
186 ESP_LOGW(TAG,
"Failed to read temperature - skipping update");
190 ESP_LOGD(TAG,
"Got temperature=%.1f°C",
temperature);
208 return event_.bit.por_detected;
225 osr_.bit.osr_p = oversampling;
231 osr_.bit.osr_t = oversampling;
250 ESP_LOGE(TAG,
"Failed to read temperature");
254 int32_t adc_temp = (int32_t) data[2] << 16 | (int32_t) data[1] << 8 | (int32_t) data[0];
270 ESP_LOGD(TAG,
"Get measurement - data not ready skipping update");
277 ESP_LOGE(TAG,
"Failed to read measurements");
281 int32_t adc_pres = (int32_t) data[2] << 16 | (int32_t) data[1] << 8 | (int32_t) data[0];
282 int32_t adc_temp = (int32_t) data[5] << 16 | (int32_t) data[4] << 8 | (int32_t) data[3];
302 osr_.reg = temperature_oversampling << 3 | pressure_oversampling;
310 ESP_LOGD(TAG,
"Not ready - sensor is in sleep mode");
316 ESP_LOGE(TAG,
"Failed to read status register");
320 ESP_LOGVV(TAG,
"data ready status %d",
status);
351 partial_data1 = uncomp_press * uncomp_press;
353 partial_data3 = partial_data1 * partial_data2;
354 float partial_data4 =
356 return partial_out1 + partial_out2 + partial_data4;
BedjetMode mode
BedJet operating mode.
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message=nullptr)
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.
void status_clear_warning()
Oversampling pressure_oversampling_
union esphome::bmp3xx_base::BMP3XXComponent::@24 event_
union esphome::bmp3xx_base::BMP3XXComponent::@27 osr_
struct esphome::bmp3xx_base::BMP3XXComponent::FloatParams compensation_float_params_
bool get_pressure(float &pressure)
Get a pressure measurement.
union esphome::bmp3xx_base::BMP3XXComponent::@23 chip_id_
bool get_measurements(float &temperature, float &pressure)
Get a temperature and pressure measurement.
union esphome::bmp3xx_base::BMP3XXComponent::@26 pwr_ctrl_
enum esphome::bmp3xx_base::BMP3XXComponent::ErrorCode NONE
bool start_forced_conversion()
Start a one shot measurement in FORCED_MODE.
sensor::Sensor * temperature_sensor_
bool set_iir_filter(IIRFilter iir_filter)
Set the IIR filter setting: OFF, 2, 3, 8, 16, 32.
union esphome::bmp3xx_base::BMP3XXComponent::@29 config_
bool set_pressure_oversampling(Oversampling pressure_oversampling)
Set the pressure oversampling: OFF, X1, X2, X4, X8, X16, X32.
union esphome::bmp3xx_base::BMP3XXComponent::@25 int_status_
@ ERROR_COMMUNICATION_FAILED
bool get_temperature(float &temperature)
Get a temperature measurement.
sensor::Sensor * pressure_sensor_
bool stop_conversion()
Stop the conversion and return to SLEEP_MODE.
float bmp388_compensate_temperature_(float uncomp_temp)
Oversampling temperature_oversampling_
virtual bool write_byte(uint8_t a_register, uint8_t data)=0
virtual bool read_bytes(uint8_t a_register, uint8_t *data, size_t len)=0
uint8_t reset()
Soft reset the sensor.
bool set_oversampling_register(Oversampling pressure_oversampling, Oversampling temperature_oversampling)
Set the BMP388 oversampling register.
bool data_ready()
Checks if a measurement is ready.
virtual bool read_byte(uint8_t a_register, uint8_t *data)=0
bool set_mode(OperationMode mode)
Set the barometer mode.
float bmp388_compensate_pressure_(float uncomp_press, float t_lin)
void dump_config() override
bool set_temperature_oversampling(Oversampling temperature_oversampling)
Set the temperature oversampling: OFF, X1, X2, X4, X8, X16, X32.
void publish_state(float state)
Publish a new state to the front-end.
uint8_t oversampling_to_time(Oversampling over_sampling)
Oversampling
Oversampling bit fields in the control and measurement register.
OperationMode
Device mode bitfield in the control and measurement register.
PROGMEM_STRING_TABLE(OversamplingStrings, "None", "2x", "4x", "8x", "16x", "32x", "")
IIRFilter
Infinite Impulse Response (IIR) filter bit field in the configuration register.
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delay(uint32_t ms)