SPI#

SPI on the micro:bit is supported in the micro:bit runtime through the ARM mbed SPI class. However, by design, this is this is not initialised by default as part of the uBit object.

The reasons for this are:

  • SPI requires the dedicated use of three GPIO pins. Committing these pins would prevent them from being used as general purpose I/O
  • The SPI module also requires a small amount of additional memory to operate, and this is not necessary for the majority of applications

Note

We may wrap SPI in the future and attach it to the MicroBit class to provide lazy initialisation of the SPI module.

In the meantime we recommend you instantiate your own instance of SPI, using the mbed SPI class:

SPI spi(MOSI, MISO, SCK);