Skip to content
Permalink
Browse files

samples: sensor: ams_iAQcore: Implement sample for AMS iAQ-core

Sample code for AMS (Austria Micro Systems) Indoor Air Quality Sensor
reading VOC and equivalent CO2 values.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
  • Loading branch information...
alexanderwachter authored and MaureenHelm committed Oct 5, 2018
1 parent 3c70a38 commit f989f2d0f973d39209c59d7ebbb144bd210d4ef7
@@ -0,0 +1,11 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.13.1)

set(DTC_OVERLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/iaq_core.overlay")

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(iAQcore)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
@@ -0,0 +1,36 @@
.. _ams_iaqcore:

ams iAQcore Indoor air quality sensor
#####################################

Overview
********

This sample application demonstrates how to use the ams iAQcore sensor to
measure CO2 equivalent and VOC. The CO2 value is a predicted value derived from
VOC. The values are fetched and printed every second.

Building and Running
********************

This sample application uses the sensor connected to the i2c stated in the
iaq_core.overlay file.
Flash the binary to a board of choice with a sensor connected.
This sample can run on every board with i2c.
For example build for a nucleo_f446re board:

.. zephyr-app-commands::
:zephyr-app: samples/sensors/ams_iAQcore
:board: nucleo_f446re
:goals: build flash
:compact:

Sample Output
=============

.. code-block:: console

device is 0x20001a08, name is IAQ_CORE
Co2: 882.000000ppm; VOC: 244.000000ppb
Co2: 863.000000ppm; VOC: 239.000000ppb
Co2: 836.000000ppm; VOC: 232.000000ppb
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2018 Alexander Wachter
* SPDX-License-Identifier: Apache-2.0
*/

&arduino_i2c {
status = "ok";
clock-frequency = <I2C_BITRATE_STANDARD>;

iaqcore: iaqcore@5a {
compatible = "ams,iaqcore";
reg = <0x5a>;
label = "IAQ_CORE";
};
};
@@ -0,0 +1,3 @@
CONFIG_I2C=y
CONFIG_SENSOR=y
CONFIG_AMS_IAQ_CORE=y
@@ -0,0 +1,8 @@
sample:
description: Demonstration of the AMS iAQ-core Digital VOC Sensor driver
name: iAQcore sample
tests:
test:
harness: sensor
tags: samples
depends_on: i2c arduino_i2c
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2018 Alexander Wachter
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr.h>
#include <device.h>
#include <sensor.h>
#include <misc/printk.h>

void main(void)
{
struct device *dev;
struct sensor_value co2, voc;

dev = device_get_binding(DT_AMS_IAQCORE_0_LABEL);
if (!dev) {
printk("Failed to get device binding");
return;
}

printk("device is %p, name is %s\n", dev, dev->config->name);

while (1) {
sensor_sample_fetch(dev);
sensor_channel_get(dev, SENSOR_CHAN_CO2, &co2);
sensor_channel_get(dev, SENSOR_CHAN_VOC, &voc);
printk("Co2: %d.%06dppm; VOC: %d.%06dppb\n",
co2.val1, co2.val2,
voc.val1, voc.val2);

k_sleep(1000);
}
}

0 comments on commit f989f2d

Please sign in to comment.
You can’t perform that action at this time.