Improve example in SCD4X for ambient pressure compensation (#2645)

* Update scd4x.rst

* Update scd4x.rst

* Update scd4x.rst

* Improve calibration example
This commit is contained in:
Carlos Garcia Saura 2023-03-06 16:24:06 +01:00 committed by GitHub
parent bff961afc6
commit 6a90cd8cfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,14 +105,18 @@ As of April 2022 the average fresh air Co² concentration is 419 ppm.
value: 419 # outside average April 2022 value: 419 # outside average April 2022
id: my_scd41 id: my_scd41
value can be a template value can also be a template, for example to define a Home Assistant calibration service:
.. code-block:: yaml .. code-block:: yaml
on_...: api:
services:
- service: calibrate_co2_value
variables:
co2_ppm: int
then: then:
- scd4x._perform_forced_calibration_action: - scd4x.perform_forced_calibration:
value: !lambda "{ return 419 };" value: !lambda 'return co2_ppm;'
id: my_scd41 id: my_scd41
@ -129,39 +133,53 @@ This :ref:`action <config-action>` triggers a factory reset of the sensor. Calib
then: then:
- scd4x.factory_reset: my_scd41 - scd4x.factory_reset: my_scd41
Automation Pressure compensation
----------------- ---------------------
Ambient pressure compensation compensation can be changed from :ref:`lambdas <config-lambda>` A static ambient pressure value can be set with `ambient_pressure_compensation` or `altitude_compensation`. It can also be changed dynamically with :ref:`lambdas <config-lambda>` using `set_ambient_pressure_compensation(<mBar>)`, or by pointing `ambient_pressure_compensation_source` to a local pressure sensor.
Example with a local sensor
***************************
``set_ambient_pressure_compensation( <pressure in bar)`` Note: remember your pressure sensor needs to output in mBar
Example
*******
Note: that the pressure from bme280 is in hPa and must be converted to bar.
.. code-block:: yaml .. code-block:: yaml
sensor: sensor:
- platform: scd4x
id: scd41
i2c_id: bus_a
co2:
name: co2
id: co2
- platform: bme280 - platform: bme280
pressure: pressure:
name: "BME280-Pressure" name: "Ambient Pressure"
id: bme280_pressure id: bme_pressure
oversampling: 1x
on_value: - platform: scd4x
measurement_mode: low_power_periodic
ambient_pressure_compensation_source: bme_pressure
temperature_offset: 0
co2:
name: "CO2 level"
Example with a remote sensor
****************************
This example creates a service `set_ambient_pressure` that can be called from Home Assistant:
.. code-block:: yaml
api:
services:
- service: set_ambient_pressure
variables:
pressure_mbar: int
then: then:
- lambda: "id(scd41)->set_ambient_pressure_compensation(x / 1000.0);" - lambda: "id(my_scd41)->set_ambient_pressure_compensation(pressure_mbar);"
sensor:
- platform: scd4x
id: my_scd41
measurement_mode: low_power_periodic
temperature_offset: 0
co2:
name: "CO2 level"
See Also See Also