Skip to content
Snippets Groups Projects
Commit 00cb7863 authored by Schorcht's avatar Schorcht
Browse files

tests: add SHT3X sensor driver test application

parent d1fab308
No related branches found
No related tags found
No related merge requests found
include ../Makefile.tests_common
USEMODULE += sht3x
include $(RIOTBASE)/Makefile.include
# 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.
/*
* 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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment