7static const uint8_t PMWCS3_I2C_ADDRESS = 0x63;
8static const uint8_t PMWCS3_REG_READ_START = 0x01;
9static const uint8_t PMWCS3_REG_READ_E25 = 0x02;
10static const uint8_t PMWCS3_REG_READ_EC = 0x03;
11static const uint8_t PMWCS3_REG_READ_TEMP = 0x04;
12static const uint8_t PMWCS3_REG_READ_VWC = 0x05;
13static const uint8_t PMWCS3_REG_CALIBRATE_AIR = 0x06;
14static const uint8_t PMWCS3_REG_CALIBRATE_WATER = 0x07;
15static const uint8_t PMWCS3_SET_I2C_ADDRESS = 0x08;
16static const uint8_t PMWCS3_REG_GET_DATA = 0x09;
17static const uint8_t PMWCS3_REG_CALIBRATE_EC = 0x10;
18static const uint8_t PMWCS3_REG_CAP = 0x0A;
19static const uint8_t PMWCS3_REG_RES = 0x0B;
20static const uint8_t PMWCS3_REG_RC = 0x0C;
21static const uint8_t PMWCS3_REG_RT = 0x0D;
28 ESP_LOGW(TAG,
"Setting I2C address failed (%d)",
address);
32 ESP_LOGVV(TAG,
"Set I2C address to %d",
address);
37 if (!this->
write_bytes(PMWCS3_REG_CALIBRATE_AIR,
nullptr, 0)) {
39 ESP_LOGW(TAG,
"Starting air calibration failed");
42 ESP_LOGW(TAG,
"Running air calibration for 300s");
45 if (!this->
write_bytes(PMWCS3_REG_CALIBRATE_WATER,
nullptr, 0)) {
47 ESP_LOGW(TAG,
"Starting water calibration failed");
50 ESP_LOGW(TAG,
"Running water calibration for 300s");
56 ESP_LOGCONFIG(TAG,
"PMWCS3");
58 LOG_UPDATE_INTERVAL(
this);
66 if (!this->
write_bytes(PMWCS3_REG_READ_START,
nullptr, 0)) {
68 ESP_LOGVV(TAG,
"Writing REG_READ_START failed");
78 ESP_LOGVV(TAG,
"Reading PMWCS3_REG_GET_DATA failed");
83 e25 = data[0] / 100.0;
85 ESP_LOGVV(TAG,
"e25: raw=%u, result=%f", data[0], e25);
90 ESP_LOGVV(TAG,
"ec: raw=%u, result=%f", data[1], ec);
93 temperature = data[2] / 100.0;
95 ESP_LOGVV(TAG,
"temp: raw=%u, result=%f", data[2],
temperature);
100 ESP_LOGVV(TAG,
"vwc: raw=%u, result=%f", data[3], vwc);
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()
bool read_bytes_16_le(uint8_t a_register, uint16_t *data, uint8_t len)
Read len 16-bit values stored least significant byte first; no conversion is compiled on little-endia...
bool write_byte(uint8_t a_register, uint8_t data) const
void set_i2c_address(uint8_t address)
We store the address of the device on the bus.
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len) const
sensor::Sensor * e25_sensor_
sensor::Sensor * ec_sensor_
sensor::Sensor * vwc_sensor_
sensor::Sensor * temperature_sensor_
void dump_config() override
void new_i2c_address(uint8_t newaddress)
void publish_state(float state)
Publish a new state to the front-end.
ESPHOME_LOG_TAG(TAG, "pmwcs3")