SDS011 Air quality sensor module for Viam
This module implements the rdk:component:sensor
API and provides two sensor models:
zaporter:sds011:v1
zaporter:sds011:v1-fake
The zaporter:sds011:v1
model supports the SDS011 Nova PM air quality sensor.
The zaporter:sds011:v1-fake
model can be used for testing the module without hardware.
[!NOTE]
For more information, see Modular Resources.
Features
- Hot reloading
- Basic functionality
[!NOTE]
Before configuring your sensor, you must create a machine.
Navigate to the Config tab of your machine's page in the Viam app.
Click on the Components subtab and click Create component.
Select the sensor
type, then select the sds011:v1
model.
Click Add module, then enter a name for your sensor and click Create.
On the new component panel, copy and paste the following attribute template into your sensor’s Attributes box:
{
"usb_interface": "<PATH TO USB PORT WHERE YOUR SENSOR IS PLUGGED IN>"
}
Attributes
The following attributes are available for zaporter:sds011:v1
sensors:
Name |
Type |
Inclusion |
Description |
usb_interface |
string |
Required |
Path to the USB port where your sensor is plugged in; see instructions below. |
To find the correct path, SSH to your board and run the following command:
ls /dev/serial/by-id
This should output a list of one or more USB devices attached to your board, for example usb-1a86_USB_Serial-if00-port0
.
If the air quality sensor is the only device plugged into your board, you can be confident that the only device listed is the correct one.
If you have multiple devices plugged into different USB ports, you may need to do some trial and error or unplug something to figure out which path to use.
The v1-fake
model also requires you to assign a value to the usb_interface
attribute, but you can set it as any string since the fake model doesn't actually communicate with any real hardware.
[!NOTE]
For more information, see Configure a Machine.
Example configuration
Example attribute configuration:
{
"usb_interface": "/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0"
}
Output
The sensor returns the following output:
{
"pm_10": float64,
"pm_2.5": float64,
"units": "μg/m³"
}
You can view sensor readings on your machine's Control tab in the Viam app or by using the sensor API.