API documentation¶
|
|
Module that implements low level communication with Nove SDS011 sensor. |
|
|
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
Module that implements low level communication with Nove SDS011 sensor.
-
class
pysds011.driver.SDS011(ser, log)¶ Main driver class
-
cmd_firmware_ver(id=b'\xff\xff')¶ Get FW version
- Returns
version description dictionary or None if error with fields: ‘year’, ‘month’, ‘day’, ‘id’, ‘pretty’
- 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(id=b'\xff\xff')¶ Get active sleep mode
Take care that sensor will not response to it if it is sleeping. So mainly this API will return 0 or None. None could means: - I’m sleeping, so I cannot reply - I’m not sleeping but something went wrong as responding
- Parameters
id (2 bytes, optional) – sensor id to request sleep status, defaults to b’ÿÿ’ that is ‘all’
- Returns
True if it is sleeping, False if wakeup, None in case of communication error
- 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_query_data(id=b'\xff\xff')¶ Read dust values from the sensor
- Parameters
id (2 bytes, optional) – Sensor ID, defaults to b’ÿÿ’
- Returns
dust data as dictionary
- Return type
dict
-
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¶
Command line interface documentation
pysds011¶
pysds011 cli app entry point
pysds011 [OPTIONS] COMMAND [ARGS]...
Options
-
--port<port>¶ UART port to communicate with dust sensor.
-
--id<id>¶ ID of sensor to use. If not provided, the driver will internally use FFFF that targets all.
-
-v,--verbosity<LVL>¶ Either CRITICAL, ERROR, WARNING, INFO or DEBUG
dust¶
Get dust value
pysds011 dust [OPTIONS]
Options
-
--warmup<warmup>¶ Time in sec to warm up the sensor
-
--format<format>¶ result format (PRETTY|JSON|PM2.5|PM10)
fw-version¶
Get SDS011 FW version
pysds011 fw-version [OPTIONS]
Options
-
--format<format>¶ result format (PRETTY|JSON|PM2.5|PM10)
help¶
Get specific help of a command
pysds011 help [OPTIONS] SUBCOMMAND
Arguments
-
SUBCOMMAND¶ Required argument