tests/driver_sgp30: initial import
This commit is contained in:
parent
478624cbb6
commit
6c4cb07a2f
7
tests/driver_sgp30/Makefile
Normal file
7
tests/driver_sgp30/Makefile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
include ../Makefile.tests_common
|
||||||
|
|
||||||
|
USEMODULE += sgp30
|
||||||
|
|
||||||
|
# DISABLE_MODULE += sgp30_strict
|
||||||
|
|
||||||
|
include $(RIOTBASE)/Makefile.include
|
||||||
17
tests/driver_sgp30/README.md
Normal file
17
tests/driver_sgp30/README.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
driver_sgp30
|
||||||
|
============
|
||||||
|
|
||||||
|
This is a manual test application for the SGP30 driver. It shows how the
|
||||||
|
sensor can be used for periodic polling.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
=====
|
||||||
|
|
||||||
|
The test application demonstrates the use of the SGP30. By default the
|
||||||
|
`sgp30_strict` module is used, which means that periodic readings are
|
||||||
|
issued every 1s, and a warm-up period of 15s is enforced, before this
|
||||||
|
`sgp30_read_measurements` returns with `-EAGAIN`.
|
||||||
|
|
||||||
|
`sgp30_strict` can be disabled by compiling with `DISABLE_MODULE=sgp30_strict`.
|
||||||
|
With this when `sgp30_read_measurements` is called during the first 15s
|
||||||
|
constant values of 400ppm CO2eq and 0ppb TVOC.
|
||||||
3
tests/driver_sgp30/app.config.test
Normal file
3
tests/driver_sgp30/app.config.test
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# this file enables modules defined in Kconfig. Do not use this file for
|
||||||
|
# application configuration. This is only needed during migration.
|
||||||
|
CONFIG_MODULE_SGP30=y
|
||||||
63
tests/driver_sgp30/main.c
Normal file
63
tests/driver_sgp30/main.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 Inria
|
||||||
|
*
|
||||||
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
* directory for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup tests
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @brief SGP30 driver test application
|
||||||
|
*
|
||||||
|
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||||
|
*
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "sgp30.h"
|
||||||
|
#include "sgp30_params.h"
|
||||||
|
|
||||||
|
#include "ztimer.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
sgp30_t sensor;
|
||||||
|
|
||||||
|
puts("SGP30 test application\n");
|
||||||
|
|
||||||
|
printf("+------------Initializing------------+\n");
|
||||||
|
|
||||||
|
/* initialize the sensor with default configuration parameters */
|
||||||
|
if (sgp30_init(&sensor, &sgp30_params[0]) != 0) {
|
||||||
|
puts("Initialization failed\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n+--------Starting Measurements--------+\n");
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
sgp30_data_t data;
|
||||||
|
|
||||||
|
/* read the data and print them on success */
|
||||||
|
int ret = sgp30_read_measurements(&sensor, &data);
|
||||||
|
if (ret == 0) {
|
||||||
|
printf("TVOC [ppb]: %d\neCO2 [ppm]: %d\n", data.tvoc, data.eco2);
|
||||||
|
puts("+-------------------------------------+");
|
||||||
|
}
|
||||||
|
else if (ret == -EAGAIN) {
|
||||||
|
printf("Device is not yet ready\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("Could not read data from sensor\n");
|
||||||
|
}
|
||||||
|
ztimer_sleep(ZTIMER_USEC, 100000LU);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user