Skip to main content

spi.writeread(data)

Sends data to the SPI serial port and simultaneously reads the same amount of data

Availability

Device

Parameters

Name Type Description
data String or blob The data to write to the bus

Returns

String or blob — the data that was read during the write

Description

This method writes to, and concurrently reads data from, the target SPI bus. The size and type of the data returned matches the same as the size and type of the data sent: write ten bytes of data to the bus and ten bytes of data will be clocked in from the bus.

Example Code

The code below provides a very basic example of interacting with an SPI device, first by reading in eight bytes of data and storing it in a blob, and then by reading and writing data in string form simultaneously.