Skip to main content

Register

The sensor client exposes pressure register object. We can read the register value to retreive the air pressure sensor last reading. The reading is in hPa and should be around 1000.

subscribe

const sensor = new ds.AirPressure()
sensor.reading.subscribe(async pressure => {
console.data({ pressure })
})

To apply filtering or thresholding on the changes, see observables.

unsubscribe

The subscribe method returns an unsubscribe callback.

const sensor = new ds.AirPressure()
const unsubscribe = sensor.reading.subscribe(async pressure =>
console.data({ pressure })
)

// cleanup
unsubscribe()

read

You can also read the sensor data using the read function.

const sensor = new ds.AirPressure()

const pressure = await sensor.reading.read()