7static constexpr uint16_t SDP3X_SOFT_RESET = 0x0006;
8static constexpr uint16_t SDP3X_READ_ID1 = 0x367C;
9static constexpr uint16_t SDP3X_READ_ID2 = 0xE102;
10static constexpr uint16_t SDP3X_STOP_MEAS = 0x3FF9;
12static constexpr uint32_t FIRST_READING_DELAY_MS = 10;
15static const LogString *model_name(uint16_t product_id) {
18 return LOG_STR(
"SDP31-500Pa");
20 return LOG_STR(
"SDP32-125Pa");
22 return LOG_STR(
"SDP800-500Pa");
24 return LOG_STR(
"SDP800-125Pa");
26 return LOG_STR(
"SDP801-500Pa");
28 return LOG_STR(
"SDP810-500Pa");
30 return LOG_STR(
"SDP810-125Pa");
32 return LOG_STR(
"SDP811-500Pa");
34 return LOG_STR(
"unknown");
56 LOG_SENSOR(
" ",
"SDP3X",
this);
61 LOG_UPDATE_INTERVAL(
this);
68 const auto pressure_raw =
static_cast<int16_t
>(data[0]);
69 const auto scale_factor =
static_cast<int16_t
>(data[2]);
71 const float pressure = pressure_raw / (scale_factor * 100.0f);
72 ESP_LOGV(TAG,
"Pressure %.3f hPa (raw %d, scale %d)",
pressure, pressure_raw, scale_factor);
void mark_failed()
Mark this component as failed.
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
void set_timeout(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a const char* name.
void dump_config() override
bool get_register(uint16_t command, uint16_t *data, uint8_t len, uint8_t delay=0)
get data words from I2C register.
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")