mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
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:
parent
1c47f9074c
commit
d208c224b0
@ -6,8 +6,8 @@
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
#ifndef SHT11_BOARD_H
|
||||
#define SHT11_BOARD_H
|
||||
#ifndef SHT1X_BOARD_H
|
||||
#define SHT1X_BOARD_H
|
||||
|
||||
/**
|
||||
* @ingroup boards_common_msb-430
|
||||
@ -32,18 +32,18 @@ extern "C" {
|
||||
* DATA = P3B4
|
||||
*/
|
||||
|
||||
#define SHT11_SCK_LOW P3OUT &= ~(BIT5); /**< serial clock line low */
|
||||
#define SHT11_SCK_HIGH P3OUT |= BIT5; /**< serial clock line high */
|
||||
#define SHT11_DATA (P3IN & BIT5) /**< read serial I/O */
|
||||
#define SHT11_DATA_LOW P3OUT &= ~(BIT5); /**< serial I/O line low */
|
||||
#define SHT11_DATA_HIGH P3OUT |= BIT5; /**< serial I/O line high */
|
||||
#define SHT11_DATA_IN P3DIR &= ~(BIT5); /**< serial I/O as input */
|
||||
#define SHT11_DATA_OUT P3DIR |= BIT5; /**< serial I/O as output */
|
||||
#define SHT11_INIT P3DIR |= BIT5; /* FIO1DIR |= BIT25; PINSEL3 &= ~(BIT14|BIT15 | BIT16|BIT17); */
|
||||
#define SHT1X_SCK_LOW P3OUT &= ~(BIT5); /**< serial clock line low */
|
||||
#define SHT1X_SCK_HIGH P3OUT |= BIT5; /**< serial clock line high */
|
||||
#define SHT1X_DATA (P3IN & BIT5) /**< read serial I/O */
|
||||
#define SHT1X_DATA_LOW P3OUT &= ~(BIT5); /**< serial I/O line low */
|
||||
#define SHT1X_DATA_HIGH P3OUT |= BIT5; /**< serial I/O line high */
|
||||
#define SHT1X_DATA_IN P3DIR &= ~(BIT5); /**< serial I/O as input */
|
||||
#define SHT1X_DATA_OUT P3DIR |= BIT5; /**< serial I/O as output */
|
||||
#define SHT1X_INIT P3DIR |= BIT5; /* FIO1DIR |= BIT25; PINSEL3 &= ~(BIT14|BIT15 | BIT16|BIT17); */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif /* SHT11_BOARD_H */
|
||||
#endif /* SHT1X_BOARD_H */
|
@ -6,8 +6,8 @@
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
#ifndef SHT11_BOARD_H
|
||||
#define SHT11_BOARD_H
|
||||
#ifndef SHT1X_BOARD_H
|
||||
#define SHT1X_BOARD_H
|
||||
|
||||
/**
|
||||
* @ingroup boards_common_msba2
|
||||
@ -32,25 +32,25 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* serial clock line low */
|
||||
#define SHT11_SCK_LOW FIO1CLR = BIT25;
|
||||
#define SHT1X_SCK_LOW FIO1CLR = BIT25;
|
||||
/* serial clock line high */
|
||||
#define SHT11_SCK_HIGH FIO1SET = BIT25;
|
||||
#define SHT1X_SCK_HIGH FIO1SET = BIT25;
|
||||
/* read serial I/O */
|
||||
#define SHT11_DATA ((FIO1PIN & BIT26) != 0)
|
||||
#define SHT1X_DATA ((FIO1PIN & BIT26) != 0)
|
||||
/* serial I/O line low */
|
||||
#define SHT11_DATA_LOW (FIO1CLR = BIT26);
|
||||
#define SHT1X_DATA_LOW (FIO1CLR = BIT26);
|
||||
/* serial I/O line high */
|
||||
#define SHT11_DATA_HIGH (FIO1SET = BIT26);
|
||||
#define SHT1X_DATA_HIGH (FIO1SET = BIT26);
|
||||
/* serial I/O as input */
|
||||
#define SHT11_DATA_IN (FIO1DIR &= ~BIT26)
|
||||
#define SHT1X_DATA_IN (FIO1DIR &= ~BIT26)
|
||||
/* 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
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif /* SHT11_BOARD_H */
|
||||
#endif /* SHT1X_BOARD_H */
|
@ -302,7 +302,8 @@ ifneq (,$(filter servo,$(USEMODULE)))
|
||||
FEATURES_REQUIRED += periph_pwm
|
||||
endif
|
||||
|
||||
ifneq (,$(filter sht11,$(USEMODULE)))
|
||||
ifneq (,$(filter sht1%,$(USEMODULE)))
|
||||
USEMODULE += sht1x
|
||||
USEMODULE += xtimer
|
||||
endif
|
||||
|
||||
|
@ -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
|
||||
* @brief Driver for Sensirion SHT11 Humidity and Temperature Sensor
|
||||
* @brief Driver for Sensirion SHT10/SHT11/SHT15 Humidity and Temperature
|
||||
Sensor
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief SHT11 Device Driver
|
||||
* @brief SHT10/SHT11/SHT15 Device Driver
|
||||
*
|
||||
* @author Freie Universität Berlin, Computer Systems & Telematics
|
||||
*/
|
||||
|
||||
#ifndef SHT11_H
|
||||
#define SHT11_H
|
||||
#ifndef SHT1X_H
|
||||
#define SHT1X_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -27,22 +28,22 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SHT11_NO_ACK (0) /**< don't ack read in `read_byte` */
|
||||
#define SHT11_ACK (1) /**< do acknowledge read in `read_byte` */
|
||||
#define SHT1X_NO_ACK (0) /**< don't ack read in `read_byte` */
|
||||
#define SHT1X_ACK (1) /**< do acknowledge read in `read_byte` */
|
||||
/* adr command r/w */
|
||||
#define SHT11_STATUS_REG_W (0x06) /**< will write to status register */
|
||||
#define SHT11_STATUS_REG_R (0x07) /**< will read from status register */
|
||||
#define SHT11_MEASURE_TEMP (0x03) /**< tell sensor to measure temperature */
|
||||
#define SHT11_MEASURE_HUMI (0x05) /**< tell sensor to measure humidity */
|
||||
#define SHT11_RESET (0x1E) /**< reset the sensor */
|
||||
#define SHT1X_STATUS_REG_W (0x06) /**< will write to status register */
|
||||
#define SHT1X_STATUS_REG_R (0x07) /**< will read from status register */
|
||||
#define SHT1X_MEASURE_TEMP (0x03) /**< tell sensor to measure temperature */
|
||||
#define SHT1X_MEASURE_HUMI (0x05) /**< tell sensor to measure humidity */
|
||||
#define SHT1X_RESET (0x1E) /**< reset the sensor */
|
||||
|
||||
/** 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 */
|
||||
#define SHT11_CLK_WAIT (1)
|
||||
#define SHT1X_CLK_WAIT (1)
|
||||
|
||||
/** set measurement timeout to 1 second */
|
||||
#define SHT11_MEASURE_TIMEOUT (1000)
|
||||
#define SHT1X_MEASURE_TIMEOUT (1000)
|
||||
|
||||
/**
|
||||
* @brief sht11 measureable data
|
||||
@ -51,7 +52,7 @@ typedef struct {
|
||||
float temperature; /**< temperature value */
|
||||
float relhum; /**< linear relative humidity */
|
||||
float relhum_temp; /**< temperature compensated relative humidity */
|
||||
} sht11_val_t;
|
||||
} sht1x_val_t;
|
||||
|
||||
/**
|
||||
* @brief SHT11 modes that can be measured
|
||||
@ -59,12 +60,12 @@ typedef struct {
|
||||
typedef enum {
|
||||
TEMPERATURE = 1,
|
||||
HUMIDITY = 2
|
||||
} sht11_mode_t;
|
||||
} sht1x_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize SHT11 ports
|
||||
*/
|
||||
void sht11_init(void);
|
||||
void sht1x_init(void);
|
||||
|
||||
/**
|
||||
* @brief Read sensor
|
||||
@ -75,11 +76,11 @@ void sht11_init(void);
|
||||
* @return 1 on success, 0 otherwise
|
||||
*
|
||||
* Example:
|
||||
* \code sht11_val sht11;
|
||||
* sht11_read_sensor(&sht11, HUMIDITY|TEMPERATURE);
|
||||
* \code sht1x_val sht11;
|
||||
* sht1x_read_sensor(&sht11, HUMIDITY|TEMPERATURE);
|
||||
* 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
|
||||
@ -88,7 +89,7 @@ uint8_t sht11_read_sensor(sht11_val_t *value, sht11_mode_t mode);
|
||||
*
|
||||
* @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
|
||||
@ -98,11 +99,11 @@ uint8_t sht11_write_status(uint8_t *p_value);
|
||||
*
|
||||
* 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
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SHT11_H */
|
||||
#endif /* SHT1X_H */
|
||||
/** @} */
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup drivers_sht11
|
||||
* @ingroup drivers_sht1x
|
||||
* @brief Driver for the Sensirion SHT11 humidity and temperature sensor
|
||||
* @{
|
||||
*
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @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 "mutex.h"
|
||||
#include "sht11.h"
|
||||
#include "sht11-board.h"
|
||||
#include "sht1x.h"
|
||||
#include "sht1x-board.h"
|
||||
#include "bitarithm.h"
|
||||
|
||||
float sht11_temperature_offset;
|
||||
float sht1x_temperature_offset;
|
||||
|
||||
/**
|
||||
* @brief Perform measurement
|
||||
@ -76,15 +76,15 @@ static void transmission_start(void);
|
||||
static inline void clk_signal(void);
|
||||
|
||||
/* mutex for exclusive measurement operation */
|
||||
mutex_t sht11_mutex = MUTEX_INIT;
|
||||
mutex_t sht1x_mutex = MUTEX_INIT;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static inline void clk_signal(void)
|
||||
{
|
||||
SHT11_SCK_HIGH;
|
||||
xtimer_usleep(SHT11_CLK_WAIT);
|
||||
SHT11_SCK_LOW;
|
||||
xtimer_usleep(SHT11_CLK_WAIT);
|
||||
SHT1X_SCK_HIGH;
|
||||
xtimer_usleep(SHT1X_CLK_WAIT);
|
||||
SHT1X_SCK_LOW;
|
||||
xtimer_usleep(SHT1X_CLK_WAIT);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -93,17 +93,17 @@ static uint8_t write_byte(uint8_t value)
|
||||
uint8_t i;
|
||||
uint8_t ack;
|
||||
|
||||
SHT11_DATA_OUT;
|
||||
SHT1X_DATA_OUT;
|
||||
|
||||
/* send value bit by bit to sht11 */
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (value & BIT7) {
|
||||
SHT11_DATA_HIGH;
|
||||
xtimer_usleep(SHT11_DATA_WAIT);
|
||||
SHT1X_DATA_HIGH;
|
||||
xtimer_usleep(SHT1X_DATA_WAIT);
|
||||
}
|
||||
else {
|
||||
SHT11_DATA_LOW;
|
||||
xtimer_usleep(SHT11_DATA_WAIT);
|
||||
SHT1X_DATA_LOW;
|
||||
xtimer_usleep(SHT1X_DATA_WAIT);
|
||||
}
|
||||
|
||||
/* trigger clock signal */
|
||||
@ -114,9 +114,9 @@ static uint8_t write_byte(uint8_t value)
|
||||
}
|
||||
|
||||
/* wait for ack */
|
||||
SHT11_DATA_IN;
|
||||
xtimer_usleep(SHT11_CLK_WAIT);
|
||||
ack = SHT11_DATA;
|
||||
SHT1X_DATA_IN;
|
||||
xtimer_usleep(SHT1X_CLK_WAIT);
|
||||
ack = SHT1X_DATA;
|
||||
|
||||
clk_signal();
|
||||
|
||||
@ -128,40 +128,40 @@ static uint8_t read_byte(uint8_t ack)
|
||||
uint8_t i;
|
||||
uint8_t value = 0;
|
||||
|
||||
SHT11_DATA_IN;
|
||||
xtimer_usleep(SHT11_DATA_WAIT);
|
||||
SHT1X_DATA_IN;
|
||||
xtimer_usleep(SHT1X_DATA_WAIT);
|
||||
|
||||
/* read value bit by bit */
|
||||
for (i = 0; i < 8; i++) {
|
||||
value = value << 1;
|
||||
SHT11_SCK_HIGH;
|
||||
xtimer_usleep(SHT11_CLK_WAIT);
|
||||
SHT1X_SCK_HIGH;
|
||||
xtimer_usleep(SHT1X_CLK_WAIT);
|
||||
|
||||
if (SHT11_DATA) {
|
||||
if (SHT1X_DATA) {
|
||||
/* increase data by one when DATA is high */
|
||||
value++;
|
||||
}
|
||||
|
||||
SHT11_SCK_LOW;
|
||||
xtimer_usleep(SHT11_CLK_WAIT);
|
||||
SHT1X_SCK_LOW;
|
||||
xtimer_usleep(SHT1X_CLK_WAIT);
|
||||
}
|
||||
|
||||
/* send ack if necessary */
|
||||
SHT11_DATA_OUT;
|
||||
SHT1X_DATA_OUT;
|
||||
|
||||
if (ack) {
|
||||
SHT11_DATA_LOW;
|
||||
xtimer_usleep(SHT11_DATA_WAIT);
|
||||
SHT1X_DATA_LOW;
|
||||
xtimer_usleep(SHT1X_DATA_WAIT);
|
||||
}
|
||||
else {
|
||||
SHT11_DATA_HIGH;
|
||||
xtimer_usleep(SHT11_DATA_WAIT);
|
||||
SHT1X_DATA_HIGH;
|
||||
xtimer_usleep(SHT1X_DATA_WAIT);
|
||||
}
|
||||
|
||||
clk_signal();
|
||||
|
||||
/* release data line */
|
||||
SHT11_DATA_IN;
|
||||
SHT1X_DATA_IN;
|
||||
|
||||
return value;
|
||||
}
|
||||
@ -173,31 +173,31 @@ static void transmission_start(void)
|
||||
___ ___
|
||||
SCK : ___| |___| |______
|
||||
*/
|
||||
SHT11_DATA_OUT;
|
||||
SHT1X_DATA_OUT;
|
||||
|
||||
/* set initial state */
|
||||
SHT11_DATA_HIGH;
|
||||
xtimer_usleep(SHT11_DATA_WAIT);
|
||||
SHT11_SCK_LOW;
|
||||
xtimer_usleep(SHT11_CLK_WAIT);
|
||||
SHT1X_DATA_HIGH;
|
||||
xtimer_usleep(SHT1X_DATA_WAIT);
|
||||
SHT1X_SCK_LOW;
|
||||
xtimer_usleep(SHT1X_CLK_WAIT);
|
||||
|
||||
SHT11_SCK_HIGH;
|
||||
xtimer_usleep(SHT11_CLK_WAIT);
|
||||
SHT1X_SCK_HIGH;
|
||||
xtimer_usleep(SHT1X_CLK_WAIT);
|
||||
|
||||
SHT11_DATA_LOW;
|
||||
xtimer_usleep(SHT11_DATA_WAIT);
|
||||
SHT1X_DATA_LOW;
|
||||
xtimer_usleep(SHT1X_DATA_WAIT);
|
||||
|
||||
SHT11_SCK_LOW;
|
||||
xtimer_usleep(SHT11_CLK_WAIT);
|
||||
SHT1X_SCK_LOW;
|
||||
xtimer_usleep(SHT1X_CLK_WAIT);
|
||||
|
||||
SHT11_SCK_HIGH;
|
||||
xtimer_usleep(SHT11_CLK_WAIT);
|
||||
SHT1X_SCK_HIGH;
|
||||
xtimer_usleep(SHT1X_CLK_WAIT);
|
||||
|
||||
SHT11_DATA_HIGH;
|
||||
xtimer_usleep(SHT11_DATA_WAIT);
|
||||
SHT1X_DATA_HIGH;
|
||||
xtimer_usleep(SHT1X_DATA_WAIT);
|
||||
|
||||
SHT11_SCK_LOW;
|
||||
xtimer_usleep(SHT11_CLK_WAIT);
|
||||
SHT1X_SCK_LOW;
|
||||
xtimer_usleep(SHT1X_CLK_WAIT);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void connection_reset(void)
|
||||
@ -208,10 +208,10 @@ static void connection_reset(void)
|
||||
SCK : __| |__| |__| |__| |__| |__| |__| |__| |__| |______| |___| |__
|
||||
*/
|
||||
uint8_t i;
|
||||
SHT11_DATA_HIGH;
|
||||
xtimer_usleep(SHT11_DATA_WAIT);
|
||||
SHT11_SCK_LOW;
|
||||
xtimer_usleep(SHT11_CLK_WAIT);
|
||||
SHT1X_DATA_HIGH;
|
||||
xtimer_usleep(SHT1X_DATA_WAIT);
|
||||
SHT1X_SCK_LOW;
|
||||
xtimer_usleep(SHT1X_CLK_WAIT);
|
||||
|
||||
for (i = 0; i < 9; i++) {
|
||||
clk_signal();
|
||||
@ -232,8 +232,8 @@ static uint8_t measure(uint8_t *p_value, uint8_t *p_checksum, uint8_t mode)
|
||||
xtimer_usleep(1000);
|
||||
|
||||
/* wait untile sensor has finished measurement or timeout */
|
||||
for (i = 0; (i < SHT11_MEASURE_TIMEOUT) && (!error); i++) {
|
||||
ack = SHT11_DATA;
|
||||
for (i = 0; (i < SHT1X_MEASURE_TIMEOUT) && (!error); i++) {
|
||||
ack = SHT1X_DATA;
|
||||
|
||||
if (!ack) {
|
||||
break;
|
||||
@ -245,44 +245,44 @@ static uint8_t measure(uint8_t *p_value, uint8_t *p_checksum, uint8_t mode)
|
||||
error += ack;
|
||||
|
||||
/* read MSB */
|
||||
*(p_value + 1) = read_byte(SHT11_ACK);
|
||||
*(p_value + 1) = read_byte(SHT1X_ACK);
|
||||
/* read LSB */
|
||||
*(p_value) = read_byte(SHT11_ACK);
|
||||
*(p_value) = read_byte(SHT1X_ACK);
|
||||
/* read checksum */
|
||||
*p_checksum = read_byte(SHT11_NO_ACK);
|
||||
*p_checksum = read_byte(SHT1X_NO_ACK);
|
||||
|
||||
return (!error);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void sht11_init(void)
|
||||
void sht1x_init(void)
|
||||
{
|
||||
sht11_temperature_offset = 0;
|
||||
SHT11_INIT;
|
||||
sht1x_temperature_offset = 0;
|
||||
SHT1X_INIT;
|
||||
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;
|
||||
|
||||
transmission_start();
|
||||
error |= write_byte(SHT11_STATUS_REG_R);
|
||||
*p_value = read_byte(SHT11_ACK);
|
||||
*p_checksum = read_byte(SHT11_NO_ACK);
|
||||
error |= write_byte(SHT1X_STATUS_REG_R);
|
||||
*p_value = read_byte(SHT1X_ACK);
|
||||
*p_checksum = read_byte(SHT1X_NO_ACK);
|
||||
return (!error);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint8_t sht11_write_status(uint8_t *p_value)
|
||||
uint8_t sht1x_write_status(uint8_t *p_value)
|
||||
{
|
||||
uint8_t error = 0;
|
||||
|
||||
transmission_start();
|
||||
error += write_byte(SHT11_STATUS_REG_W);
|
||||
error += write_byte(SHT1X_STATUS_REG_W);
|
||||
error += write_byte(*p_value);
|
||||
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 checksum;
|
||||
@ -313,28 +313,28 @@ uint8_t sht11_read_sensor(sht11_val_t *value, sht11_mode_t mode)
|
||||
value->relhum = 0;
|
||||
value->relhum_temp = 0;
|
||||
|
||||
mutex_lock(&sht11_mutex);
|
||||
mutex_lock(&sht1x_mutex);
|
||||
connection_reset();
|
||||
|
||||
/* measure 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 */
|
||||
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 */
|
||||
if (error != 0) {
|
||||
connection_reset();
|
||||
mutex_unlock(&sht11_mutex);
|
||||
mutex_unlock(&sht1x_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -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;
|
||||
}
|
@ -95,6 +95,11 @@ PSEUDOMODULES += adc121c
|
||||
PSEUDOMODULES += sx1272
|
||||
PSEUDOMODULES += sx1276
|
||||
|
||||
# include variants of SHT1X drivers as pseudo modules
|
||||
PSEUDOMODULES += sht10
|
||||
PSEUDOMODULES += sht11
|
||||
PSEUDOMODULES += sht15
|
||||
|
||||
# include variants of Si114x drivers as pseudo modules
|
||||
PSEUDOMODULES += si1145
|
||||
PSEUDOMODULES += si1146
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
#include "auto_init.h"
|
||||
|
||||
#ifdef MODULE_SHT11
|
||||
#include "sht11.h"
|
||||
#ifdef MODULE_SHT1X
|
||||
#include "sht1x.h"
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_MCI
|
||||
@ -101,9 +101,9 @@ void auto_init(void)
|
||||
DEBUG("Auto init xtimer module.\n");
|
||||
xtimer_init();
|
||||
#endif
|
||||
#ifdef MODULE_SHT11
|
||||
DEBUG("Auto init SHT11 module.\n");
|
||||
sht11_init();
|
||||
#ifdef MODULE_SHT1X
|
||||
DEBUG("Auto init SHT1X module.\n");
|
||||
sht1x_init();
|
||||
#endif
|
||||
#ifdef MODULE_MCI
|
||||
DEBUG("Auto init mci module.\n");
|
||||
|
@ -8,8 +8,8 @@ endif
|
||||
ifneq (,$(filter ps,$(USEMODULE)))
|
||||
SRC += sc_ps.c
|
||||
endif
|
||||
ifneq (,$(filter sht11,$(USEMODULE)))
|
||||
SRC += sc_sht11.c
|
||||
ifneq (,$(filter sht1x,$(USEMODULE)))
|
||||
SRC += sc_sht1x.c
|
||||
endif
|
||||
ifneq (,$(filter lpc2387,$(USEMODULE)))
|
||||
SRC += sc_heap.c
|
||||
|
@ -22,11 +22,11 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.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)
|
||||
{
|
||||
@ -34,8 +34,8 @@ int _get_humidity_handler(int argc, char **argv)
|
||||
(void) argv;
|
||||
|
||||
uint8_t success;
|
||||
sht11_val_t sht11_val;
|
||||
success = sht11_read_sensor(&sht11_val, HUMIDITY | TEMPERATURE);
|
||||
sht1x_val_t sht1x_val;
|
||||
success = sht1x_read_sensor(&sht1x_val, HUMIDITY | TEMPERATURE);
|
||||
|
||||
if (!success) {
|
||||
printf("Error reading SHT11\n");
|
||||
@ -44,7 +44,7 @@ int _get_humidity_handler(int argc, char **argv)
|
||||
}
|
||||
else {
|
||||
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;
|
||||
}
|
||||
@ -56,8 +56,8 @@ int _get_temperature_handler(int argc, char **argv)
|
||||
(void) argv;
|
||||
|
||||
uint8_t success;
|
||||
sht11_val_t sht11_val;
|
||||
success = sht11_read_sensor(&sht11_val, TEMPERATURE);
|
||||
sht1x_val_t sht1x_val;
|
||||
success = sht1x_read_sensor(&sht1x_val, TEMPERATURE);
|
||||
|
||||
if (!success) {
|
||||
printf("Error reading SHT11\n");
|
||||
@ -65,7 +65,7 @@ int _get_temperature_handler(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
printf("Temperature: %-6.2f°C\n", (double) sht11_val.temperature);
|
||||
printf("Temperature: %-6.2f°C\n", (double) sht1x_val.temperature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -77,8 +77,8 @@ int _get_weather_handler(int argc, char **argv)
|
||||
(void) argv;
|
||||
|
||||
uint8_t success;
|
||||
sht11_val_t sht11_val;
|
||||
success = sht11_read_sensor(&sht11_val, HUMIDITY | TEMPERATURE);
|
||||
sht1x_val_t sht1x_val;
|
||||
success = sht1x_read_sensor(&sht1x_val, HUMIDITY | TEMPERATURE);
|
||||
|
||||
if (!success) {
|
||||
printf("Error reading SHT11\n");
|
||||
@ -87,8 +87,8 @@ int _get_weather_handler(int argc, char **argv)
|
||||
}
|
||||
else {
|
||||
printf("Relative humidity: %5.2f%% / Temperature compensated humidity; %5.2f%% ",
|
||||
(double) sht11_val.relhum, (double) sht11_val.relhum_temp);
|
||||
printf("Temperature: %-6.2f°C\n", (double) sht11_val.temperature);
|
||||
(double) sht1x_val.relhum, (double) sht1x_val.relhum_temp);
|
||||
printf("Temperature: %-6.2f°C\n", (double) sht1x_val.temperature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -102,8 +102,8 @@ int _set_offset_handler(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
sht11_temperature_offset = atoi(argv[1]);
|
||||
printf("Temperature offset set to %f\n", (double) sht11_temperature_offset);
|
||||
sht1x_temperature_offset = atoi(argv[1]);
|
||||
printf("Temperature offset set to %f\n", (double) sht1x_temperature_offset);
|
||||
|
||||
return 0;
|
||||
}
|
@ -37,7 +37,7 @@ extern int _heap_handler(int argc, char **argv);
|
||||
extern int _ps_handler(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_SHT11
|
||||
#ifdef MODULE_SHT1X
|
||||
extern int _get_temperature_handler(int argc, char **argv);
|
||||
extern int _get_humidity_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
|
||||
{"ps", "Prints information about running threads.", _ps_handler},
|
||||
#endif
|
||||
#ifdef MODULE_SHT11
|
||||
#ifdef MODULE_SHT1X
|
||||
{"temp", "Prints measured temperature.", _get_temperature_handler},
|
||||
{"hum", "Prints measured humidity.", _get_humidity_handler},
|
||||
{"weather", "Prints measured humidity and temperature.", _get_weather_handler},
|
||||
|
Loading…
Reference in New Issue
Block a user