Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_sht30.h
1 #ifndef _BC_SHT30_H
2 #define _BC_SHT30_H
3 
4 #include <bc_i2c.h>
5 #include <bc_scheduler.h>
6 
10 
11 #define BC_SHT30_ADDRESS_DEFAULT 0x44
12 #define BC_SHT30_ADDRESS_ALTERNATE 0x45
13 
15 
16 typedef enum
17 {
20 
23 
25 
27 
28 typedef struct bc_sht30_t bc_sht30_t;
29 
31 
32 typedef enum
33 {
34  BC_SHT30_STATE_ERROR = -1,
35  BC_SHT30_STATE_INITIALIZE = 0,
36  BC_SHT30_STATE_MEASURE = 1,
37  BC_SHT30_STATE_READ = 2,
38  BC_SHT30_STATE_UPDATE = 3
39 
40 } bc_sht30_state_t;
41 
42 struct bc_sht30_t
43 {
44  bc_i2c_channel_t _i2c_channel;
45  uint8_t _i2c_address;
46  bc_scheduler_task_id_t _task_id_interval;
47  bc_scheduler_task_id_t _task_id_measure;
48  void (*_event_handler)(bc_sht30_t *, bc_sht30_event_t, void *);
49  void *_event_param;
50  bool _measurement_active;
51  bc_tick_t _update_interval;
52  bc_sht30_state_t _state;
53  bc_tick_t _tick_ready;
54  bool _humidity_valid;
55  bool _temperature_valid;
56  uint16_t _reg_humidity;
57  uint16_t _reg_temperature;
58 };
59 
61 
66 
67 void bc_sht30_init(bc_sht30_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address);
68 
73 
74 void bc_sht30_set_event_handler(bc_sht30_t *self, void (*event_handler)(bc_sht30_t *, bc_sht30_event_t, void *), void *event_param);
75 
79 
81 
86 
87 bool bc_sht30_measure(bc_sht30_t *self);
88 
94 
95 bool bc_sht30_get_humidity_raw(bc_sht30_t *self, uint16_t *raw);
96 
102 
103 bool bc_sht30_get_humidity_percentage(bc_sht30_t *self, float *percentage);
104 
110 
111 bool bc_sht30_get_temperature_raw(bc_sht30_t *self, uint16_t *raw);
112 
118 
119 bool bc_sht30_get_temperature_celsius(bc_sht30_t *self, float *celsius);
120 
122 
123 #endif // _BC_SHT30_H
bool bc_sht30_get_humidity_percentage(bc_sht30_t *self, float *percentage)
Get measured humidity as percentage.
Definition: bc_sht30.c:74
Error event.
Definition: bc_sht30.h:19
uint64_t bc_tick_t
Timestamp data type.
Definition: bc_tick.h:16
struct bc_sht30_t bc_sht30_t
SHT30 instance.
Definition: bc_sht30.h:28
bool bc_sht30_get_temperature_raw(bc_sht30_t *self, uint16_t *raw)
Get measured temperature as raw value.
Definition: bc_sht30.c:97
Update event.
Definition: bc_sht30.h:22
bc_sht30_event_t
Callback events.
Definition: bc_sht30.h:16
void bc_sht30_init(bc_sht30_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize SHT30.
Definition: bc_sht30.c:11
void bc_sht30_set_update_interval(bc_sht30_t *self, bc_tick_t interval)
Set measurement interval.
Definition: bc_sht30.c:32
size_t bc_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: bc_scheduler.h:18
void bc_sht30_set_event_handler(bc_sht30_t *self, void(*event_handler)(bc_sht30_t *, bc_sht30_event_t, void *), void *event_param)
Set callback function.
Definition: bc_sht30.c:26
bc_i2c_channel_t
I2C channels.
Definition: bc_i2c.h:15
bool bc_sht30_get_humidity_raw(bc_sht30_t *self, uint16_t *raw)
Get measured humidity as raw value.
Definition: bc_sht30.c:62
bool bc_sht30_measure(bc_sht30_t *self)
Start measurement manually.
Definition: bc_sht30.c:48
bool bc_sht30_get_temperature_celsius(bc_sht30_t *self, float *celsius)
Get measured temperature in degrees of Celsius.
Definition: bc_sht30.c:109