5 #include <twr_scheduler.h>
11 #define TWR_SHT30_ADDRESS_DEFAULT 0x44
12 #define TWR_SHT30_ADDRESS_ALTERNATE 0x45
34 TWR_SHT30_STATE_ERROR = -1,
35 TWR_SHT30_STATE_INITIALIZE = 0,
36 TWR_SHT30_STATE_MEASURE = 1,
37 TWR_SHT30_STATE_READ = 2,
38 TWR_SHT30_STATE_UPDATE = 3
50 bool _measurement_active;
52 twr_sht30_state_t _state;
55 bool _temperature_valid;
56 uint16_t _reg_humidity;
57 uint16_t _reg_temperature;
twr_i2c_channel_t
I2C channels.
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
void twr_sht30_set_update_interval(twr_sht30_t *self, twr_tick_t interval)
Set measurement interval.
bool twr_sht30_get_temperature_celsius(twr_sht30_t *self, float *celsius)
Get measured temperature in degrees of Celsius.
bool twr_sht30_measure(twr_sht30_t *self)
Start measurement manually.
struct twr_sht30_t twr_sht30_t
SHT30 instance.
void twr_sht30_deinit(twr_sht30_t *self)
Deinitialize SHT30.
bool twr_sht30_get_temperature_kelvin(twr_sht30_t *self, float *kelvin)
Get measured temperature in kelvin.
bool twr_sht30_get_temperature_fahrenheit(twr_sht30_t *self, float *fahrenheit)
Get measured temperature in degrees of Fahrenheit.
twr_sht30_event_t
Callback events.
void twr_sht30_set_event_handler(twr_sht30_t *self, void(*event_handler)(twr_sht30_t *, twr_sht30_event_t, void *), void *event_param)
Set callback function.
bool twr_sht30_get_humidity_percentage(twr_sht30_t *self, float *percentage)
Get measured humidity as percentage.
void twr_sht30_init(twr_sht30_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize SHT30.
bool twr_sht30_get_temperature_raw(twr_sht30_t *self, uint16_t *raw)
Get measured temperature as raw value.
bool twr_sht30_get_humidity_raw(twr_sht30_t *self, uint16_t *raw)
Get measured humidity as raw value.
@ TWR_SHT30_EVENT_ERROR
Error event.
@ TWR_SHT30_EVENT_UPDATE
Update event.
uint64_t twr_tick_t
Timestamp data type.