9static const char *
const TAG =
"sdp3x.sensor";
10static const uint16_t SDP3X_SOFT_RESET = 0x0006;
11static const uint16_t SDP3X_READ_ID1 = 0x367C;
12static const uint16_t SDP3X_READ_ID2 = 0xE102;
13static const uint16_t SDP3X_START_DP_AVG = 0x3615;
14static const uint16_t SDP3X_START_MASS_FLOW_AVG = 0x3603;
15static const uint16_t SDP3X_STOP_MEAS = 0x3FF9;
21 ESP_LOGW(TAG,
"Stop failed");
25 ESP_LOGW(TAG,
"Soft Reset failed");
30 ESP_LOGE(TAG,
"Read ID1 failed");
35 ESP_LOGE(TAG,
"Read ID2 failed");
42 ESP_LOGE(TAG,
"Read ID failed");
50 if (data[1] >> 8 == 0x02) {
51 switch (data[1] & 0xFF) {
53 ESP_LOGCONFIG(TAG,
"Sensor is SDP800-500Pa");
56 ESP_LOGCONFIG(TAG,
"Sensor is SDP810-500Pa");
59 ESP_LOGCONFIG(TAG,
"Sensor is SDP801-500Pa");
62 ESP_LOGCONFIG(TAG,
"Sensor is SDP811-500Pa");
65 ESP_LOGCONFIG(TAG,
"Sensor is SDP800-125Pa");
68 ESP_LOGCONFIG(TAG,
"Sensor is SDP810-125Pa");
71 }
else if (data[1] >> 8 == 0x01) {
72 if ((data[1] & 0xFF) == 0x01) {
73 ESP_LOGCONFIG(TAG,
"Sensor is SDP31-500Pa");
74 }
else if ((data[1] & 0xFF) == 0x02) {
75 ESP_LOGCONFIG(TAG,
"Sensor is SDP32-125Pa");
80 ESP_LOGE(TAG,
"Start Measurements failed");
84 ESP_LOGCONFIG(TAG,
"started");
88 LOG_SENSOR(
" ",
"SDP3X",
this);
91 ESP_LOGE(TAG,
" Connection with failed");
93 LOG_UPDATE_INTERVAL(
this);
99 ESP_LOGW(TAG,
"Couldn't read data");
104 int16_t pressure_raw = data[0];
105 int16_t temperature_raw = data[1];
106 int16_t scale_factor_raw = data[2];
108 float pressure = pressure_raw / (scale_factor_raw * 100.0f);
109 ESP_LOGV(TAG,
"Got raw pressure=%d, raw scale factor =%d, raw temperature=%d ", pressure_raw, scale_factor_raw,
111 ESP_LOGD(TAG,
"Got Pressure=%.3f hPa",
pressure);
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message=nullptr)
void status_clear_warning()
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
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
float get_setup_priority() const 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.
const float DATA
For components that import data from directly connected sensors like DHT.
Providing packet encoding functions for exchanging data with a remote host.