6static const char *
const TAG =
"bmp085.sensor";
8static const uint8_t BMP085_ADDRESS = 0x77;
9static const uint8_t BMP085_REGISTER_AC1_H = 0xAA;
10static const uint8_t BMP085_REGISTER_CONTROL = 0xF4;
11static const uint8_t BMP085_REGISTER_DATA_MSB = 0xF6;
12static const uint8_t BMP085_CONTROL_MODE_TEMPERATURE = 0x2E;
13static const uint8_t BMP085_CONTROL_MODE_PRESSURE_3 = 0xF4;
16 if (!this->
set_mode_(BMP085_CONTROL_MODE_TEMPERATURE))
23 if (!this->
read_bytes(BMP085_REGISTER_AC1_H, data, 22)) {
35 this->
calibration_.
b1 = ((data[12] & 0xFF) << 8) | (data[13] & 0xFF);
36 this->
calibration_.
b2 = ((data[14] & 0xFF) << 8) | (data[15] & 0xFF);
37 this->
calibration_.
mb = ((data[16] & 0xFF) << 8) | (data[17] & 0xFF);
38 this->
calibration_.
mc = ((data[18] & 0xFF) << 8) | (data[19] & 0xFF);
39 this->
calibration_.
md = ((data[20] & 0xFF) << 8) | (data[21] & 0xFF);
42 ESP_LOGCONFIG(TAG,
"BMP085:");
45 ESP_LOGE(TAG,
"Connection with BMP085 failed!");
47 LOG_UPDATE_INTERVAL(
this);
50 LOG_SENSOR(
" ",
"Pressure", this->
pressure_);
56 if (!this->
read_bytes(BMP085_REGISTER_DATA_MSB, buffer, 2)) {
61 int32_t ut = ((buffer[0] & 0xFF) << 8) | (buffer[1] & 0xFF);
63 ESP_LOGW(TAG,
"Invalid temperature!");
73 double a = c5 * (ut - c6);
74 float temp = a + (mc / (a + md));
77 ESP_LOGD(TAG,
"Got Temperature=%.1f °C", temp);
82 if (!this->
set_mode_(BMP085_CONTROL_MODE_PRESSURE_3)) {
91 if (!this->
read_bytes(BMP085_REGISTER_DATA_MSB, buffer, 3)) {
97 if ((value >> 5) == 0) {
98 ESP_LOGW(TAG,
"Invalid pressure!");
105 double b1 = pow(160.0, 2.0) * pow(2.0, -30.0) * this->
calibration_.
b1;
108 double x2 = pow(160.0, 2.0) * pow(2.0, -25.0) * this->
calibration_.
b2;
109 double y0 = c4 * pow(2.0, 15.0);
112 double p0 = (3791.0 - 8.0) / 1600.0;
113 double p1 = 1.0 - 7357.0 * pow(2, -20);
114 double p2 = 3038.0 * 100.0 * pow(2, -36);
116 double p = value / 256.0;
118 double x = (x2 * s * s) + (x1 * s) + x0;
119 double y = (y2 * s * s) + (y1 * s) + y0;
120 double z = (p -
x) /
y;
123 ESP_LOGD(TAG,
"Got Pressure=%.1f hPa",
pressure);
130 ESP_LOGV(TAG,
"Setting mode to 0x%02X",
mode);
BedjetMode mode
BedJet operating mode.
void mark_failed()
Mark this component as failed.
void status_set_warning()
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()
CalibrationData calibration_
void setup() override
Setup the sensor and test for a connection.
void read_pressure_()
Internal method to read the pressure from the component after it has been scheduled.
void update() override
Schedule temperature+pressure readings.
void dump_config() override
sensor::Sensor * pressure_
void read_temperature_()
Internal method to read the temperature from the component after it has been scheduled.
bool set_mode_(uint8_t mode)
sensor::Sensor * temperature_
bool write_byte(uint8_t a_register, uint8_t data) const
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.