Carbon Dioxide Sensor
The CarbonDioxide sensor class provides access to a carbon dioxide sensor.
Constructor
Section titled “Constructor”CarbonDioxide(options)
Section titled “CarbonDioxide(options)”Creates a new CarbonDioxide object instance.
CarbonDioxide(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 CO2 concentration data.
sample()Return Value
Section titled “Return Value”An object with the following property:
CO2- A number that represents the sampled carbon dioxide in parts per million (ppm).
Examples
Section titled “Examples”const sensor = new device.sensor.CarbonDioxide({ sensor: { io: device.io.I2C, address: 0x58 }});
const sample = sensor.sample();console.log(`CO2 Level: ${sample.CO2} ppm`);