Skip to content

Commit 1741dc0

Browse files
committed
app: sensor: add fetching data from ccs811 and hm3301
Add support for CCS811 air quality sensor and HM3301 particulate matter sensor to the fire detection system alongside existing BME280. Changes: - Add CCS811 (CO2/VOC) and HM3301 (PM1.0/2.5/10) sensor support - Configure devicetree overlay for multi-sensor I2C bus setup - Implement environmental compensation for CCS811 using BME280 data - Add configurable CCS811_ENV_COMPENSATION with smart threshold updates - Refactor main.c into modular functions for better maintainability - Enable required sensor drivers in project configuration The environmental compensation feature improves CCS811 accuracy by updating its internal registers with temperature and humidity from BME280, using a 0.5°C/0.5%RH threshold to minimize I2C traffic. Refs: #9 Signed-off-by: Natalia Pluta <pluta.natalia.m@gmail.com>
1 parent 3977398 commit 1741dc0

4 files changed

Lines changed: 312 additions & 35 deletions

File tree

app/Kconfig

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,36 @@ menu "Zephyr"
1010
source "Kconfig.zephyr"
1111
endmenu
1212

13+
menu "Application Configuration"
14+
15+
config CCS811_ENV_COMPENSATION
16+
bool "Enable environmental compensation for CCS811"
17+
default y
18+
depends on CCS811 && BME280
19+
help
20+
Enable updating CCS811 environmental data register with
21+
temperature and humidity values from BME280 sensor.
22+
This improves accuracy of CO2 and VOC measurements by
23+
compensating for environmental conditions.
24+
25+
config CCS811_DEFAULT_TEMPERATURE
26+
int "Fallback temperature for CCS811, Celsius"
27+
default 22
28+
depends on CCS811_ENV_COMPENSATION
29+
help
30+
Default temperature value to use for CCS811 environmental
31+
compensation when BME280 sensor is not available or fails.
32+
33+
config CCS811_DEFAULT_HUMIDITY
34+
int "Fallback humidity for CCS811, %RH"
35+
default 50
36+
depends on CCS811_ENV_COMPENSATION
37+
help
38+
Default humidity value to use for CCS811 environmental
39+
compensation when BME280 sensor is not available or fails.
40+
41+
endmenu
42+
1343
module = APP
1444
module-str = APP
1545
source "subsys/logging/Kconfig.template.log_config"

app/boards/nrf9160dk_nrf9160.overlay

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,27 @@
2525
pinctrl-0 = <&i2c2_default_alt>;
2626
pinctrl-1 = <&i2c2_sleep_alt>;
2727
pinctrl-names = "default", "sleep";
28+
2829
bme280: bme280@77 {
2930
compatible = "bosch,bme280";
3031
reg = <0x77>;
3132
status = "okay";
3233
};
34+
35+
ccs811: ccs811@5b {
36+
compatible = "ams,ccs811";
37+
reg = <0x5b>;
38+
status = "okay";
39+
reset-gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
40+
irq-gpios = <&gpio0 24 GPIO_ACTIVE_LOW>;
41+
wake-gpios = <&gpio0 25 GPIO_ACTIVE_LOW>;
42+
};
43+
44+
hm3301: hm3301@40 {
45+
compatible = "seeed,hm330x";
46+
reg = <0x40>;
47+
status = "okay";
48+
};
3349
};
3450

3551
/ {

app/prj.conf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
CONFIG_LOG=y
77
CONFIG_BLINK=y
88

9-
# Enable I2C and sensor subsystem for BME280
9+
# Enable I2C and sensor subsystem for multiple sensors
1010
CONFIG_I2C=y
1111
CONFIG_SENSOR=y
1212
CONFIG_BME280=y
13+
CONFIG_CCS811=y
14+
CONFIG_CCS811_ENV_COMPENSATION=y
15+
CONFIG_HM330X=y

0 commit comments

Comments
 (0)