10static constexpr uint32_t DATA_TIMEOUT_ID = 0;
14 if (!this->
read_byte(REGISTER_VERSION, &version) || version == 0xFF) {
18 ESP_LOGI(TAG,
"Found uFire_ise board version 0x%02X", version);
21 const bool compensate = this->temperature_sensor_ !=
nullptr || this->external_temperature_sensor_ !=
nullptr;
22 this->
update_register(REGISTER_CONFIG, CONFIG_TEMP_COMPENSATION, compensate ? CONFIG_TEMP_COMPENSATION : 0);
25void UFireISEComponent::update() {
27 if (this->temperature_sensor_ !=
nullptr) {
28 this->
write_byte(REGISTER_TASK, COMMAND_MEASURE_TEMP);
31 if (this->ph_sensor_ !=
nullptr) {
32 this->
write_byte(REGISTER_TASK, COMMAND_MEASURE_MV);
44 if (this->temperature_sensor_ !=
nullptr) {
46 this->temperature_sensor_->publish_state(
temperature);
49 else if (this->external_temperature_sensor_ !=
nullptr) {
50 temperature = this->external_temperature_sensor_->state;
53 PUBLISH_STATE(this->ph_sensor_, this->
measure_ph_(temperature));
67 ph = fabsf(7.0f - (mv / PROBE_MV_TO_PH));
70 float distance_from_7 = std::abs(7 - roundf(ph));
71 float distance_from_25 = std::floor(std::abs(25 - roundf(
temperature)) / 10);
72 float temp_multiplier = (distance_from_25 * distance_from_7) * PROBE_TMP_CORRECTION;
74 temp_multiplier *= -1;
76 temp_multiplier *= -1;
78 ph += temp_multiplier;
79 if ((ph <= 0.0f) || (ph > 14.0f))
90 solution = (7 - solution) * PROBE_MV_TO_PH;
94void UFireISEComponent::calibrate_probe_low(
float solution) {
96 this->
write_byte(REGISTER_TASK, COMMAND_CALIBRATE_LOW);
99void UFireISEComponent::calibrate_probe_high(
float solution) {
101 this->
write_byte(REGISTER_TASK, COMMAND_CALIBRATE_HIGH);
104void UFireISEComponent::reset_board() {
115 this->
write(®, 1);
118 for (uint8_t i = 0; i < 4; i++) {
121 memcpy(&f, temp,
sizeof(f));
129 memcpy(temp, &data,
sizeof(data));
134void UFireISEComponent::dump_config() {
135 ESP_LOGCONFIG(TAG,
"uFire-ISE");
137 LOG_UPDATE_INTERVAL(this);
138 LOG_SENSOR(" ", "PH Sensor", this->ph_sensor_);
139 LOG_SENSOR(" ", "Temperature Sensor", this->temperature_sensor_);
140 LOG_SENSOR(" ", "Temperature Sensor external", this->external_temperature_sensor_);
bool update_register(uint8_t a_register, uint8_t mask, uint8_t value)
Read a register, replace the bits in mask with those of value and write it back.