mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 09:18:00 +01:00
[SCD30] Disable negative temperature offset (#4850)
This commit is contained in:
parent
321155eb40
commit
c3ef12d580
2 changed files with 16 additions and 8 deletions
|
@ -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
|
||||||
|
|
|
@ -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(
|
||||||
|
|
Loading…
Reference in a new issue