drivers: Renamed module sht11 to sht1x

The sensor family SHT10, SHT11 and SHT15 only differ in their accuracy (as in
calibration, not as in resolution). Thus, the same driver can be used for all.
The new driver name better reflects this fact.
This commit is contained in:
Marian Buschsieweke 2018-06-13 08:26:30 +02:00
parent 1c47f9074c
commit d208c224b0
No known key found for this signature in database
GPG Key ID: 61F64C6599B1539F
11 changed files with 151 additions and 144 deletions

View File

@ -6,8 +6,8 @@
* directory for more details. * directory for more details.
*/ */
#ifndef SHT11_BOARD_H #ifndef SHT1X_BOARD_H
#define SHT11_BOARD_H #define SHT1X_BOARD_H
/** /**
* @ingroup boards_common_msb-430 * @ingroup boards_common_msb-430
@ -32,18 +32,18 @@ extern "C" {
* DATA = P3B4 * DATA = P3B4
*/ */
#define SHT11_SCK_LOW P3OUT &= ~(BIT5); /**< serial clock line low */ #define SHT1X_SCK_LOW P3OUT &= ~(BIT5); /**< serial clock line low */
#define SHT11_SCK_HIGH P3OUT |= BIT5; /**< serial clock line high */ #define SHT1X_SCK_HIGH P3OUT |= BIT5; /**< serial clock line high */
#define SHT11_DATA (P3IN & BIT5) /**< read serial I/O */ #define SHT1X_DATA (P3IN & BIT5) /**< read serial I/O */
#define SHT11_DATA_LOW P3OUT &= ~(BIT5); /**< serial I/O line low */ #define SHT1X_DATA_LOW P3OUT &= ~(BIT5); /**< serial I/O line low */
#define SHT11_DATA_HIGH P3OUT |= BIT5; /**< serial I/O line high */ #define SHT1X_DATA_HIGH P3OUT |= BIT5; /**< serial I/O line high */
#define SHT11_DATA_IN P3DIR &= ~(BIT5); /**< serial I/O as input */ #define SHT1X_DATA_IN P3DIR &= ~(BIT5); /**< serial I/O as input */
#define SHT11_DATA_OUT P3DIR |= BIT5; /**< serial I/O as output */ #define SHT1X_DATA_OUT P3DIR |= BIT5; /**< serial I/O as output */
#define SHT11_INIT P3DIR |= BIT5; /* FIO1DIR |= BIT25; PINSEL3 &= ~(BIT14|BIT15 | BIT16|BIT17); */ #define SHT1X_INIT P3DIR |= BIT5; /* FIO1DIR |= BIT25; PINSEL3 &= ~(BIT14|BIT15 | BIT16|BIT17); */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /** @} */
#endif /* SHT11_BOARD_H */ #endif /* SHT1X_BOARD_H */

View File

@ -6,8 +6,8 @@
* directory for more details. * directory for more details.
*/ */
#ifndef SHT11_BOARD_H #ifndef SHT1X_BOARD_H
#define SHT11_BOARD_H #define SHT1X_BOARD_H
/** /**
* @ingroup boards_common_msba2 * @ingroup boards_common_msba2
@ -32,25 +32,25 @@ extern "C" {
#endif #endif
/* serial clock line low */ /* serial clock line low */
#define SHT11_SCK_LOW FIO1CLR = BIT25; #define SHT1X_SCK_LOW FIO1CLR = BIT25;
/* serial clock line high */ /* serial clock line high */
#define SHT11_SCK_HIGH FIO1SET = BIT25; #define SHT1X_SCK_HIGH FIO1SET = BIT25;
/* read serial I/O */ /* read serial I/O */
#define SHT11_DATA ((FIO1PIN & BIT26) != 0) #define SHT1X_DATA ((FIO1PIN & BIT26) != 0)
/* serial I/O line low */ /* serial I/O line low */
#define SHT11_DATA_LOW (FIO1CLR = BIT26); #define SHT1X_DATA_LOW (FIO1CLR = BIT26);
/* serial I/O line high */ /* serial I/O line high */
#define SHT11_DATA_HIGH (FIO1SET = BIT26); #define SHT1X_DATA_HIGH (FIO1SET = BIT26);
/* serial I/O as input */ /* serial I/O as input */
#define SHT11_DATA_IN (FIO1DIR &= ~BIT26) #define SHT1X_DATA_IN (FIO1DIR &= ~BIT26)
/* serial I/O as output */ /* serial I/O as output */
#define SHT11_DATA_OUT (FIO1DIR |= BIT26) #define SHT1X_DATA_OUT (FIO1DIR |= BIT26)
#define SHT11_INIT FIO1DIR |= BIT25; PINSEL3 &= ~(BIT14|BIT15 | BIT16|BIT17); #define SHT1X_INIT FIO1DIR |= BIT25; PINSEL3 &= ~(BIT14|BIT15 | BIT16|BIT17);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /** @} */
#endif /* SHT11_BOARD_H */ #endif /* SHT1X_BOARD_H */

View File

@ -302,7 +302,8 @@ ifneq (,$(filter servo,$(USEMODULE)))
FEATURES_REQUIRED += periph_pwm FEATURES_REQUIRED += periph_pwm
endif endif
ifneq (,$(filter sht11,$(USEMODULE))) ifneq (,$(filter sht1%,$(USEMODULE)))
USEMODULE += sht1x
USEMODULE += xtimer USEMODULE += xtimer
endif endif

View File

@ -7,19 +7,20 @@
*/ */
/** /**
* @defgroup drivers_sht11 SHT11 Humidity and Temperature Sensor * @defgroup drivers_sht1x SHT10/SHT11/SHT15 Humidity and Temperature Sensor
* @ingroup drivers_sensors * @ingroup drivers_sensors
* @brief Driver for Sensirion SHT11 Humidity and Temperature Sensor * @brief Driver for Sensirion SHT10/SHT11/SHT15 Humidity and Temperature
Sensor
* @{ * @{
* *
* @file * @file
* @brief SHT11 Device Driver * @brief SHT10/SHT11/SHT15 Device Driver
* *
* @author Freie Universität Berlin, Computer Systems & Telematics * @author Freie Universität Berlin, Computer Systems & Telematics
*/ */
#ifndef SHT11_H #ifndef SHT1X_H
#define SHT11_H #define SHT1X_H
#include <stdint.h> #include <stdint.h>
@ -27,22 +28,22 @@
extern "C" { extern "C" {
#endif #endif
#define SHT11_NO_ACK (0) /**< don't ack read in `read_byte` */ #define SHT1X_NO_ACK (0) /**< don't ack read in `read_byte` */
#define SHT11_ACK (1) /**< do acknowledge read in `read_byte` */ #define SHT1X_ACK (1) /**< do acknowledge read in `read_byte` */
/* adr command r/w */ /* adr command r/w */
#define SHT11_STATUS_REG_W (0x06) /**< will write to status register */ #define SHT1X_STATUS_REG_W (0x06) /**< will write to status register */
#define SHT11_STATUS_REG_R (0x07) /**< will read from status register */ #define SHT1X_STATUS_REG_R (0x07) /**< will read from status register */
#define SHT11_MEASURE_TEMP (0x03) /**< tell sensor to measure temperature */ #define SHT1X_MEASURE_TEMP (0x03) /**< tell sensor to measure temperature */
#define SHT11_MEASURE_HUMI (0x05) /**< tell sensor to measure humidity */ #define SHT1X_MEASURE_HUMI (0x05) /**< tell sensor to measure humidity */
#define SHT11_RESET (0x1E) /**< reset the sensor */ #define SHT1X_RESET (0x1E) /**< reset the sensor */
/** time to wait after toggling the data line */ /** time to wait after toggling the data line */
#define SHT11_DATA_WAIT (1) #define SHT1X_DATA_WAIT (1)
/** time to wait after toggling the clock line */ /** time to wait after toggling the clock line */
#define SHT11_CLK_WAIT (1) #define SHT1X_CLK_WAIT (1)
/** set measurement timeout to 1 second */ /** set measurement timeout to 1 second */
#define SHT11_MEASURE_TIMEOUT (1000) #define SHT1X_MEASURE_TIMEOUT (1000)
/** /**
* @brief sht11 measureable data * @brief sht11 measureable data
@ -51,7 +52,7 @@ typedef struct {
float temperature; /**< temperature value */ float temperature; /**< temperature value */
float relhum; /**< linear relative humidity */ float relhum; /**< linear relative humidity */
float relhum_temp; /**< temperature compensated relative humidity */ float relhum_temp; /**< temperature compensated relative humidity */
} sht11_val_t; } sht1x_val_t;
/** /**
* @brief SHT11 modes that can be measured * @brief SHT11 modes that can be measured
@ -59,12 +60,12 @@ typedef struct {
typedef enum { typedef enum {
TEMPERATURE = 1, TEMPERATURE = 1,
HUMIDITY = 2 HUMIDITY = 2
} sht11_mode_t; } sht1x_mode_t;
/** /**
* @brief Initialize SHT11 ports * @brief Initialize SHT11 ports
*/ */
void sht11_init(void); void sht1x_init(void);
/** /**
* @brief Read sensor * @brief Read sensor
@ -75,11 +76,11 @@ void sht11_init(void);
* @return 1 on success, 0 otherwise * @return 1 on success, 0 otherwise
* *
* Example: * Example:
* \code sht11_val sht11; * \code sht1x_val sht11;
* sht11_read_sensor(&sht11, HUMIDITY|TEMPERATURE); * sht1x_read_sensor(&sht11, HUMIDITY|TEMPERATURE);
* printf("%-6.2f °C %5.2f %% %5.2f %%\n", sht11.temperature, sht11.relhum, sht11.relhum_temp); \endcode * printf("%-6.2f °C %5.2f %% %5.2f %%\n", sht11.temperature, sht11.relhum, sht11.relhum_temp); \endcode
*/ */
uint8_t sht11_read_sensor(sht11_val_t *value, sht11_mode_t mode); uint8_t sht1x_read_sensor(sht1x_val_t *value, sht1x_mode_t mode);
/** /**
* @brief Write status register * @brief Write status register
@ -88,7 +89,7 @@ uint8_t sht11_read_sensor(sht11_val_t *value, sht11_mode_t mode);
* *
* @return 1 on success, 0 otherwise * @return 1 on success, 0 otherwise
*/ */
uint8_t sht11_write_status(uint8_t *p_value); uint8_t sht1x_write_status(uint8_t *p_value);
/** /**
* @brief Read status register with checksum * @brief Read status register with checksum
@ -98,11 +99,11 @@ uint8_t sht11_write_status(uint8_t *p_value);
* *
* return 1 on success, 0 otherwise * return 1 on success, 0 otherwise
*/ */
uint8_t sht11_read_status(uint8_t *p_value, uint8_t *p_checksum); uint8_t sht1x_read_status(uint8_t *p_value, uint8_t *p_checksum);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* SHT11_H */ #endif /* SHT1X_H */
/** @} */ /** @} */

View File

@ -7,7 +7,7 @@
*/ */
/** /**
* @ingroup drivers_sht11 * @ingroup drivers_sht1x
* @brief Driver for the Sensirion SHT11 humidity and temperature sensor * @brief Driver for the Sensirion SHT11 humidity and temperature sensor
* @{ * @{
* *
@ -16,7 +16,7 @@
* *
* @version $Revision: 2396 $ * @version $Revision: 2396 $
* *
* @note $Id: sht11.c 2396 2010-07-06 15:12:35Z ziegert $ * @note $Id: sht1x.c 2396 2010-07-06 15:12:35Z ziegert $
* @} * @}
*/ */
@ -25,11 +25,11 @@
#include "xtimer.h" #include "xtimer.h"
#include "mutex.h" #include "mutex.h"
#include "sht11.h" #include "sht1x.h"
#include "sht11-board.h" #include "sht1x-board.h"
#include "bitarithm.h" #include "bitarithm.h"
float sht11_temperature_offset; float sht1x_temperature_offset;
/** /**
* @brief Perform measurement * @brief Perform measurement
@ -76,15 +76,15 @@ static void transmission_start(void);
static inline void clk_signal(void); static inline void clk_signal(void);
/* mutex for exclusive measurement operation */ /* mutex for exclusive measurement operation */
mutex_t sht11_mutex = MUTEX_INIT; mutex_t sht1x_mutex = MUTEX_INIT;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static inline void clk_signal(void) static inline void clk_signal(void)
{ {
SHT11_SCK_HIGH; SHT1X_SCK_HIGH;
xtimer_usleep(SHT11_CLK_WAIT); xtimer_usleep(SHT1X_CLK_WAIT);
SHT11_SCK_LOW; SHT1X_SCK_LOW;
xtimer_usleep(SHT11_CLK_WAIT); xtimer_usleep(SHT1X_CLK_WAIT);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -93,17 +93,17 @@ static uint8_t write_byte(uint8_t value)
uint8_t i; uint8_t i;
uint8_t ack; uint8_t ack;
SHT11_DATA_OUT; SHT1X_DATA_OUT;
/* send value bit by bit to sht11 */ /* send value bit by bit to sht11 */
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
if (value & BIT7) { if (value & BIT7) {
SHT11_DATA_HIGH; SHT1X_DATA_HIGH;
xtimer_usleep(SHT11_DATA_WAIT); xtimer_usleep(SHT1X_DATA_WAIT);
} }
else { else {
SHT11_DATA_LOW; SHT1X_DATA_LOW;
xtimer_usleep(SHT11_DATA_WAIT); xtimer_usleep(SHT1X_DATA_WAIT);
} }
/* trigger clock signal */ /* trigger clock signal */
@ -114,9 +114,9 @@ static uint8_t write_byte(uint8_t value)
} }
/* wait for ack */ /* wait for ack */
SHT11_DATA_IN; SHT1X_DATA_IN;
xtimer_usleep(SHT11_CLK_WAIT); xtimer_usleep(SHT1X_CLK_WAIT);
ack = SHT11_DATA; ack = SHT1X_DATA;
clk_signal(); clk_signal();
@ -128,40 +128,40 @@ static uint8_t read_byte(uint8_t ack)
uint8_t i; uint8_t i;
uint8_t value = 0; uint8_t value = 0;
SHT11_DATA_IN; SHT1X_DATA_IN;
xtimer_usleep(SHT11_DATA_WAIT); xtimer_usleep(SHT1X_DATA_WAIT);
/* read value bit by bit */ /* read value bit by bit */
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
value = value << 1; value = value << 1;
SHT11_SCK_HIGH; SHT1X_SCK_HIGH;
xtimer_usleep(SHT11_CLK_WAIT); xtimer_usleep(SHT1X_CLK_WAIT);
if (SHT11_DATA) { if (SHT1X_DATA) {
/* increase data by one when DATA is high */ /* increase data by one when DATA is high */
value++; value++;
} }
SHT11_SCK_LOW; SHT1X_SCK_LOW;
xtimer_usleep(SHT11_CLK_WAIT); xtimer_usleep(SHT1X_CLK_WAIT);
} }
/* send ack if necessary */ /* send ack if necessary */
SHT11_DATA_OUT; SHT1X_DATA_OUT;
if (ack) { if (ack) {
SHT11_DATA_LOW; SHT1X_DATA_LOW;
xtimer_usleep(SHT11_DATA_WAIT); xtimer_usleep(SHT1X_DATA_WAIT);
} }
else { else {
SHT11_DATA_HIGH; SHT1X_DATA_HIGH;
xtimer_usleep(SHT11_DATA_WAIT); xtimer_usleep(SHT1X_DATA_WAIT);
} }
clk_signal(); clk_signal();
/* release data line */ /* release data line */
SHT11_DATA_IN; SHT1X_DATA_IN;
return value; return value;
} }
@ -173,31 +173,31 @@ static void transmission_start(void)
___ ___ ___ ___
SCK : ___| |___| |______ SCK : ___| |___| |______
*/ */
SHT11_DATA_OUT; SHT1X_DATA_OUT;
/* set initial state */ /* set initial state */
SHT11_DATA_HIGH; SHT1X_DATA_HIGH;
xtimer_usleep(SHT11_DATA_WAIT); xtimer_usleep(SHT1X_DATA_WAIT);
SHT11_SCK_LOW; SHT1X_SCK_LOW;
xtimer_usleep(SHT11_CLK_WAIT); xtimer_usleep(SHT1X_CLK_WAIT);
SHT11_SCK_HIGH; SHT1X_SCK_HIGH;
xtimer_usleep(SHT11_CLK_WAIT); xtimer_usleep(SHT1X_CLK_WAIT);
SHT11_DATA_LOW; SHT1X_DATA_LOW;
xtimer_usleep(SHT11_DATA_WAIT); xtimer_usleep(SHT1X_DATA_WAIT);
SHT11_SCK_LOW; SHT1X_SCK_LOW;
xtimer_usleep(SHT11_CLK_WAIT); xtimer_usleep(SHT1X_CLK_WAIT);
SHT11_SCK_HIGH; SHT1X_SCK_HIGH;
xtimer_usleep(SHT11_CLK_WAIT); xtimer_usleep(SHT1X_CLK_WAIT);
SHT11_DATA_HIGH; SHT1X_DATA_HIGH;
xtimer_usleep(SHT11_DATA_WAIT); xtimer_usleep(SHT1X_DATA_WAIT);
SHT11_SCK_LOW; SHT1X_SCK_LOW;
xtimer_usleep(SHT11_CLK_WAIT); xtimer_usleep(SHT1X_CLK_WAIT);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void connection_reset(void) static void connection_reset(void)
@ -208,10 +208,10 @@ static void connection_reset(void)
SCK : __| |__| |__| |__| |__| |__| |__| |__| |__| |______| |___| |__ SCK : __| |__| |__| |__| |__| |__| |__| |__| |__| |______| |___| |__
*/ */
uint8_t i; uint8_t i;
SHT11_DATA_HIGH; SHT1X_DATA_HIGH;
xtimer_usleep(SHT11_DATA_WAIT); xtimer_usleep(SHT1X_DATA_WAIT);
SHT11_SCK_LOW; SHT1X_SCK_LOW;
xtimer_usleep(SHT11_CLK_WAIT); xtimer_usleep(SHT1X_CLK_WAIT);
for (i = 0; i < 9; i++) { for (i = 0; i < 9; i++) {
clk_signal(); clk_signal();
@ -232,8 +232,8 @@ static uint8_t measure(uint8_t *p_value, uint8_t *p_checksum, uint8_t mode)
xtimer_usleep(1000); xtimer_usleep(1000);
/* wait untile sensor has finished measurement or timeout */ /* wait untile sensor has finished measurement or timeout */
for (i = 0; (i < SHT11_MEASURE_TIMEOUT) && (!error); i++) { for (i = 0; (i < SHT1X_MEASURE_TIMEOUT) && (!error); i++) {
ack = SHT11_DATA; ack = SHT1X_DATA;
if (!ack) { if (!ack) {
break; break;
@ -245,44 +245,44 @@ static uint8_t measure(uint8_t *p_value, uint8_t *p_checksum, uint8_t mode)
error += ack; error += ack;
/* read MSB */ /* read MSB */
*(p_value + 1) = read_byte(SHT11_ACK); *(p_value + 1) = read_byte(SHT1X_ACK);
/* read LSB */ /* read LSB */
*(p_value) = read_byte(SHT11_ACK); *(p_value) = read_byte(SHT1X_ACK);
/* read checksum */ /* read checksum */
*p_checksum = read_byte(SHT11_NO_ACK); *p_checksum = read_byte(SHT1X_NO_ACK);
return (!error); return (!error);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void sht11_init(void) void sht1x_init(void)
{ {
sht11_temperature_offset = 0; sht1x_temperature_offset = 0;
SHT11_INIT; SHT1X_INIT;
xtimer_usleep(11 * 1000); xtimer_usleep(11 * 1000);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
uint8_t sht11_read_status(uint8_t *p_value, uint8_t *p_checksum) uint8_t sht1x_read_status(uint8_t *p_value, uint8_t *p_checksum)
{ {
uint8_t error = 0; uint8_t error = 0;
transmission_start(); transmission_start();
error |= write_byte(SHT11_STATUS_REG_R); error |= write_byte(SHT1X_STATUS_REG_R);
*p_value = read_byte(SHT11_ACK); *p_value = read_byte(SHT1X_ACK);
*p_checksum = read_byte(SHT11_NO_ACK); *p_checksum = read_byte(SHT1X_NO_ACK);
return (!error); return (!error);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
uint8_t sht11_write_status(uint8_t *p_value) uint8_t sht1x_write_status(uint8_t *p_value)
{ {
uint8_t error = 0; uint8_t error = 0;
transmission_start(); transmission_start();
error += write_byte(SHT11_STATUS_REG_W); error += write_byte(SHT1X_STATUS_REG_W);
error += write_byte(*p_value); error += write_byte(*p_value);
return (!error); return (!error);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
uint8_t sht11_read_sensor(sht11_val_t *value, sht11_mode_t mode) uint8_t sht1x_read_sensor(sht1x_val_t *value, sht1x_mode_t mode)
{ {
uint8_t error = 0; uint8_t error = 0;
uint8_t checksum; uint8_t checksum;
@ -313,28 +313,28 @@ uint8_t sht11_read_sensor(sht11_val_t *value, sht11_mode_t mode)
value->relhum = 0; value->relhum = 0;
value->relhum_temp = 0; value->relhum_temp = 0;
mutex_lock(&sht11_mutex); mutex_lock(&sht1x_mutex);
connection_reset(); connection_reset();
/* measure humidity */ /* measure humidity */
if (mode & HUMIDITY) { if (mode & HUMIDITY) {
error += (!measure((uint8_t *) &humi_int, &checksum, SHT11_MEASURE_HUMI)); error += (!measure((uint8_t *) &humi_int, &checksum, SHT1X_MEASURE_HUMI));
} }
/* measure temperature */ /* measure temperature */
if (mode & TEMPERATURE) { if (mode & TEMPERATURE) {
error += (!measure((uint8_t *) &temp_int, &checksum, SHT11_MEASURE_TEMP)); error += (!measure((uint8_t *) &temp_int, &checksum, SHT1X_MEASURE_TEMP));
} }
/* break on error */ /* break on error */
if (error != 0) { if (error != 0) {
connection_reset(); connection_reset();
mutex_unlock(&sht11_mutex); mutex_unlock(&sht1x_mutex);
return 0; return 0;
} }
if (mode & TEMPERATURE) { if (mode & TEMPERATURE) {
value->temperature = D1 + (D2 * ((float) temp_int)) + sht11_temperature_offset; value->temperature = D1 + (D2 * ((float) temp_int)) + sht1x_temperature_offset;
} }
if (mode & HUMIDITY) { if (mode & HUMIDITY) {
@ -345,6 +345,6 @@ uint8_t sht11_read_sensor(sht11_val_t *value, sht11_mode_t mode)
} }
} }
mutex_unlock(&sht11_mutex); mutex_unlock(&sht1x_mutex);
return 1; return 1;
} }

View File

@ -95,6 +95,11 @@ PSEUDOMODULES += adc121c
PSEUDOMODULES += sx1272 PSEUDOMODULES += sx1272
PSEUDOMODULES += sx1276 PSEUDOMODULES += sx1276
# include variants of SHT1X drivers as pseudo modules
PSEUDOMODULES += sht10
PSEUDOMODULES += sht11
PSEUDOMODULES += sht15
# include variants of Si114x drivers as pseudo modules # include variants of Si114x drivers as pseudo modules
PSEUDOMODULES += si1145 PSEUDOMODULES += si1145
PSEUDOMODULES += si1146 PSEUDOMODULES += si1146

View File

@ -20,8 +20,8 @@
#include "auto_init.h" #include "auto_init.h"
#ifdef MODULE_SHT11 #ifdef MODULE_SHT1X
#include "sht11.h" #include "sht1x.h"
#endif #endif
#ifdef MODULE_MCI #ifdef MODULE_MCI
@ -101,9 +101,9 @@ void auto_init(void)
DEBUG("Auto init xtimer module.\n"); DEBUG("Auto init xtimer module.\n");
xtimer_init(); xtimer_init();
#endif #endif
#ifdef MODULE_SHT11 #ifdef MODULE_SHT1X
DEBUG("Auto init SHT11 module.\n"); DEBUG("Auto init SHT1X module.\n");
sht11_init(); sht1x_init();
#endif #endif
#ifdef MODULE_MCI #ifdef MODULE_MCI
DEBUG("Auto init mci module.\n"); DEBUG("Auto init mci module.\n");

View File

@ -8,8 +8,8 @@ endif
ifneq (,$(filter ps,$(USEMODULE))) ifneq (,$(filter ps,$(USEMODULE)))
SRC += sc_ps.c SRC += sc_ps.c
endif endif
ifneq (,$(filter sht11,$(USEMODULE))) ifneq (,$(filter sht1x,$(USEMODULE)))
SRC += sc_sht11.c SRC += sc_sht1x.c
endif endif
ifneq (,$(filter lpc2387,$(USEMODULE))) ifneq (,$(filter lpc2387,$(USEMODULE)))
SRC += sc_heap.c SRC += sc_heap.c

View File

@ -22,11 +22,11 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "sht11.h" #include "sht1x.h"
#ifdef MODULE_SHT11 #ifdef MODULE_SHT1X
extern float sht11_temperature_offset; extern float sht1x_temperature_offset;
int _get_humidity_handler(int argc, char **argv) int _get_humidity_handler(int argc, char **argv)
{ {
@ -34,8 +34,8 @@ int _get_humidity_handler(int argc, char **argv)
(void) argv; (void) argv;
uint8_t success; uint8_t success;
sht11_val_t sht11_val; sht1x_val_t sht1x_val;
success = sht11_read_sensor(&sht11_val, HUMIDITY | TEMPERATURE); success = sht1x_read_sensor(&sht1x_val, HUMIDITY | TEMPERATURE);
if (!success) { if (!success) {
printf("Error reading SHT11\n"); printf("Error reading SHT11\n");
@ -44,7 +44,7 @@ int _get_humidity_handler(int argc, char **argv)
} }
else { else {
printf("Relative humidity: %5.2f%% / Temperature compensated humidity; %5.2f%%\n", printf("Relative humidity: %5.2f%% / Temperature compensated humidity; %5.2f%%\n",
(double) sht11_val.relhum, (double) sht11_val.relhum_temp); (double) sht1x_val.relhum, (double) sht1x_val.relhum_temp);
return 0; return 0;
} }
@ -56,8 +56,8 @@ int _get_temperature_handler(int argc, char **argv)
(void) argv; (void) argv;
uint8_t success; uint8_t success;
sht11_val_t sht11_val; sht1x_val_t sht1x_val;
success = sht11_read_sensor(&sht11_val, TEMPERATURE); success = sht1x_read_sensor(&sht1x_val, TEMPERATURE);
if (!success) { if (!success) {
printf("Error reading SHT11\n"); printf("Error reading SHT11\n");
@ -65,7 +65,7 @@ int _get_temperature_handler(int argc, char **argv)
return 1; return 1;
} }
else { else {
printf("Temperature: %-6.2f°C\n", (double) sht11_val.temperature); printf("Temperature: %-6.2f°C\n", (double) sht1x_val.temperature);
return 0; return 0;
} }
@ -77,8 +77,8 @@ int _get_weather_handler(int argc, char **argv)
(void) argv; (void) argv;
uint8_t success; uint8_t success;
sht11_val_t sht11_val; sht1x_val_t sht1x_val;
success = sht11_read_sensor(&sht11_val, HUMIDITY | TEMPERATURE); success = sht1x_read_sensor(&sht1x_val, HUMIDITY | TEMPERATURE);
if (!success) { if (!success) {
printf("Error reading SHT11\n"); printf("Error reading SHT11\n");
@ -87,8 +87,8 @@ int _get_weather_handler(int argc, char **argv)
} }
else { else {
printf("Relative humidity: %5.2f%% / Temperature compensated humidity; %5.2f%% ", printf("Relative humidity: %5.2f%% / Temperature compensated humidity; %5.2f%% ",
(double) sht11_val.relhum, (double) sht11_val.relhum_temp); (double) sht1x_val.relhum, (double) sht1x_val.relhum_temp);
printf("Temperature: %-6.2f°C\n", (double) sht11_val.temperature); printf("Temperature: %-6.2f°C\n", (double) sht1x_val.temperature);
return 0; return 0;
} }
@ -102,8 +102,8 @@ int _set_offset_handler(int argc, char **argv)
return 1; return 1;
} }
else { else {
sht11_temperature_offset = atoi(argv[1]); sht1x_temperature_offset = atoi(argv[1]);
printf("Temperature offset set to %f\n", (double) sht11_temperature_offset); printf("Temperature offset set to %f\n", (double) sht1x_temperature_offset);
return 0; return 0;
} }

View File

@ -37,7 +37,7 @@ extern int _heap_handler(int argc, char **argv);
extern int _ps_handler(int argc, char **argv); extern int _ps_handler(int argc, char **argv);
#endif #endif
#ifdef MODULE_SHT11 #ifdef MODULE_SHT1X
extern int _get_temperature_handler(int argc, char **argv); extern int _get_temperature_handler(int argc, char **argv);
extern int _get_humidity_handler(int argc, char **argv); extern int _get_humidity_handler(int argc, char **argv);
extern int _get_weather_handler(int argc, char **argv); extern int _get_weather_handler(int argc, char **argv);
@ -153,7 +153,7 @@ const shell_command_t _shell_command_list[] = {
#ifdef MODULE_PS #ifdef MODULE_PS
{"ps", "Prints information about running threads.", _ps_handler}, {"ps", "Prints information about running threads.", _ps_handler},
#endif #endif
#ifdef MODULE_SHT11 #ifdef MODULE_SHT1X
{"temp", "Prints measured temperature.", _get_temperature_handler}, {"temp", "Prints measured temperature.", _get_temperature_handler},
{"hum", "Prints measured humidity.", _get_humidity_handler}, {"hum", "Prints measured humidity.", _get_humidity_handler},
{"weather", "Prints measured humidity and temperature.", _get_weather_handler}, {"weather", "Prints measured humidity and temperature.", _get_weather_handler},