Carbon Monoxide Sensor
The CarbonMonoxide sensor class provides access to a carbon monoxide sensor.
Constructor
Section titled “Constructor”CarbonMonoxide(options)
Section titled “CarbonMonoxide(options)”Creates a new CarbonMonoxide object instance.
CarbonMonoxide(options)Parameters
Section titled “Parameters”options
An object of properties used to construct the class.
sensor- The hardware connection definition.
interval(optional) - The sampling interval in milliseconds.
Instance Methods
Section titled “Instance Methods”sample()
Section titled “sample()”Returns a sample object containing the current CO concentration data.
sample()Return Value
Section titled “Return Value”An object with the following property:
CO- A number that represents the sampled carbon monoxide in parts per million (ppm).
Examples
Section titled “Examples”const sensor = new device.sensor.CarbonMonoxide({ sensor: { io: device.io.I2C, address: 0x31 }});
const sample = sensor.sample();console.log(`CO Level: ${sample.CO} ppm`);