Reads data from the SPI port and returns it as a string
Device
Name | Type | Description |
---|---|---|
numberOfChars | Integer |
How many characters to read in from the bus
|
String — the characters read from the SPI bus
This method reads a specified quantity of data from the target SPI bus and returns it as a string. If the SPI is configured for full duplex operation, the same number of zero bytes will be automatically clocked out of COPI (controller out, peripheral in)
COPI was previously referred to as MOSI.
The code below provides a very basic example of interacting with an SPI device, initially by reading in eight bytes of data into a string variable using spi.readstring().