Driver SDS011 Laser Dust Sensor.
More...
Driver SDS011 Laser Dust Sensor.
|
file | sds011.h |
| Interface for controlling SDS011 Laser Dust Sensor.
|
|
file | sds011_internal.h |
| Internal constants etc. for the SDS011 laser dust sensor.
|
|
file | sds011_params.h |
| SDS011 sensor specific configuration.
|
|
|
int | sds011_init (sds011_t *dev, const sds011_params_t *params) |
| Initialize SDS011 Laser Dust Sensor. More...
|
|
void | sds011_power_on (const sds011_t *dev) |
| Enable power supply of SDS011 laser dust sensor. More...
|
|
void | sds011_power_off (const sds011_t *dev) |
| Disable power supply of SDS011 laser dust sensor. More...
|
|
int | sds011_read (sds011_t *dev, sds011_data_t *data) |
| Read measurement values from SDS011 laser dust sensor. More...
|
|
int | sds011_register_callback (sds011_t *dev, sds011_callback_t cb, void *ctx) |
| Register measurement callback. More...
|
|
int | sds011_get_reporting_mode (sds011_t *dev, sds011_reporting_mode_t *mode) |
| Get the current reporting mode of the sensor. More...
|
|
int | sds011_set_reporting_mode (sds011_t *dev, sds011_reporting_mode_t mode) |
| Set the reporting mode of the sensor. More...
|
|
int | sds011_get_working_mode (sds011_t *dev, sds011_working_mode_t *mode) |
| Get current working mode of the sensor. More...
|
|
int | sds011_set_working_mode (sds011_t *dev, sds011_working_mode_t mode) |
| Set working mode of the sensor. More...
|
|
int | sds011_get_working_period (sds011_t *dev, uint8_t *minutes) |
| Get current working period of the sensor. More...
|
|
int | sds011_set_working_period (sds011_t *dev, uint8_t minutes) |
| Set working period of the sensor. More...
|
|
int | sds011_get_fw_version (sds011_t *dev, uint8_t *year, uint8_t *mon, uint8_t *day) |
| Get firmware version of the sensor. More...
|
|
int | sds011_set_dev_id (sds011_t *dev, uint16_t sens_dev_id) |
| Set device ID of the sensor. More...
|
|
◆ anonymous enum
Named return values.
Enumerator |
---|
SDS011_OK | all good
|
SDS011_INVALID_RESPONSE | invalid response
|
SDS011_INVALID_CHKSUM | invalid checksum
|
SDS011_ERROR | internal error
|
Definition at line 43 of file sds011.h.
◆ sds011_reporting_mode
Report mode of the SDS011 sensor.
Enumerator |
---|
SDS011_RMODE_ACTIVE | continuously reporting values
|
SDS011_RMODE_QUERY | sensor needs to be queried
|
Definition at line 53 of file sds011.h.
◆ sds011_working_mode
Work/sleep mode of the SDS011 sensor.
Enumerator |
---|
SDS011_WMODE_SLEEP | laser & fan are disabled
|
SDS011_WMODE_WORK | laser & fan are enabled
|
Definition at line 61 of file sds011.h.
◆ sds011_get_fw_version()
int sds011_get_fw_version |
( |
sds011_t * |
dev, |
|
|
uint8_t * |
year, |
|
|
uint8_t * |
mon, |
|
|
uint8_t * |
day |
|
) |
| |
Get firmware version of the sensor.
- Parameters
-
[in] | dev | device descriptor |
[out] | year | year of the firmware version |
[out] | mon | month of the firmware version |
[out] | day | day of the firmware version |
- Returns
- SDS011_OK on success
-
SDS011_INVALID_RESPONSE when response doesn't match the request
-
SDS011_INVALID_CHKSUM when response checksum is invalid
-
SDS011_ERROR when other error occurred
- Precondition
dev
!= NULL
-
year
!= NULL
-
mon
!= NULL
-
day
!= NULL
◆ sds011_get_reporting_mode()
Get the current reporting mode of the sensor.
- Parameters
-
[in] | dev | device descriptor |
[out] | mode | SDS011_RMODE_ACTIVE: continuously report new values SDS011_RMODE_QUERY: new values need to be requested |
- Returns
- SDS011_OK on success
-
SDS011_INVALID_RESPONSE when response doesn't match the request
-
SDS011_INVALID_CHKSUM when response checksum is invalid
-
SDS011_ERROR when other error occurred
- Precondition
dev
!= NULL
◆ sds011_get_working_mode()
Get current working mode of the sensor.
- Parameters
-
[in] | dev | device descriptor |
[out] | mode | SDS011_WMODE_SLEEP: sensor is in sleep mode (~3 mA) SDS011_WMODE_WORK: sensor is in working mode (~65 mA) |
- Returns
- SDS011_OK on success
-
SDS011_INVALID_RESPONSE when response doesn't match the request
-
SDS011_INVALID_CHKSUM when response checksum is invalid
-
SDS011_ERROR when other error occurred
- Precondition
dev
!= NULL
◆ sds011_get_working_period()
int sds011_get_working_period |
( |
sds011_t * |
dev, |
|
|
uint8_t * |
minutes |
|
) |
| |
Get current working period of the sensor.
- Parameters
-
[in] | dev | device descriptor |
[out] | minutes | working period of the sensor in minutes |
- Returns
- SDS011_OK on success
-
SDS011_INVALID_RESPONSE when response doesn't match the request
-
SDS011_INVALID_CHKSUM when response checksum is invalid
-
SDS011_ERROR when other error occurred
- Precondition
dev
!= NULL
◆ sds011_init()
Initialize SDS011 Laser Dust Sensor.
- Parameters
-
[out] | dev | device descriptor |
[in] | params | device configuration |
- Precondition
dev
!= NULL
-
params
!= NULL
- Returns
- SDS011_OK on success
-
SDS011_ERROR on error
◆ sds011_power_off()
void sds011_power_off |
( |
const sds011_t * |
dev | ) |
|
Disable power supply of SDS011 laser dust sensor.
- Parameters
-
- Precondition
dev
!= NULL
◆ sds011_power_on()
void sds011_power_on |
( |
const sds011_t * |
dev | ) |
|
Enable power supply of SDS011 laser dust sensor.
- Parameters
-
- Precondition
dev
!= NULL
◆ sds011_read()
Read measurement values from SDS011 laser dust sensor.
- Parameters
-
[in] | dev | device descriptor |
[out] | data | pointer for storing the values |
- Returns
- SDS011_OK on success
-
SDS011_INVALID_RESPONSE when response doesn't match the request
-
SDS011_INVALID_CHKSUM when response checksum is invalid
-
SDS011_ERROR when other error occurred
- Precondition
dev
!= NULL
-
data
!= NULL
◆ sds011_register_callback()
Register measurement callback.
The registered callback is executed when new measurements were
received by the sensor. This function should be used together with
active reporting mode of the sensor that automatically sends new
measurements periodically (factory default setting of the sensor).
- Parameters
-
[in] | dev | device descriptor |
[in] | cb | function to be called for new values (NULL for disable) |
[in] | ctx | context pointer that will be handed to the callback |
- Returns
- SDS011_OK on success
-
SDS011_ERROR when error occurred
- Precondition
dev
!= NULL
◆ sds011_set_dev_id()
int sds011_set_dev_id |
( |
sds011_t * |
dev, |
|
|
uint16_t |
sens_dev_id |
|
) |
| |
Set device ID of the sensor.
- Parameters
-
[in] | dev | device descriptor |
[in] | sens_dev_id | ID as one number (ID byte 1 MSB, ID byte 2 LSB) |
- Note
- This setting is persistent even after a full power-cycle! Factory default is an individual ID which is printed next to the serial number barcode. For the number xxxx-abab the ID is 0xabab.
- Returns
- SDS011_OK on success
-
SDS011_INVALID_RESPONSE when response doesn't match the request
-
SDS011_INVALID_CHKSUM when response checksum is invalid
-
SDS011_ERROR when other error occurred
- Precondition
dev
!= NULL
◆ sds011_set_reporting_mode()
Set the reporting mode of the sensor.
- Parameters
-
[in] | dev | device descriptor |
[in] | mode | SDS011_RMODE_ACTIVE: continuously report new values SDS011_RMODE_QUERY: new values need to be requested |
- Note
- This setting is persistent even after a full power-cycle! Factory default is SDS011_RMODE_ACTIVE
- Returns
- SDS011_OK on success
-
SDS011_INVALID_RESPONSE when response doesn't match the request
-
SDS011_INVALID_CHKSUM when response checksum is invalid
-
SDS011_ERROR when other error occurred
- Precondition
dev
!= NULL
◆ sds011_set_working_mode()
Set working mode of the sensor.
- Parameters
-
[in] | dev | device descriptor |
[in] | mode | SDS011_WMODE_SLEEP: put to sleep mode (~3 mA) SDS011_WMODE_WORK: put to working mode (~65 mA) |
- Returns
- SDS011_OK on success
-
SDS011_INVALID_RESPONSE when response doesn't match the request
-
SDS011_INVALID_CHKSUM when response checksum is invalid
-
SDS011_ERROR when other error occurred
- Precondition
dev
!= NULL
◆ sds011_set_working_period()
int sds011_set_working_period |
( |
sds011_t * |
dev, |
|
|
uint8_t |
minutes |
|
) |
| |
Set working period of the sensor.
- Parameters
-
[in] | dev | device descriptor |
[in] | minutes | 0 - 30 new working period of the sensor in minutes 0 for continuous reporting mode 1 - 30 for a period of minutes |
- Note
- For values greater than 0, the active duration (fan, laser enabled) is always fixed to 30 seconds, while the sleep duration is adjusted to give an overall period of
minutes
.
- Returns
- SDS011_OK on success
-
SDS011_INVALID_RESPONSE when response doesn't match the request
-
SDS011_INVALID_CHKSUM when response checksum is invalid
-
SDS011_ERROR when other error occurred
- Precondition
dev
!= NULL