7static const char *
const TAG =
"ufire_ec";
10 ESP_LOGCONFIG(TAG,
"Setting up uFire_ec...");
13 if (!this->
read_byte(REGISTER_VERSION, &version) && version != 0xFF) {
17 ESP_LOGI(TAG,
"Found ufire_ec board version 0x%02X", version);
21 this->
read_byte(REGISTER_CONFIG, &config);
23 config &= ~CONFIG_TEMP_COMPENSATION;
25 config |= CONFIG_TEMP_COMPENSATION;
38 this->
write_byte(REGISTER_TASK, COMMAND_MEASURE_TEMP);
45 this->
write_byte(REGISTER_TASK, COMMAND_MEASURE_EC);
78 this->
write_byte(REGISTER_TASK, COMMAND_CALIBRATE_PROBE);
90 for (uint8_t i = 0; i < 4; i++) {
93 memcpy(&f, temp,
sizeof(f));
101 memcpy(temp, &data,
sizeof(data));
107 ESP_LOGCONFIG(TAG,
"uFire-EC");
109 LOG_UPDATE_INTERVAL(
this)
110 LOG_SENSOR(
" ",
"EC Sensor", this->
ec_sensor_)
virtual void mark_failed()
Mark this component as failed.
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len, bool stop=true)
ErrorCode write(const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a device using an I2CBus
optional< std::array< uint8_t, N > > read_bytes_raw()
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
void publish_state(float state)
Publish a new state to the front-end.
float state
This member variable stores the last state that has passed through all filters.
void dump_config() override
float measure_temperature_()
float temperature_compensation_
sensor::Sensor * ec_sensor_
void set_compensation_(float temperature)
void calibrate_probe(float solution, float temperature)
float read_data_(uint8_t reg)
sensor::Sensor * temperature_sensor_external_
float temperature_coefficient_
void set_temperature_(float temperature)
void write_data_(uint8_t reg, float data)
void set_solution_(float solution, float temperature)
sensor::Sensor * temperature_sensor_
void set_coefficient_(float coefficient)
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delay(uint32_t ms)