DS18B20 Onewire Temperature Sensor
Provides an interface for Dallas DS18B20 temperature sensors over the DS2482 onewire bridge
Install
$ npm install ds2482-temperature
Usage
const DS18B20 = ; const sense = ; sense ;
Streaming
const DS18B20 = ; const sense = ; sense ;
API
new DS18B20([options])
Creates an interface for Dallas DS18B20 temperature sensors. The instance inherites from
readable stream
and will search and emit measurements for all found sensors when a data
listener is added.
Options:
wire
an instance of wirei2c
an instance of i2caddress
the i2c address of the bridge chip, default:0x18
device
the location of the i2c interface, default:/dev/i2c-1
units
the temperature units, default:C
pollRate
the rate to poll the sensors when streaming, default:30 secs
sense.init()
Resets the bridge chip and any onewire devices connected to it
Returns: Promise <Uint8>
resolves with DS2482 status register
sense.search()
Searches the bus and returns a list of found temperature sensors
Returns: Promise <Array <Sensor>>
resolves with list of sensors
<Sensor "2826274402000012"> <Sensor "28493331020000bf"> <Sensor "280b135f020000d9">
sense.readTemperatures()
Initiates a measurement and returns the temperature readings from all known sensors
Returns: Promise <Array {rom:String, value:Number, units:Sting}>
resolves with list of temperatures
rom: "2826274402000012" value: 229375 units: "C" rom: "28493331020000bf" value: 22875 units: "C" rom: "280b135f020000d9" value: 219375 units: "C"
sense.destroy()
Destroys the streaming interface
new DS18B20.Sensor(rom [, options])
Creates a temperature sensor instance. The instance inherites from
readable stream
and will emit measurements from the sensor when a data
listener is added.
Arguments:
rom
the ROM address of the sensor as a 16 character hex encoded string
Options:
wire
an instance of wirei2c
an instance of i2caddress
the i2c address of the bridge chip, default:0x18
device
the location of the i2c interface, default:/dev/i2c-1
units
the temperature units, default:C
pollRate
the rate to poll the sensor when streaming, default:30 secs
sensor.readTemperature()
Initiates a measurement and returns the temperature reading from a particular sensor
Returns: Promise <Number>
resolves with temperature
229375
sensor.destroy()
Destroys the streaming interface