onewire — One Wire

The one-wire bus is a peripheral serial expansion bus technology introduced by Dallas Semiconductor in the United States. It differs from SPI and I2C serial data communication methods. It uses a single signal line to transmit both the clock and the data, and data transmission is bidirectional. It has many advantages, such as saving I/O lines, simple resource structure, low cost, and easy bus expansion and maintenance.

The one-wire bus is suitable for single-master systems and can control one or more slave devices. The master can be a microcontroller, and the slave can be a one-wire device. Data exchange between them passes through only one signal line. When there is only one slave device, the system can operate as a single-node system; when there are multiple slave devices, the system operates as a multi-node system. Figure 12-1 shows a one-wire multi-node system.

../../../../../../_images/ss0_baidu_com_cd2141b72e.jpg

Diagram of a one-wire multi-node system

OneWire Class

class onewire.OneWire(pin)

Construct a OneWire class.

  • pin - a machine.Pin instance object.

onewire.reset(required=False)
onewire.readinto(buf)

Read bytes.

onewire.write(buf)

Write bytes.

onewire.select_rom(rom)
onewire.scan()

Scan the devices on the bus.

onewire.crc8(data)