1 /*
2  * Copyright (c) 2018 Alexander Wachter
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/kernel.h>
8 #include <zephyr/device.h>
9 #include <zephyr/drivers/sensor.h>
10 #include <zephyr/sys/printk.h>
11 
main(void)12 int main(void)
13 {
14 	const struct device *dev;
15 	struct sensor_value co2, voc;
16 
17 	dev = DEVICE_DT_GET_ONE(ams_iaqcore);
18 	if (!device_is_ready(dev)) {
19 		printk("sensor: device not ready.\n");
20 		return 0;
21 	}
22 
23 	printk("device is %p, name is %s\n", dev, dev->name);
24 
25 	while (1) {
26 		sensor_sample_fetch(dev);
27 		sensor_channel_get(dev, SENSOR_CHAN_CO2, &co2);
28 		sensor_channel_get(dev, SENSOR_CHAN_VOC, &voc);
29 		printk("Co2: %d.%06dppm; VOC: %d.%06dppb\n",
30 			co2.val1, co2.val2,
31 			voc.val1, voc.val2);
32 
33 		k_sleep(K_MSEC(1000));
34 	}
35 	return 0;
36 }
37