mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-03 19:38:30 +02:00
SCD30 Added support for manual calibration (#4362)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
@@ -202,5 +202,27 @@ bool SCD30Component::is_data_ready_() {
|
||||
return is_data_ready == 1;
|
||||
}
|
||||
|
||||
bool SCD30Component::force_recalibration_with_reference(uint16_t co2_reference) {
|
||||
ESP_LOGD(TAG, "Performing CO2 force recalibration with reference %dppm.", co2_reference);
|
||||
if (this->write_command(SCD30_CMD_FORCED_CALIBRATION, co2_reference)) {
|
||||
ESP_LOGD(TAG, "Force recalibration complete.");
|
||||
return true;
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to force recalibration with reference.");
|
||||
this->error_code_ = FORCE_RECALIBRATION_FAILED;
|
||||
this->status_set_warning();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t SCD30Component::get_forced_calibration_reference() {
|
||||
uint16_t forced_calibration_reference;
|
||||
// Get current CO2 calibration
|
||||
if (!this->get_register(SCD30_CMD_FORCED_CALIBRATION, forced_calibration_reference)) {
|
||||
ESP_LOGE(TAG, "Unable to read forced calibration reference.");
|
||||
}
|
||||
return forced_calibration_reference;
|
||||
}
|
||||
|
||||
} // namespace scd30
|
||||
} // namespace esphome
|
||||
|
||||
Reference in New Issue
Block a user