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");
46 if (data[1] >> 8 == 0x02) {
47 switch (data[1] & 0xFF) {
49 ESP_LOGCONFIG(TAG,
"Sensor is SDP800-500Pa");
52 ESP_LOGCONFIG(TAG,
"Sensor is SDP810-500Pa");
55 ESP_LOGCONFIG(TAG,
"Sensor is SDP801-500Pa");
58 ESP_LOGCONFIG(TAG,
"Sensor is SDP811-500Pa");
61 ESP_LOGCONFIG(TAG,
"Sensor is SDP800-125Pa");
64 ESP_LOGCONFIG(TAG,
"Sensor is SDP810-125Pa");
67 }
else if (data[1] >> 8 == 0x01) {
68 if ((data[1] & 0xFF) == 0x01) {
69 ESP_LOGCONFIG(TAG,
"Sensor is SDP31-500Pa");
70 }
else if ((data[1] & 0xFF) == 0x02) {
71 ESP_LOGCONFIG(TAG,
"Sensor is SDP32-125Pa");
76 this->
mark_failed(LOG_STR(
"Start Measurements failed"));
79 ESP_LOGCONFIG(TAG,
"started");
83 LOG_SENSOR(
" ",
"SDP3X",
this);
85 LOG_UPDATE_INTERVAL(
this);
91 ESP_LOGW(TAG,
"Couldn't read data");
96 int16_t pressure_raw = data[0];
97 int16_t temperature_raw = data[1];
98 int16_t scale_factor_raw = data[2];
100 float pressure = pressure_raw / (scale_factor_raw * 100.0f);
101 ESP_LOGV(TAG,
"Got raw pressure=%d, raw scale factor =%d, raw temperature=%d ", pressure_raw, scale_factor_raw,
103 ESP_LOGD(TAG,
"Got Pressure=%.3f hPa",
pressure);
void mark_failed()
Mark this component as failed.
void status_set_warning()
void set_timeout(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a const char* 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.
ESPHOME_LOG_TAG(TAG, "sdp3x.sensor")