Improve gas_ceiling scaling

Represent int kΩ rather than raw Ω for easier values.
This commit is contained in:
Joshua Boniface 2024-06-11 01:42:39 -04:00
parent 3088a6393b
commit 350a04e2e3
2 changed files with 13 additions and 11 deletions

View File

@ -63,13 +63,15 @@ but can be done if desired.
The AQ (air quality) calculation from the BME680 requires a "maximum"/ceiling The AQ (air quality) calculation from the BME680 requires a "maximum"/ceiling
threshold for the gas resistance value in clean air after some operation threshold for the gas resistance value in clean air after some operation
time. The value defaults to 200,000 to provide an initial baseline, but time. The value defaults to 200 to provide an initial baseline, but
should be calibrated manually by: should be calibrated manually after setup as each sensor is different:
1. Turning on the Supersensor in a known-clean environment (e.g. a sealed 1. Turn on the Supersensor in a known-clean environment (e.g. a sealed clean
container in fresh air). container in fresh air).
2. Leave the sensor on for 4-6 hours to burn in the sensor. 2. Leave the sensor on for 4-6 hours to burn in.
3. Setting this to the maximum value of the Gas Resistance sensor. 3. Record the maximum Gas Resistance value (in Ω) and round up to the nearest
5,000-10,000 or so (e.g. 96,938 => 100,000).
4. Divide the rounded maximum Gas Resistance value by 1000 to get the kΩ value.
This value will then define what "100% air quality" represents, and the This value will then define what "100% air quality" represents, and the
Supersensor can then be moved to its normal operating location. Supersensor can then be moved to its normal operating location.

View File

@ -60,7 +60,7 @@ globals:
- id: gas_ceiling - id: gas_ceiling
type: int type: int
restore_value: yes restore_value: yes
initial_value: "200000" initial_value: "200"
- id: pir_hold_time - id: pir_hold_time
type: int type: int
@ -518,7 +518,7 @@ sensor:
lambda: |- lambda: |-
float ph_slope = 0.03; float ph_slope = 0.03;
float comp_gas = id(bme680_gas_resistance).state * pow(2.718281, (ph_slope * id(bme680_absolute_humidity).state)); float comp_gas = id(bme680_gas_resistance).state * pow(2.718281, (ph_slope * id(bme680_absolute_humidity).state));
float gas_ratio = pow((comp_gas / id(gas_ceiling)), 2); float gas_ratio = pow((comp_gas / (id(gas_ceiling) * 1000)), 2);
if (gas_ratio > 1) { if (gas_ratio > 1) {
gas_ratio = 1.0; gas_ratio = 1.0;
} }
@ -709,11 +709,11 @@ switch:
number: number:
- platform: template - platform: template
name: "Gas Ceiling" name: "Gas Ceiling (kΩ)"
id: gas_ceiling_setter id: gas_ceiling_setter
min_value: 25000 min_value: 25
max_value: 350000 max_value: 350
step: 1000 step: 1
lambda: |- lambda: |-
return id(gas_ceiling); return id(gas_ceiling);
set_action: set_action: