7 static 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_)
sensor::Sensor * temperature_sensor_
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
void calibrate_probe(float solution, float temperature)
void write_data_(uint8_t reg, float data)
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
optional< std::array< uint8_t, N > > read_bytes_raw()
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
float temperature_coefficient_
void set_temperature_(float temperature)
ErrorCode write(const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a device using an I2CBus
float state
This member variable stores the last state that has passed through all filters.
void set_solution_(float solution, float temperature)
sensor::Sensor * ec_sensor_
void publish_state(float state)
Publish a new state to the front-end.
float measure_temperature_()
float read_data_(uint8_t reg)
void set_coefficient_(float coefficient)
void set_compensation_(float temperature)
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
virtual void mark_failed()
Mark this component as failed.
sensor::Sensor * temperature_sensor_external_
Implementation of SPI Controller mode.
void dump_config() override
float temperature_compensation_
void IRAM_ATTR HOT delay(uint32_t ms)
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len, bool stop=true)