1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys/shell/commands/sc_sht11.c

83 lines
2.0 KiB
C
Raw Normal View History

/**
* Shell commands for temperature and humidity sensor
*
* Copyright (C) 2013 INRIA.
*
2013-11-22 20:47:05 +01:00
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License. See the file LICENSE in the top level directory for more
* details.
*
* @ingroup shell_commands
* @{
* @file sc_sht11.c
* @brief provides shell commands to poll sht11 sensor
* @author Oliver Hahm <oliver.hahm@inria.fr>
* @}
*/
#include <stdio.h>
#include <stdint.h>
2012-11-06 00:55:05 +01:00
#include <stdlib.h>
#include <string.h>
2013-12-16 17:54:58 +01:00
#include "sht11.h"
#ifdef MODULE_SHT11
extern float sht11_temperature_offset;
void _get_humidity_handler(char *unused)
{
uint8_t success;
sht11_val_t sht11_val;
success = sht11_read_sensor(&sht11_val, HUMIDITY | TEMPERATURE);
if (!success) {
printf("Error reading SHT11\n");
}
else {
printf("Relative humidity: %5.2f%% / Temperature compensated humidity; %5.2f%%\n",
(double) sht11_val.relhum, (double) sht11_val.relhum_temp);
}
}
void _get_temperature_handler(char *unused)
{
uint8_t success;
sht11_val_t sht11_val;
success = sht11_read_sensor(&sht11_val, TEMPERATURE);
if (!success) {
printf("Error reading SHT11\n");
}
else {
2012-11-06 00:55:05 +01:00
printf("Temperature: %-6.2f°C\n", (double) sht11_val.temperature);
}
}
void _get_weather_handler(char *unused)
{
uint8_t success;
sht11_val_t sht11_val;
success = sht11_read_sensor(&sht11_val, HUMIDITY | TEMPERATURE);
if (!success) {
printf("Error reading SHT11\n");
}
else {
printf("Relative humidity: %5.2f%% / Temperature compensated humidity; %5.2f%% ",
(double) sht11_val.relhum, (double) sht11_val.relhum_temp);
2012-11-06 00:55:05 +01:00
printf("Temperature: %-6.2f°C\n", (double) sht11_val.temperature);
}
}
void _set_offset_handler(char *offset)
{
if (strlen(offset) == 6) {
puts("Usage: offset <OFFSET>");
}
else {
sht11_temperature_offset = atoi(offset + 7);
printf("Temperature offset set to %f\n", (double) sht11_temperature_offset);
}
}
#endif