Description

requestFrom() is used by the controller device to request bytes from a peripheral device. The bytes may then be retrieved with the available() and read() functions.

The optional stop parameter specifies whether to release the I2C bus after the request. If true (default), a stop message is sent, releasing the bus. If false, a restart message is sent instead, keeping the connection active. This prevents another controller device from requesting between messages, allowing one controller to send multiple requests while maintaining control of the bus.

This function is part of the Wire library. See the Wire main page for more information.

Syntax

  • Wire.requestFrom(address, quantity)
  • Wire.requestFrom(address, quantity, stop)

Parameters

  • address: the 7-bit address of the peripheral device to request bytes from. Allowed data types: int.
  • quantity: the number of bytes to request. Allowed data types: int.
  • stop (optional): true sends a stop message and releases the bus after the request. false sends a restart message, keeping the connection active. Default is true. Allowed data types: bool.

Returns

The number of bytes returned from the peripheral device. Data type: byte.