[SCD30] Disable negative temperature offset (#4850)

This commit is contained in:
Ryan DeShone 2023-06-28 19:42:39 -04:00 committed by Jesse Hills
parent 321155eb40
commit c3ef12d580
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A
2 changed files with 16 additions and 8 deletions

View file

@ -42,14 +42,19 @@ void SCD30Component::setup() {
ESP_LOGD(TAG, "SCD30 Firmware v%0d.%02d", (uint16_t(raw_firmware_version[0]) >> 8), ESP_LOGD(TAG, "SCD30 Firmware v%0d.%02d", (uint16_t(raw_firmware_version[0]) >> 8),
uint16_t(raw_firmware_version[0] & 0xFF)); uint16_t(raw_firmware_version[0] & 0xFF));
if (this->temperature_offset_ != 0) { uint16_t temp_offset;
if (!this->write_command(SCD30_CMD_TEMPERATURE_OFFSET, (uint16_t) (temperature_offset_ * 100.0))) { if (this->temperature_offset_ > 0) {
temp_offset = (this->temperature_offset_ * 100);
} else {
temp_offset = 0;
}
if (!this->write_command(SCD30_CMD_TEMPERATURE_OFFSET, temp_offset)) {
ESP_LOGE(TAG, "Sensor SCD30 error setting temperature offset."); ESP_LOGE(TAG, "Sensor SCD30 error setting temperature offset.");
this->error_code_ = MEASUREMENT_INIT_FAILED; this->error_code_ = MEASUREMENT_INIT_FAILED;
this->mark_failed(); this->mark_failed();
return; return;
} }
}
#ifdef USE_ESP32 #ifdef USE_ESP32
// According ESP32 clock stretching is typically 30ms and up to 150ms "due to // According ESP32 clock stretching is typically 30ms and up to 150ms "due to
// internal calibration processes". The I2C peripheral only supports 13ms (at // internal calibration processes". The I2C peripheral only supports 13ms (at

View file

@ -68,7 +68,10 @@ CONFIG_SCHEMA = (
cv.int_range(min=0, max=0xFFFF, max_included=False), cv.int_range(min=0, max=0xFFFF, max_included=False),
), ),
cv.Optional(CONF_AMBIENT_PRESSURE_COMPENSATION, default=0): cv.pressure, cv.Optional(CONF_AMBIENT_PRESSURE_COMPENSATION, default=0): cv.pressure,
cv.Optional(CONF_TEMPERATURE_OFFSET): cv.temperature, cv.Optional(CONF_TEMPERATURE_OFFSET): cv.All(
cv.temperature,
cv.float_range(min=0, max=655.35),
),
cv.Optional(CONF_UPDATE_INTERVAL, default="60s"): cv.All( cv.Optional(CONF_UPDATE_INTERVAL, default="60s"): cv.All(
cv.positive_time_period_seconds, cv.positive_time_period_seconds,
cv.Range( cv.Range(