The friendly Operating System for the Internet of Things

Driver for Sensirion SHT11 Humidity and Temperature Sensor. More...

Detailed Description

Files

file  sht11.h
 SHT11 Device Driver.
 

Data Structures

struct  sht11_val_t
 sht11 measureable data More...
 

Macros

#define SHT11_NO_ACK   (0)
 don't ack read in read_byte
 
#define SHT11_ACK   (1)
 do acknowledge read in read_byte
 
#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 SHT11_DATA_WAIT   (1)
 time to wait after toggling the data line
 
#define SHT11_CLK_WAIT   (1)
 time to wait after toggling the clock line
 
#define SHT11_MEASURE_TIMEOUT   (1000)
 set measurement timeout to 1 second
 

Enumerations

enum  sht11_mode_t { TEMPERATURE = 1, HUMIDITY = 2 }
 SHT11 modes that can be measured.
 

Functions

void sht11_init (void)
 Initialize SHT11 ports.
 
uint8_t sht11_read_sensor (sht11_val_t *value, sht11_mode_t mode)
 Read sensor. More...
 
uint8_t sht11_write_status (uint8_t *p_value)
 Write status register. More...
 
uint8_t sht11_read_status (uint8_t *p_value, uint8_t *p_checksum)
 Read status register with checksum. More...
 

Function Documentation

uint8_t sht11_read_sensor ( sht11_val_t value,
sht11_mode_t  mode 
)
Parameters
valueThe struct to be filled with measured values
modeSpecifies type of data to be read
Returns
1 on success, 0 otherwise

Example:

1  sht11_val sht11;
2 sht11_read_sensor(&sht11, HUMIDITY|TEMPERATURE);
3 printf("%-6.2f °C %5.2f %% %5.2f %%\n", sht11.temperature, sht11.relhum, sht11.relhum_temp);
uint8_t sht11_read_status ( uint8_t *  p_value,
uint8_t *  p_checksum 
)
Parameters
p_valueThe read value
p_checksumThe received checksum

return 1 on success, 0 otherwise

uint8_t sht11_write_status ( uint8_t *  p_value)
Parameters
p_valueThe value to write
Returns
1 on success, 0 otherwise