ESP32 SPI Example help


I wanted to try SPI on my ESP32 Devkit. I was reading the SPI class
Its confusing to me.
It states:
class Spi(nss, drvname=SPI0, clock=12000000, bits=SPI_8_BITS, mode=SPI_MODE_LOW_FIRST)

Yet, does not mention what “nss” is.

It also says "Spi is initialized by passing the driver name drvname, in the form of SPI0, SPI1, etc… "
yet the examples show:
s0 = spi.Spi(D0)
when I tried just adding this it compiled ok (which makes no sense, because D1 is not one of the specified parameters) .
s1 = spi.Spi(D1,clock=8000000)

Yet from the docs I should be able to do this, but yet I get an error ([error] Can’t find name [SPI_MODE_LOW_FIRST] ).
s1 = spi.Spi(D1,clock=8000000,mode=SPI_MODE_LOW_FIRST)

Am I doing something wrong, or is it just messed up ?


Hi seulater,

You’re right; this is a bug in our documentation  :#
nss is the chip select of your SPI peripheral (D0, D1, etc. - a digital pin connected to the chip select of your sensor/actuator) and dvrname is the peripherals name (SPI0, SPI1, etc. - it comprehends the MOSI, MISO, CLK pins of the peripheral - see the pin mapping of the device in peripheral view).

If you search SPI, in the Example view of the Zerynth Studio, you can find all spi usage example related to our supported libraries and, under “your_home/zerynth2/dist/r2.0.11/libs/official” you can find the related source files, where you can see a spi subclass implementation.

Let me know if this can help you, and if you need more support, you can post here some line/reference of your code. :slight_smile: