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
1 changed files with 49 additions and 31 deletions

View File

@ -105,15 +105,19 @@ As of April 2022 the average fresh air Co² concentration is 419 ppm.
value: 419 # outside average April 2022
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
on_...:
then:
- scd4x._perform_forced_calibration_action:
value: !lambda "{ return 419 };"
id: my_scd41
api:
services:
- service: calibrate_co2_value
variables:
co2_ppm: int
then:
- scd4x.perform_forced_calibration:
value: !lambda 'return co2_ppm;'
id: my_scd41
.. _factory_reset_action:
@ -129,39 +133,53 @@ This :ref:`action <config-action>` triggers a factory reset of the sensor. Calib
then:
- 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)``
Example
*******
Note: that the pressure from bme280 is in hPa and must be converted to bar.
Note: remember your pressure sensor needs to output in mBar
.. code-block:: yaml
sensor:
- platform: scd4x
id: scd41
i2c_id: bus_a
co2:
name: co2
id: co2
- platform: bme280
pressure:
name: "Ambient Pressure"
id: bme_pressure
- platform: bme280
pressure:
name: "BME280-Pressure"
id: bme280_pressure
oversampling: 1x
on_value:
then:
- lambda: "id(scd41)->set_ambient_pressure_compensation(x / 1000.0);"
- 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:
- 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