![Gitter](https://badges.gitter.im/Join Chat.svg)
Provides an interface for the Dallas DS2482 onewire bridge
$ npm install ds2482
const DS2482 = require('ds2482');
const wire = new DS2482();
wire.init()
.then(() => wire.search())
.then(found => {
console.log(found); // Returns a list of ROM addresses as hex encoded strings
})
.catch(err => {
console.error(err);
});
Creates an interface for a Dallas DS2482 i2c to onewire bridge chip
Options:
i2c
an instance of i2caddress
the i2c address of the bridge chip, default:0x18
device
the location of the i2c interface, default:/dev/i2c-1
Resets the bridge chip and any onewire devices connected to it
Returns: Promise <Uint8>
resolves with status register
Configures the onewire interface for subsequent communication
Options:
activePullup
controls whether to use active or passive pullupstrongPullup
enables strong pullup only after next command then resetsoverdrive
enable overdrive speed for the bridge chip
Returns: Promise <Uint8>
resolves with configuration register
Select the onewire channel to use for subsequent commands
Note: Only for use with DS2482-800
Arguments:
channel
channel to select, defaults to 0
Returns: Promise <Uint8>
resolves with channel selection register
Sends a command to a onewire device if specified or all onewire devices if omitted
Arguments:
command
command to send as an unsigned integerrom
optional ROM address of the device to send the command to as a 16 character hex encoded string
Returns: Promise <Uint8>
resolves with status register
Searches the bus for all onewire devices and returns a list of ROM addresses as hex encoded strings
Returns: Promise <String[]>
resolves with list of roms
[
"2826274402000012",
"2889075f0200003e",
"3ae9f412000000a6"
]
Searches the bus for all onewire devices of a particular family and returns a list of ROM addresses as hex encoded strings
Arguments:
family
the family to search as either an unsigned integer or 2 character hex encoded string
Returns: Promise <String[]>
resolves with list of roms
[
"2826274402000012",
"2889075f0200003e"
]
Searches the bus for the next onewire device and returns the ROM address as a hex encoded string
Returns: Promise <String>
resolves with rom
"2826274402000012"
Reads the ROM address of the single onewire device and returns it as a hex encoded string
NOTE: Will return a CRC mismatch
error if multiple devices are on the bus
Returns: Promise <String>
resolves with rom
Selects a single onewire device to send a command to
Arguments:
rom
the ROM address of the device to select as a 16 character hex encoded string
Returns: Promise <Uint8>
resolves with status register
Selects all onewire devices to send a command to
NOTE: Can only be used for commands that don't return a response
Returns: Promise <Uint8>
resolves with status register
Writes one or more bytes to the onewire bus
Arguments:
data
a single byte, array of bytes or data buffer to be written out
Returns: Promise <Uint8>
resolves with status register
Reads one or more bytes from the onewire bus and returns a data buffer
Arguments:
size
number of bytes to be read in
Returns: Promise <Buffer>
resolves with data buffer
Checks that the crc in the last byte matches the rest of the buffer
Arguments:
buffer
the data buffer to be checked
Returns: Boolean