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;
23static const char *
const TAG =
"pmwcs3";
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");
59 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
61 LOG_UPDATE_INTERVAL(
this);
69 if (!this->
write_bytes(PMWCS3_REG_READ_START,
nullptr, 0)) {
71 ESP_LOGVV(TAG,
"Writing REG_READ_START failed");
80 if (!this->
read_bytes(PMWCS3_REG_GET_DATA, (uint8_t *) &data, 8)) {
81 ESP_LOGVV(TAG,
"Reading PMWCS3_REG_GET_DATA failed");
86 e25 = ((data[1] << 8) | data[0]) / 100.0;
88 ESP_LOGVV(TAG,
"e25: data[0]=%d, data[1]=%d, result=%f", data[0], data[1], e25);
91 ec = ((data[3] << 8) | data[2]) / 10.0;
93 ESP_LOGVV(TAG,
"ec: data[2]=%d, data[3]=%d, result=%f", data[2], data[3], ec);
96 temperature = ((data[5] << 8) | data[4]) / 100.0;
98 ESP_LOGVV(TAG,
"temp: data[4]=%d, data[5]=%d, result=%f", data[4], data[5],
temperature);
101 vwc = ((data[7] << 8) | data[6]) / 10.0;
103 ESP_LOGVV(TAG,
"vwc: data[6]=%d, data[7]=%d, result=%f", data[6], data[7], vwc);
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()
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
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
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.