From 350a04e2e3bf74f4965b9dc6ca9b90d203cb80b2 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Tue, 11 Jun 2024 01:42:39 -0400 Subject: [PATCH] Improve gas_ceiling scaling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Represent int kΩ rather than raw Ω for easier values. --- README.md | 12 +++++++----- supersensor.yaml | 12 ++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 7871d57..5aaec0b 100644 --- a/README.md +++ b/README.md @@ -63,13 +63,15 @@ but can be done if desired. The AQ (air quality) calculation from the BME680 requires a "maximum"/ceiling 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 -should be calibrated manually by: +time. The value defaults to 200 kΩ to provide an initial baseline, but +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). -2. Leave the sensor on for 4-6 hours to burn in the sensor. -3. Setting this to the maximum value of the Gas Resistance sensor. +2. Leave the sensor on for 4-6 hours to burn in. +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 Supersensor can then be moved to its normal operating location. diff --git a/supersensor.yaml b/supersensor.yaml index 30d59d2..c9fbe55 100644 --- a/supersensor.yaml +++ b/supersensor.yaml @@ -60,7 +60,7 @@ globals: - id: gas_ceiling type: int restore_value: yes - initial_value: "200000" + initial_value: "200" - id: pir_hold_time type: int @@ -518,7 +518,7 @@ sensor: lambda: |- float ph_slope = 0.03; 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) { gas_ratio = 1.0; } @@ -709,11 +709,11 @@ switch: number: - platform: template - name: "Gas Ceiling" + name: "Gas Ceiling (kΩ)" id: gas_ceiling_setter - min_value: 25000 - max_value: 350000 - step: 1000 + min_value: 25 + max_value: 350 + step: 1 lambda: |- return id(gas_ceiling); set_action: