sds011

package module
v0.0.0-...-2278375 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 7 Imported by: 0

README


SDS011 image
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

Configure your SDS011 sensor

[!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.

Documentation

Overview

Package sds011 is the package for sds011

Index

Constants

This section is empty.

Variables

View Source
var (
	Model     = resource.NewModel("zaporter", "sds011", "v1")
	ModelFake = resource.NewModel("zaporter", "sds011", "v1-fake")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	USBInterface string `json:"usb_interface"`
}

func (*Config) Validate

func (cfg *Config) Validate(path string) ([]string, error)

Validate takes the current location in the config (useful for good error messages). It should return a []string which contains all of the implicit dependencies of a module. (or nil,err if the config does not pass validation).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL