adafruit_onewire.bus

Provide access to a 1-Wire bus.

  • Author(s): Carter Nelson

class adafruit_onewire.bus.OneWireAddress(rom: bytearray)[source]

A class to represent a 1-Wire address.

property crc: int

The 8 bit CRC.

property family_code: int

The 8 bit family code.

property rom: bytearray

The unique 64 bit ROM code.

property serial_number: bytearray

The 48 bit serial number.

class adafruit_onewire.bus.OneWireBus(pin: Pin)[source]

A class to represent a 1-Wire bus.

static crc8(data: array | bytearray | bytes | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray) int[source]

Perform the 1-Wire CRC check on the provided data.

Parameters:

data (ReadableBuffer) – 8 byte array representing 64 bit ROM code

property maximum_devices: int

The maximum number of devices the bus will scan for. Valid range is 1 to 255. It is an error to have more devices on the bus than this number. Having less is OK.

readinto(buf: array | bytearray | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray, *, start: int = 0, end: int | None = None) None[source]

Read into buf from the device. The number of bytes read will be the length of buf.

If start or end is provided, then the buffer will be sliced as if buf[start:end]. This will not cause an allocation like buf[start:end] will so it saves memory.

Parameters:
  • buf (~WriteableBuffer) – Buffer to write into

  • start (int) – Index to start writing at

  • end (int) – Index to write up to but not include

reset(required: bool = False) bool[source]

Perform a reset and check for presence pulse.

Parameters:

required (bool) – require presence pulse

scan() List[OneWireAddress][source]

Scan for devices on the bus and return a list of addresses.

write(buf: array | bytearray | bytes | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray, *, start: int = 0, end: int | None = None) None[source]

Write the bytes from buf to the device.

If start or end is provided, then the buffer will be sliced as if buffer[start:end]. This will not cause an allocation like buffer[start:end] will so it saves memory.

Parameters:
  • buf (ReadableBuffer) – Buffer containing the bytes to write

  • start (int) – Index to start writing from

  • end (int) – Index to read up to but not include

exception adafruit_onewire.bus.OneWireError[source]

A class to represent a 1-Wire exception.

adafruit_onewire.device

Provides access to a single device on the 1-Wire bus.

  • Author(s): Carter Nelson

class adafruit_onewire.device.OneWireDevice(bus: OneWireBus, address: OneWireAddress)[source]

A class to represent a single device on the 1-Wire bus.

readinto(buf: array | bytearray | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray, *, start: int = 0, end: int | None = None) None[source]

Read into buf from the device. The number of bytes read will be the length of buf.

If start or end is provided, then the buffer will be sliced as if buf[start:end]. This will not cause an allocation like buf[start:end] will so it saves memory.

Parameters:
  • buf (WriteableBuffer) – Buffer to write into

  • start (int) – Index to start writing at

  • end (int) – Index to write up to but not include

write(buf: array | bytearray | bytes | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray, *, start: int = 0, end: int | None = None) None[source]

Write the bytes from buf to the device.

If start or end is provided, then the buffer will be sliced as if buffer[start:end]. This will not cause an allocation like buffer[start:end] will so it saves memory.

Parameters:
  • buf (ReadableBuffer) – buffer containing the bytes to write

  • start (int) – Index to start writing from

  • end (int) – Index to read up to but not include