diff --git a/tests/driver_sht3x/Makefile b/tests/driver_sht3x/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..117bcc408050ea865d701b166ae5215d806e60a8 --- /dev/null +++ b/tests/driver_sht3x/Makefile @@ -0,0 +1,5 @@ +include ../Makefile.tests_common + +USEMODULE += sht3x + +include $(RIOTBASE)/Makefile.include diff --git a/tests/driver_sht3x/README.md b/tests/driver_sht3x/README.md new file mode 100644 index 0000000000000000000000000000000000000000..21f5b3b1950d36b4e97f173608f09f810d24d61d --- /dev/null +++ b/tests/driver_sht3x/README.md @@ -0,0 +1,13 @@ +# Sensirion SHT30/SHT31/SHT35 Humidity and Temperature Sensors + +## About +This is a manual test application for the SHT3x driver. + +## Usage +This test application will initialize the sensor with the following parameters: + +- Periodic Measurement with 2 measurements per second +- High Repeatability + +After initialization, the sensor reads the temperature and humidity every second +and prints them to the STDOUT. diff --git a/tests/driver_sht3x/main.c b/tests/driver_sht3x/main.c new file mode 100644 index 0000000000000000000000000000000000000000..b2655ad930bd50bd79080f6f2680a32996ea8824 --- /dev/null +++ b/tests/driver_sht3x/main.c @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2018 Gunar Schorcht + * + * 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 + * @brief Test application for the Sensirion SHT30/SHT31/SHT35 device driver + * @author Gunar Schorcht <gunar@schorcht.net> + * @file + * @{ + * @} + */ + +#include <stdio.h> +#include <string.h> + +#include "xtimer.h" +#include "sht3x.h" +#include "sht3x_params.h" + +int main(void) +{ + sht3x_dev_t dev; + int res; + + puts("SHT3X test application\n"); + + printf("+------------Initializing------------+\n"); + + if ((res = sht3x_init(&dev, &sht3x_params[0])) != SHT3X_OK) { + puts("Initialization failed\n"); + return 1; + } + else { + puts("Initialization successful\n"); + } + + printf("\n+--------Starting Measurements--------+\n"); + + while (1) { + int16_t temp; + int16_t hum; + + if ((res = sht3x_read(&dev, &temp, &hum)) == SHT3X_OK) { + printf("Temperature [°C]: %d.%d\n" + "Relative Humidity [%%]: %d.%d\n" + "+-------------------------------------+\n", + temp / 100, temp % 100, + hum / 100, hum % 100); + } + else { + printf("Could not read data from sensor, error %d\n", res); + } + xtimer_usleep(1000000); + } + + return 0; +}