1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/driver_shtc1/main.c
steffen fa05cf0c5d Driver/shtc1: add saul integration
- add saul integration
- uncrustified
- SAUL/DRIVER tests
2019-12-16 15:29:04 +01:00

62 lines
1.4 KiB
C

/*
* Copyright (C) 2017 RWTH Aachen, Steffen Robertz, Josua Arndt
*
* 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 Test application for the SHTC1 temperature and humidity sensor
*
* @author Steffen Robertz <steffen.robertz@rwth-aachen.de>
* @author Josua Arndt <jarndt@ias.rwth-aachen.de>
* @author Michel Gerlach <michel.gerlach@haw-hamburg.de>
*
* @}
*/
#include <stdio.h>
#include <stdlib.h>
#include "shtc1.h"
#include "shtc1_params.h"
#include "xtimer.h"
#include "fmt.h"
int main(void)
{
shtc1_t dev;
int16_t temp;
uint16_t hum;
char str_temp[8];
char str_hum[8];
size_t len;
puts("SHTC1 test application\n");
if ((shtc1_init(&dev, &shtc1_params[0])) != SHTC1_OK) {
puts("can't initialize the sensor");
return -1;
}
puts("SHTC1 initialized\n");
while (1) {
if (shtc1_read(&dev, &hum, &temp) == SHTC1_OK) {
len = fmt_s16_dfp(str_temp, temp, -2);
str_temp[len] = '\0';
len = fmt_s16_dfp(str_hum, hum, -2);
str_hum[len] = '\0';
}
/* print values to STDIO */
printf("Temperature [°C]: %s\n", str_temp);
printf(" Humidity [%%rH]: %s\n", str_hum);
xtimer_sleep(2);
}
return 0;
}