42#define CHIP_NAME "Sensirion SHT85"
43#define MANUFACTURER_NAME "Sensirion"
44#define SUPPLY_VOLTAGE_MIN 2.15f
45#define SUPPLY_VOLTAGE_MAX 5.5f
46#define MAX_CURRENT 1.5f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 105.0f
49#define DRIVER_VERSION 1000
54#define SHT85_ADDRESS (0x44 << 1)
59#define SHT85_COMMAND_FETCH_DATA 0xE000U
60#define SHT85_COMMAND_ART 0x2B32U
61#define SHT85_COMMAND_BREAK 0x3093U
62#define SHT85_COMMAND_SOFT_RESET 0x30A2U
63#define SHT85_COMMAND_HEATER_ENABLE 0x306DU
64#define SHT85_COMMAND_HEATER_DISABLE 0x3066U
65#define SHT85_COMMAND_READ_STATUS 0xF32DU
66#define SHT85_COMMAND_CLEAR_STATUS 0x3041U
67#define SHT85_COMMAND_GET_SERIAL_NUMBER 0x3682U
100static uint8_t a_sht85_read(
sht85_handle_t *handle, uint16_t reg, uint8_t *data, uint16_t len)
117static uint8_t a_sht85_crc(uint8_t *data, uint16_t len)
119 const uint8_t POLYNOMIAL = 0x31;
123 for (j = len; j != 0; --j)
126 for (i = 8; i != 0; --i)
128 crc = (crc & 0x80) ? (crc << 1) ^ POLYNOMIAL : (crc<<1);
166 handle->
debug_print(
"sht85: iic_deinit is null.\n");
172 handle->
debug_print(
"sht85: iic_read_address16 is null.\n");
178 handle->
debug_print(
"sht85: iic_write_address16 is null.\n");
196 res = a_sht85_write(handle, command);
199 handle->
debug_print(
"sht85: write command failed.\n");
234 res = a_sht85_write(handle, command);
237 handle->
debug_print(
"sht85: write command failed.\n");
243 handle->
debug_print(
"sht85: iic deinit failed.\n");
278 memset(data, 0,
sizeof(uint8_t) * 3);
280 res = a_sht85_read(handle, command, (uint8_t *)data, 3);
283 handle->
debug_print(
"sht85: read status failed.\n");
287 if (a_sht85_crc((uint8_t *)data, 2) == data[2])
289 *status = (uint16_t)((((uint16_t)data[0]) << 8) | data[1]);
326 res = a_sht85_write(handle, command);
329 handle->
debug_print(
"sht85: write command failed.\n");
404 uint16_t *temperature_raw,
float *temperature_s,
405 uint16_t *humidity_raw,
float *humidity_s)
434 handle->
debug_print(
"sht85: repeatability is invalid.\n");
439 memset(data, 0,
sizeof(uint8_t) * 6);
440 res = a_sht85_read(handle, command, (uint8_t *)data, 6);
447 if (a_sht85_crc((uint8_t *)data, 2) != data[2])
453 if (a_sht85_crc((uint8_t *)&data[3], 2) != data[5])
459 *temperature_raw = (uint16_t)((((uint16_t)data[0]) << 8) | data[1]);
460 *humidity_raw = (uint16_t)((((uint16_t)data[3]) << 8) | data[4]);
461 *temperature_s = (float)(*temperature_raw) / 65535.0f * 175.0f - 45.0f;
462 *humidity_s = (float)(*humidity_raw) / 65535.0f * 100.0f;
581 handle->
debug_print(
"sht85: repeatability is invalid.\n");
585 res = a_sht85_write(handle, command);
588 handle->
debug_print(
"sht85: write command failed.\n");
621 res = a_sht85_write(handle, command);
624 handle->
debug_print(
"sht85: write command failed.\n");
647 uint16_t *temperature_raw,
float *temperature_s,
648 uint16_t *humidity_raw,
float *humidity_s)
664 res = a_sht85_read(handle, command, (uint8_t *)data, 6);
671 if (a_sht85_crc((uint8_t *)data, 2) != data[2])
677 if (a_sht85_crc((uint8_t *)&data[3], 2) != data[5])
683 *temperature_raw = (uint16_t)((((uint16_t)data[0]) << 8) | data[1]);
684 *humidity_raw = (uint16_t)((((uint16_t)data[3]) << 8) | data[4]);
685 *temperature_s = (float)(*temperature_raw) / 65535.0f * 175.0f - 45.0f;
686 *humidity_s = (float)(*humidity_raw) / 65535.0f * 100.0f;
716 res = a_sht85_write(handle, command);
719 handle->
debug_print(
"sht85: write command failed.\n");
752 res = a_sht85_write(handle, command);
755 handle->
debug_print(
"sht85: write command failed.\n");
802 res = a_sht85_write(handle, command);
805 handle->
debug_print(
"sht85: write command failed.\n");
840 res = a_sht85_read(handle, command, (uint8_t *)data, 6);
847 if (a_sht85_crc((uint8_t *)data, 2) != data[2])
853 if (a_sht85_crc((uint8_t *)&data[3], 2) != data[5])
889 return a_sht85_write(handle, command);
916 return a_sht85_read(handle, command, buf, len);
#define SHT85_COMMAND_HEATER_DISABLE
#define SHT85_COMMAND_GET_SERIAL_NUMBER
#define SHT85_COMMAND_ART
#define SHT85_COMMAND_HEATER_ENABLE
#define SUPPLY_VOLTAGE_MAX
#define SHT85_COMMAND_CLEAR_STATUS
#define SHT85_COMMAND_BREAK
#define SHT85_COMMAND_FETCH_DATA
chip command definition
#define SHT85_ADDRESS
chip address definition
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define SHT85_COMMAND_READ_STATUS
#define CHIP_NAME
chip information definition
#define SHT85_COMMAND_SOFT_RESET
uint8_t sht85_start_continuous_read(sht85_handle_t *handle, sht85_rate_t rate)
start reading
uint8_t sht85_continuous_read(sht85_handle_t *handle, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
read data continuously
uint8_t sht85_set_heater(sht85_handle_t *handle, sht85_bool_t enable)
enable or disable the chip heater
uint8_t sht85_clear_status(sht85_handle_t *handle)
clear the current status
uint8_t sht85_get_serial_number(sht85_handle_t *handle, uint8_t sn[4])
get serial number
struct sht85_info_s sht85_info_t
sht85 information structure definition
uint8_t sht85_init(sht85_handle_t *handle)
initialize the chip
uint8_t sht85_set_repeatability(sht85_handle_t *handle, sht85_repeatability_t repeatability)
set the measurement repeatability
sht85_repeatability_t
sht85 repeatability enumeration definition
uint8_t sht85_stop_continuous_read(sht85_handle_t *handle)
stop reading
uint8_t sht85_deinit(sht85_handle_t *handle)
close the chip
uint8_t sht85_info(sht85_info_t *info)
get chip's information
sht85_rate_t
sht85 rate enumeration definition
uint8_t sht85_set_art(sht85_handle_t *handle)
set the chip art
sht85_bool_t
sht85 bool enumeration definition
uint8_t sht85_get_status(sht85_handle_t *handle, uint16_t *status)
get the current status
struct sht85_handle_s sht85_handle_t
sht85 handle structure definition
uint8_t sht85_single_read(sht85_handle_t *handle, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
read data once
uint8_t sht85_soft_reset(sht85_handle_t *handle)
soft reset the chip
uint8_t sht85_get_repeatability(sht85_handle_t *handle, sht85_repeatability_t *repeatability)
get the measurement repeatability
@ SHT85_REPEATABILITY_HIGH
@ SHT85_REPEATABILITY_LOW
@ SHT85_REPEATABILITY_MEDIUM
uint8_t sht85_set_reg(sht85_handle_t *handle, uint16_t command)
set the chip register
uint8_t sht85_get_reg(sht85_handle_t *handle, uint16_t command, uint8_t *buf, uint16_t len)
get the chip register
void(* delay_ms)(uint32_t ms)
uint8_t(* iic_read_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v