mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 15:08:10 +01:00
[SCD30] Disable negative temperature offset (#4850)
This commit is contained in:
parent
ac5246e21d
commit
807621402d
2 changed files with 16 additions and 8 deletions
|
@ -42,13 +42,18 @@ void SCD30Component::setup() {
|
|||
ESP_LOGD(TAG, "SCD30 Firmware v%0d.%02d", (uint16_t(raw_firmware_version[0]) >> 8),
|
||||
uint16_t(raw_firmware_version[0] & 0xFF));
|
||||
|
||||
if (this->temperature_offset_ != 0) {
|
||||
if (!this->write_command(SCD30_CMD_TEMPERATURE_OFFSET, (uint16_t) (temperature_offset_ * 100.0))) {
|
||||
ESP_LOGE(TAG, "Sensor SCD30 error setting temperature offset.");
|
||||
this->error_code_ = MEASUREMENT_INIT_FAILED;
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
uint16_t temp_offset;
|
||||
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.");
|
||||
this->error_code_ = MEASUREMENT_INIT_FAILED;
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
#ifdef USE_ESP32
|
||||
// According ESP32 clock stretching is typically 30ms and up to 150ms "due to
|
||||
|
|
|
@ -68,7 +68,10 @@ CONFIG_SCHEMA = (
|
|||
cv.int_range(min=0, max=0xFFFF, max_included=False),
|
||||
),
|
||||
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.positive_time_period_seconds,
|
||||
cv.Range(
|
||||
|
|
Loading…
Reference in a new issue