Temperature Sensor
The Temperature sensor class provides access to a temperature sensor (thermometer).
Constructor
Section titled “Constructor”Temperature(options)
Section titled “Temperature(options)”Creates a new Temperature object instance.
Temperature(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 temperature data.
sample()Return Value
Section titled “Return Value”An object with the following property:
temperature- A number that represents the sampled temperature in degrees Celsius.
Examples
Section titled “Examples”const temp = new device.sensor.Temperature({ sensor: { io: device.io.I2C, address: 0x48 }});
const sample = temp.sample();console.log(`Current temperature: ${sample.temperature} °C`);