OneWire – Lowest-level of the Maxim OneWire protocol

OneWire implements the timing-sensitive foundation of the Maxim (formerly Dallas Semi) OneWire protocol.

Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126

class busio.OneWire(pin)

Create a OneWire object associated with the given pin. The object implements the lowest level timing-sensitive bits of the protocol.

Parameters:pin (Pin) – Pin connected to the OneWire bus

Read a short series of pulses:

import busio
import board

onewire = busio.OneWire(board.D7)
onewire.reset()
onewire.write_bit(True)
onewire.write_bit(False)
print(onewire.read_bit())
deinit()

Deinitialize the OneWire bus and release any hardware resources for reuse.

__enter__()

No-op used by Context Managers.

__exit__()

Automatically deinitializes the hardware when exiting a context. See Lifetime and ContextManagers for more info.

reset()

Reset the OneWire bus and read presence

Returns:False when at least one device is present
Return type:bool
read_bit()

Read in a bit

Returns:bit state read
Return type:bool
write_bit(value)

Write out a bit based on value.