Firmware SDK
twr_sps30

Driver for SPS30 PM sensor. More...

Typedefs

typedef struct twr_sps30_t twr_sps30_t
 SPS30 instance.
 

Enumerations

enum  twr_sps30_event_t {
  TWR_SPS30_EVENT_ERROR = 0,
  TWR_SPS30_EVENT_UPDATE = 1
}
 Callback events. More...
 

Functions

void twr_sps30_init (twr_sps30_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
 Initialize SPS30. More...
 
void twr_sps30_set_event_handler (twr_sps30_t *self, void(*event_handler)(twr_sps30_t *, twr_sps30_event_t, void *), void *event_param)
 Set callback function. More...
 
void twr_sps30_set_startup_time (twr_sps30_t *self, twr_tick_t startup_time)
 Set startup time (how long the fan blows air before the measurement) More...
 
void twr_sps30_set_update_interval (twr_sps30_t *self, twr_tick_t interval)
 Set measurement interval. More...
 
bool twr_sps30_measure (twr_sps30_t *self)
 Start measurement manually. More...
 
bool twr_sps30_get_mass_concentration (twr_sps30_t *self, twr_sps30_mass_concentration_t *mass_concentration)
 Get measured mass concentration in μg/m3. More...
 
bool twr_sps30_get_number_concentration (twr_sps30_t *self, twr_sps30_number_concentration_t *number_concentration)
 Get measured number concentration in #/cm3. More...
 
bool twr_sps30_get_typical_particle_size (twr_sps30_t *self, float *typical_particle_size)
 Get measured typical particle size in μm. More...
 

Detailed Description

Driver for SPS30 PM sensor.

Enumeration Type Documentation

◆ twr_sps30_event_t

Callback events.

Enumerator
TWR_SPS30_EVENT_ERROR 

Error event.

TWR_SPS30_EVENT_UPDATE 

Update event.

Definition at line 13 of file twr_sps30.h.

Function Documentation

◆ twr_sps30_get_mass_concentration()

bool twr_sps30_get_mass_concentration ( twr_sps30_t self,
twr_sps30_mass_concentration_t *  mass_concentration 
)

Get measured mass concentration in μg/m3.

Parameters
[in]selfInstance
[out]mass_concentrationPointer to mass concentration structure
Returns
true When value is valid
false When value is invalid

Definition at line 75 of file twr_sps30.c.

◆ twr_sps30_get_number_concentration()

bool twr_sps30_get_number_concentration ( twr_sps30_t self,
twr_sps30_number_concentration_t *  number_concentration 
)

Get measured number concentration in #/cm3.

Parameters
[in]selfInstance
[out]number_concentrationPointer to number concentration structure
Returns
true When value is valid
false When value is invalid

Definition at line 90 of file twr_sps30.c.

◆ twr_sps30_get_typical_particle_size()

bool twr_sps30_get_typical_particle_size ( twr_sps30_t self,
float *  typical_particle_size 
)

Get measured typical particle size in μm.

Parameters
[in]selfInstance
[out]typical_particle_sizePointer to typical particle size
Returns
true When value is valid
false When value is invalid

Definition at line 106 of file twr_sps30.c.

Here is the call graph for this function:

◆ twr_sps30_init()

void twr_sps30_init ( twr_sps30_t self,
twr_i2c_channel_t  i2c_channel,
uint8_t  i2c_address 
)

Initialize SPS30.

Parameters
[in]selfInstance
[in]i2c_channelI2C channel
[in]i2c_addressI2C device address

Definition at line 20 of file twr_sps30.c.

Here is the call graph for this function:

◆ twr_sps30_measure()

bool twr_sps30_measure ( twr_sps30_t self)

Start measurement manually.

Parameters
[in]selfInstance
Returns
true On success
false When other measurement is in progress

Definition at line 60 of file twr_sps30.c.

Referenced by twr_sps30_get_typical_particle_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_sps30_set_event_handler()

void twr_sps30_set_event_handler ( twr_sps30_t self,
void(*)(twr_sps30_t *, twr_sps30_event_t, void *)  event_handler,
void *  event_param 
)

Set callback function.

Parameters
[in]selfInstance
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)

Definition at line 35 of file twr_sps30.c.

◆ twr_sps30_set_startup_time()

void twr_sps30_set_startup_time ( twr_sps30_t self,
twr_tick_t  startup_time 
)

Set startup time (how long the fan blows air before the measurement)

Parameters
[in]selfInstance
[in]intervalStartup time

Definition at line 41 of file twr_sps30.c.

◆ twr_sps30_set_update_interval()

void twr_sps30_set_update_interval ( twr_sps30_t self,
twr_tick_t  interval 
)

Set measurement interval.

Parameters
[in]selfInstance
[in]intervalMeasurement interval

Definition at line 46 of file twr_sps30.c.

Here is the call graph for this function: