Skip to main content

spi.readstring(numberOfChars)

Reads data from the SPI port and returns it as a string

Availability

Device

Parameters

Name Type Description
numberOfChars Integer How many characters to read in from the bus

Returns

String — the characters read from the SPI bus

Description

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 MOSI.

Example Code

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().