8static const char *
const TAG =
"sdp3x.sensor";
9static const uint16_t SDP3X_SOFT_RESET = 0x0006;
10static const uint16_t SDP3X_READ_ID1 = 0x367C;
11static const uint16_t SDP3X_READ_ID2 = 0xE102;
12static const uint16_t SDP3X_START_DP_AVG = 0x3615;
13static const uint16_t SDP3X_START_MASS_FLOW_AVG = 0x3603;
14static const uint16_t SDP3X_STOP_MEAS = 0x3FF9;
20 ESP_LOGW(TAG,
"Stop failed");
24 ESP_LOGW(TAG,
"Soft Reset failed");
29 ESP_LOGE(TAG,
"Read ID1 failed");
34 ESP_LOGE(TAG,
"Read ID2 failed");
41 ESP_LOGE(TAG,
"Read ID failed");
49 if (data[1] >> 8 == 0x02) {
50 switch (data[1] & 0xFF) {
52 ESP_LOGCONFIG(TAG,
"Sensor is SDP800-500Pa");
55 ESP_LOGCONFIG(TAG,
"Sensor is SDP810-500Pa");
58 ESP_LOGCONFIG(TAG,
"Sensor is SDP801-500Pa");
61 ESP_LOGCONFIG(TAG,
"Sensor is SDP811-500Pa");
64 ESP_LOGCONFIG(TAG,
"Sensor is SDP800-125Pa");
67 ESP_LOGCONFIG(TAG,
"Sensor is SDP810-125Pa");
70 }
else if (data[1] >> 8 == 0x01) {
71 if ((data[1] & 0xFF) == 0x01) {
72 ESP_LOGCONFIG(TAG,
"Sensor is SDP31-500Pa");
73 }
else if ((data[1] & 0xFF) == 0x02) {
74 ESP_LOGCONFIG(TAG,
"Sensor is SDP32-125Pa");
79 ESP_LOGE(TAG,
"Start Measurements failed");
83 ESP_LOGCONFIG(TAG,
"started");
87 LOG_SENSOR(
" ",
"SDP3X",
this);
90 ESP_LOGE(TAG,
" Connection with failed");
92 LOG_UPDATE_INTERVAL(
this);
98 ESP_LOGW(TAG,
"Couldn't read data");
103 int16_t pressure_raw = data[0];
104 int16_t temperature_raw = data[1];
105 int16_t scale_factor_raw = data[2];
107 float pressure = pressure_raw / (scale_factor_raw * 100.0f);
108 ESP_LOGV(TAG,
"Got raw pressure=%d, raw scale factor =%d, raw temperature=%d ", pressure_raw, scale_factor_raw,
110 ESP_LOGD(TAG,
"Got Pressure=%.3f hPa",
pressure);
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()
void read_pressure_()
Internal method to read the pressure from the component after it has been scheduled.
void setup() override
Setup the sensor and test for a connection.
void update() override
Schedule temperature+pressure readings.
void dump_config() override
MeasurementMode measurement_mode_
bool write_command(T i2c_register)
Write a command to the I2C device.
bool read_data(uint16_t *data, uint8_t len)
Read data words from I2C device.
void publish_state(float state)
Publish a new state to the front-end.