Skip to content

Temperature Sensor

The Temperature sensor class provides access to a temperature sensor (thermometer).

Creates a new Temperature object instance.

Temperature(options)

options

An object of properties used to construct the class.

sensor - The hardware connection definition.

interval (optional) - The sampling interval in milliseconds.

Returns a sample object containing the current temperature data.

sample()

An object with the following property:

temperature - A number that represents the sampled temperature in degrees Celsius.

const temp = new device.sensor.Temperature({
sensor: {
io: device.io.I2C,
address: 0x48
}
});
const sample = temp.sample();
console.log(`Current temperature: ${sample.temperature} °C`);

Temperature