Hello I am i have connected an MCP23S17 spi GPIO expansion, upon testing it with the sample code from here, It does not seem to work. There could be many reasons why this is happening. I would like to narrow down the possible culprits. I would like to first know if my raspberry pi can detect the spi device. Is there an equivalent command for spi that detects if a device is present? Kind of like a ping request in networking.


1 Answer 1


There is no ping command. The best you can do is send a legal command and see a legal response.

I suggest you monitor the SPI bus (MOSI, MISO, SCLK, CS) and check that the correct data is being sent, and if so check that a response is received on MISO.

If you use a bus speed in the 100 kHz region you can use (my) piscope to visualise the bus.

Alternatively use monitor.py to get a console output.

  • thank you for that suggestion sir, will look into it.
    – Jack
    Dec 29, 2019 at 17:00
  • My current lead for me right now is that it would seem i pinned the chip select pin for an ordinary GPIO. Although that there is only 1 device in the spi line and i have set that GPIO to low, it would still not work. I am currently finding ways of using the chip select parameter of the library, but it is not well documented if it is possible to use an ordinary GPIO as chip select. I am not well versed with python do you think you can give the source code a look
    – Jack
    Dec 29, 2019 at 17:11
  • That code only uses one of the standard chip selects CE0 or CE1 (see pinout.xyz) depending on whether 0 or 1 is passed as the select parameter.
    – joan
    Dec 29, 2019 at 17:20
  • i see so unfortunately is cant be changed aside from those two, but theoretically it should still work since the chip is still receiving a low chip select, SPI communications need the CS pin to be help low at all times during communications exchange right?
    – Jack
    Dec 29, 2019 at 17:25
  • Yes, CS is normally high. When you want to talk to the chip you set its CS low, do the transfer, then set it back high.
    – joan
    Dec 29, 2019 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.