LibDriver SHT31
Loading...
Searching...
No Matches
sht31 base driver function

sht31 base driver modules More...

Collaboration diagram for sht31 base driver function:

Data Structures

struct  sht31_handle_s
 sht31 handle structure definition More...
struct  sht31_info_s
 sht31 information structure definition More...

Typedefs

typedef struct sht31_handle_s sht31_handle_t
 sht31 handle structure definition
typedef struct sht31_info_s sht31_info_t
 sht31 information structure definition

Enumerations

enum  sht31_address_t { SHT31_ADDRESS_0 = (0x44 << 1) , SHT31_ADDRESS_1 = (0x45 << 1) }
 sht31 address enumeration definition More...
enum  sht31_bool_t { SHT31_BOOL_FALSE = 0x00 , SHT31_BOOL_TRUE = 0x01 }
 sht31 bool enumeration definition More...
enum  sht31_rate_t {
  SHT31_RATE_0P5HZ = 0x20 , SHT31_RATE_1HZ = 0x21 , SHT31_RATE_2HZ = 0x22 , SHT31_RATE_4HZ = 0x23 ,
  SHT31_RATE_10HZ = 0x27
}
 sht31 rate enumeration definition More...
enum  sht31_repeatability_t { SHT31_REPEATABILITY_HIGH = 0x00 , SHT31_REPEATABILITY_MEDIUM = 0x01 , SHT31_REPEATABILITY_LOW = 0x02 }
 sht31 repeatability enumeration definition More...
enum  sht31_status_t {
  SHT31_STATUS_ALERT_PENDING_STATUS = (1 << 15) , SHT31_STATUS_HEATER_ON = (1 << 13) , SHT31_STATUS_HUMIDITY_ALERT = (1 << 11) , SHT31_STATUS_TEMPERATURE_ALERT = (1 << 10) ,
  SHT31_STATUS_SYSTEM_RESET = (1 << 4) , SHT31_STATUS_COMMAND_STATUS = (1 << 1) , SHT31_STATUS_CHECKSUM_STATUS = (1 << 0)
}
 sht31 status enumeration definition More...

Functions

uint8_t sht31_info (sht31_info_t *info)
 get chip's information
uint8_t sht31_set_addr_pin (sht31_handle_t *handle, sht31_address_t addr_pin)
 set the iic address pin
uint8_t sht31_get_addr_pin (sht31_handle_t *handle, sht31_address_t *addr_pin)
 get the iic address pin
uint8_t sht31_irq_handler (sht31_handle_t *handle)
 irq handler
uint8_t sht31_init (sht31_handle_t *handle)
 initialize the chip
uint8_t sht31_deinit (sht31_handle_t *handle)
 close the chip
uint8_t sht31_single_read (sht31_handle_t *handle, sht31_bool_t clock_stretching_enable, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
 read data once
uint8_t sht31_start_continuous_read (sht31_handle_t *handle, sht31_rate_t rate)
 start reading
uint8_t sht31_stop_continuous_read (sht31_handle_t *handle)
 stop reading
uint8_t sht31_continuous_read (sht31_handle_t *handle, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
 read data continuously
uint8_t sht31_get_status (sht31_handle_t *handle, uint16_t *status)
 get the current status
uint8_t sht31_clear_status (sht31_handle_t *handle)
 clear the current status
uint8_t sht31_set_repeatability (sht31_handle_t *handle, sht31_repeatability_t repeatability)
 set the measurement repeatability
uint8_t sht31_get_repeatability (sht31_handle_t *handle, sht31_repeatability_t *repeatability)
 get the measurement repeatability
uint8_t sht31_set_art (sht31_handle_t *handle)
 set the chip art
uint8_t sht31_soft_reset (sht31_handle_t *handle)
 soft reset the chip
uint8_t sht31_set_heater (sht31_handle_t *handle, sht31_bool_t enable)
 enable or disable the chip heater
uint8_t sht31_get_serial_number (sht31_handle_t *handle, uint8_t sn[4])
 get serial number
uint8_t sht31_set_high_alert_limit (sht31_handle_t *handle, uint16_t set, uint16_t clear)
 set high alert limit
uint8_t sht31_get_high_alert_limit (sht31_handle_t *handle, uint16_t *set, uint16_t *clear)
 get high alert limit
uint8_t sht31_set_low_alert_limit (sht31_handle_t *handle, uint16_t set, uint16_t clear)
 set low alert limit
uint8_t sht31_get_low_alert_limit (sht31_handle_t *handle, uint16_t *set, uint16_t *clear)
 get low alert limit
uint8_t sht31_alert_limit_convert_to_register (sht31_handle_t *handle, float temperature, float humidity, uint16_t *reg)
 alert limit convert to register raw data

Detailed Description

sht31 base driver modules

Typedef Documentation

◆ sht31_handle_t

sht31 handle structure definition

◆ sht31_info_t

typedef struct sht31_info_s sht31_info_t

sht31 information structure definition

Enumeration Type Documentation

◆ sht31_address_t

sht31 address enumeration definition

Enumerator
SHT31_ADDRESS_0 

ADDR pin connected to GND

SHT31_ADDRESS_1 

ADDR pin connected to VCC

Definition at line 63 of file driver_sht31.h.

◆ sht31_bool_t

sht31 bool enumeration definition

Enumerator
SHT31_BOOL_FALSE 

disable function

SHT31_BOOL_TRUE 

enable function

Definition at line 72 of file driver_sht31.h.

◆ sht31_rate_t

sht31 rate enumeration definition

Enumerator
SHT31_RATE_0P5HZ 

0.5Hz sample rate

SHT31_RATE_1HZ 

1Hz sample rate

SHT31_RATE_2HZ 

2Hz sample rate

SHT31_RATE_4HZ 

4Hz sample rate

SHT31_RATE_10HZ 

10Hz sample rate

Definition at line 81 of file driver_sht31.h.

◆ sht31_repeatability_t

sht31 repeatability enumeration definition

Enumerator
SHT31_REPEATABILITY_HIGH 

high repeatability

SHT31_REPEATABILITY_MEDIUM 

medium repeatability

SHT31_REPEATABILITY_LOW 

low repeatability

Definition at line 93 of file driver_sht31.h.

◆ sht31_status_t

sht31 status enumeration definition

Enumerator
SHT31_STATUS_ALERT_PENDING_STATUS 

alert pending status

SHT31_STATUS_HEATER_ON 

heater on

SHT31_STATUS_HUMIDITY_ALERT 

humidity alert

SHT31_STATUS_TEMPERATURE_ALERT 

temperature alert

SHT31_STATUS_SYSTEM_RESET 

system reset

SHT31_STATUS_COMMAND_STATUS 

command status

SHT31_STATUS_CHECKSUM_STATUS 

checksum status

Definition at line 103 of file driver_sht31.h.

Function Documentation

◆ sht31_alert_limit_convert_to_register()

uint8_t sht31_alert_limit_convert_to_register ( sht31_handle_t * handle,
float temperature,
float humidity,
uint16_t * reg )

alert limit convert to register raw data

Parameters
[in]*handlepointer to an sht31 handle structure
[in]temperatureconverted temperature
[in]humidityconverted humidity
[out]*regpointer to a register raw buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1225 of file driver_sht31.c.

◆ sht31_clear_status()

uint8_t sht31_clear_status ( sht31_handle_t * handle)

clear the current status

Parameters
[in]*handlepointer to an sht31 handle structure
Returns
status code
  • 0 success
  • 1 clear status failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 385 of file driver_sht31.c.

◆ sht31_continuous_read()

uint8_t sht31_continuous_read ( sht31_handle_t * handle,
uint16_t * temperature_raw,
float * temperature_s,
uint16_t * humidity_raw,
float * humidity_s )

read data continuously

Parameters
[in]*handlepointer to an sht31 handle structure
[out]*temperature_rawpointer to a raw temperature buffer
[out]*temperature_spointer to a converted temperature buffer
[out]*humidity_rawpointer to a raw humidity buffer
[out]*humidity_spointer to a converted humidity buffer
Returns
status code
  • 0 success
  • 1 continuous read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 760 of file driver_sht31.c.

◆ sht31_deinit()

uint8_t sht31_deinit ( sht31_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to an sht31 handle structure
Returns
status code
  • 0 success
  • 1 iic deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 249 of file driver_sht31.c.

◆ sht31_get_addr_pin()

uint8_t sht31_get_addr_pin ( sht31_handle_t * handle,
sht31_address_t * addr_pin )

get the iic address pin

Parameters
[in]*handlepointer to an sht31 handle structure
[out]*addr_pinpointer to a chip iic address pin buffer
Returns
status code
  • 0 success
  • 1 get addr pin failed
  • 2 handle is NULL
Note
none

Definition at line 314 of file driver_sht31.c.

◆ sht31_get_high_alert_limit()

uint8_t sht31_get_high_alert_limit ( sht31_handle_t * handle,
uint16_t * set,
uint16_t * clear )

get high alert limit

Parameters
[in]*handlepointer to an sht31 handle structure
[out]*setpointer to a high alert limit set buffer
[out]*clearpointer to a high alert limit clear buffer
Returns
status code
  • 0 success
  • 1 get high alert limit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1047 of file driver_sht31.c.

◆ sht31_get_low_alert_limit()

uint8_t sht31_get_low_alert_limit ( sht31_handle_t * handle,
uint16_t * set,
uint16_t * clear )

get low alert limit

Parameters
[in]*handlepointer to an sht31 handle structure
[out]*setpointer to a low alert limit set buffer
[out]*clearpointer to a low alert limit clear buffer
Returns
status code
  • 0 success
  • 1 get low alert limit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1163 of file driver_sht31.c.

◆ sht31_get_repeatability()

uint8_t sht31_get_repeatability ( sht31_handle_t * handle,
sht31_repeatability_t * repeatability )

get the measurement repeatability

Parameters
[in]*handlepointer to an sht31 handle structure
[out]*repeatabilitypointer to a measurement repeatability buffer
Returns
status code
  • 0 success
  • 1 get repeatability failed
  • 2 handle is NULL
Note
none

Definition at line 447 of file driver_sht31.c.

◆ sht31_get_serial_number()

uint8_t sht31_get_serial_number ( sht31_handle_t * handle,
uint8_t sn[4] )

get serial number

Parameters
[in]*handlepointer to an sht31 handle structure
[out]*snpointer to a serial number buffer
Returns
status code
  • 0 success
  • 1 get serial number failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 938 of file driver_sht31.c.

◆ sht31_get_status()

uint8_t sht31_get_status ( sht31_handle_t * handle,
uint16_t * status )

get the current status

Parameters
[in]*handlepointer to an sht31 handle structure
[out]*statuspointer to a status buffer
Returns
status code
  • 0 success
  • 1 get status failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 337 of file driver_sht31.c.

◆ sht31_info()

uint8_t sht31_info ( sht31_info_t * info)

get chip's information

Parameters
[out]*infopointer to an sht31 info structure
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 1387 of file driver_sht31.c.

◆ sht31_init()

uint8_t sht31_init ( sht31_handle_t * handle)

initialize the chip

Parameters
[in]*handlepointer to an sht31 handle structure
Returns
status code
  • 0 success
  • 1 iic initialization failed
  • 2 handle is NULL
  • 3 linked functions is NULL
Note
none

Definition at line 175 of file driver_sht31.c.

◆ sht31_irq_handler()

uint8_t sht31_irq_handler ( sht31_handle_t * handle)

irq handler

Parameters
[in]*handlepointer to an sht31 handle structure
Returns
status code
  • 0 success
  • 1 run failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1258 of file driver_sht31.c.

◆ sht31_set_addr_pin()

uint8_t sht31_set_addr_pin ( sht31_handle_t * handle,
sht31_address_t addr_pin )

set the iic address pin

Parameters
[in]*handlepointer to an sht31 handle structure
[in]addr_pinchip iic address pin
Returns
status code
  • 0 success
  • 1 set addr pin failed
  • 2 handle is NULL
Note
none

Definition at line 292 of file driver_sht31.c.

◆ sht31_set_art()

uint8_t sht31_set_art ( sht31_handle_t * handle)

set the chip art

Parameters
[in]*handlepointer to an sht31 handle structure
Returns
status code
  • 0 success
  • 1 set art failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 815 of file driver_sht31.c.

◆ sht31_set_heater()

uint8_t sht31_set_heater ( sht31_handle_t * handle,
sht31_bool_t enable )

enable or disable the chip heater

Parameters
[in]*handlepointer to an sht31 handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set heater failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 888 of file driver_sht31.c.

◆ sht31_set_high_alert_limit()

uint8_t sht31_set_high_alert_limit ( sht31_handle_t * handle,
uint16_t set,
uint16_t clear )

set high alert limit

Parameters
[in]*handlepointer to an sht31 handle structure
[in]sethigh alert limit set
[in]clearhigh alert limit clear
Returns
status code
  • 0 success
  • 1 set high alert limit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 993 of file driver_sht31.c.

◆ sht31_set_low_alert_limit()

uint8_t sht31_set_low_alert_limit ( sht31_handle_t * handle,
uint16_t set,
uint16_t clear )

set low alert limit

Parameters
[in]*handlepointer to an sht31 handle structure
[in]setlow alert limit set
[in]clearlow alert limit clear
Returns
status code
  • 0 success
  • 1 set low alert limit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1109 of file driver_sht31.c.

◆ sht31_set_repeatability()

uint8_t sht31_set_repeatability ( sht31_handle_t * handle,
sht31_repeatability_t repeatability )

set the measurement repeatability

Parameters
[in]*handlepointer to an sht31 handle structure
[in]repeatabilitymeasurement repeatability
Returns
status code
  • 0 success
  • 1 set repeatability failed
  • 2 handle is NULL
Note
none

Definition at line 421 of file driver_sht31.c.

◆ sht31_single_read()

uint8_t sht31_single_read ( sht31_handle_t * handle,
sht31_bool_t clock_stretching_enable,
uint16_t * temperature_raw,
float * temperature_s,
uint16_t * humidity_raw,
float * humidity_s )

read data once

Parameters
[in]*handlepointer to an sht31 handle structure
[in]clock_stretching_enableclock stretching bool value
[out]*temperature_rawpointer to a raw temperature buffer
[out]*temperature_spointer to a converted temperature buffer
[out]*humidity_rawpointer to a raw humidity buffer
[out]*humidity_spointer to a converted humidity buffer
Returns
status code
  • 0 success
  • 1 single read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 478 of file driver_sht31.c.

◆ sht31_soft_reset()

uint8_t sht31_soft_reset ( sht31_handle_t * handle)

soft reset the chip

Parameters
[in]*handlepointer to an sht31 handle structure
Returns
status code
  • 0 success
  • 1 soft reset failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 851 of file driver_sht31.c.

◆ sht31_start_continuous_read()

uint8_t sht31_start_continuous_read ( sht31_handle_t * handle,
sht31_rate_t rate )

start reading

Parameters
[in]*handlepointer to an sht31 handle structure
[in]ratesample rate
Returns
status code
  • 0 success
  • 1 start continuous read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 592 of file driver_sht31.c.

◆ sht31_stop_continuous_read()

uint8_t sht31_stop_continuous_read ( sht31_handle_t * handle)

stop reading

Parameters
[in]*handlepointer to an sht31 handle structure
Returns
status code
  • 0 success
  • 1 stop continuous read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 720 of file driver_sht31.c.