API documentation¶
|
|
Module that contains the command line app. |
Driver API¶
Low level layer that is in charge to manage communication with the sensor. This is the most reusable part of this package
-
class
pysds011.driver.
SDS011
(ser, log)¶ Main driver class
-
cmd_firmware_ver
(id=b'\xff\xff')¶ Get FW version
- Returns
version description dictionary
- Return type
dict
-
cmd_get_mode
(id=b'\xff\xff')¶ Get active reporting mode
- Parameters
id (2 bytes, optional) – sensor id to request mode, defaults to b’ÿÿ’ that is ‘all’
- Returns
mode if it is ok, None if error
- Return type
int
-
cmd_get_sleep
()¶ Get active sleep mode
- Returns
True if it is sleeping
- Return type
bool
-
cmd_get_working_period
(id=b'\xff\xff')¶ Get current working period
- Returns
working period in minutes: work 30 seconds and sleep n*60-30 seconds
- Return type
int
-
cmd_set_id
(id, new_id)¶ Set a device ID to a specific sensor
- Parameters
id (2 bytes) – ID of sensor that need a new ID (FF FF is in theory allowed too, but be carefull)
new_id (2 bytes) – new ID to be assigned
- Returns
operation result
- Return type
bool
-
cmd_set_mode
(mode=1, id=b'\xff\xff')¶ Set data reporting mode. The setting is still effective after power off
- Parameters
mode (int, optional) – 0:report active mode 1:Report query mode, defaults to 1
id (2 bytes, optional) – sensor id to request mode, defaults to b’ÿÿ’ that is ‘all’
- Returns
True is set is ok
- Return type
bool
-
cmd_set_sleep
(sleep=1, id=b'\xff\xff')¶ Set sleep mode
- Parameters
sleep (int, optional) – 1:enable sleep mode, 0:wakeup, defaults to 1
id (2 bytes, optional) – sensor id to request mode, defaults to b’ÿÿ’ that is ‘all’
- Returns
True is set is ok
- Return type
bool
-
cmd_set_working_period
(period=0, id=b'\xff\xff')¶ - Set working period
The setting is still effective after power off, factory default is continuous measurement. The sensor works periodically and reports the latest data.
- Parameters
period (int) – 0:continuous(default), 1-30 minute work 30 seconds and sleep n*60-30 seconds
- Returns
result
- Return type
bool
-
CLI app API¶
Module that contains the command line app.