I want to connect 8 ADCs to the Raspberry Pi, however, the board has only 2 Chip Enable pins. I searched around a bit and the option that I found was to use arbritrary GPIO pins to act as CE pins. And the place I was referred to look at in order to implement it was: /boot/overlays/README. I opened it up, however, I can neither edit it nor do I understand a lot of what's going on in the file.

  • Which ADCs do you refer to? Also 1 ADC with 8 channels or really 8 ADCs? If multiple ADCs use a port expander if to less GPIOs.
    – LotPings
    Commented Aug 20, 2017 at 19:07
  • LTC2366. Really 8 ADCs. Sorry, I did not get your last part, what do you mean by "If multiple ADCs use a port expander if to less GPIOs"" Commented Aug 20, 2017 at 22:16
  • If you don't have enough GPIOs to connect the 8 ADCs, a port expander like MCP23S17 or MAX7317 would allow you to multiplex the IOs at the cost of more difficult timings/programming.
    – LotPings
    Commented Aug 20, 2017 at 22:38

2 Answers 2


The following will work to allow you to use as many devices as you can find spare GPIO.

Find 8 spare GPIO (i.e. not being used by SPI or anything else in your project). Do not use or connect CE0.

I will refer to them as G1 to G8.

Connect the slave select (or whatever it is called for your chips) of ADC1 to G1, ADC2 to G2, ..., ADC8 to G8.

Connect the other SPI signals (MISO/MOSI/SCLK) in parallel to the ADCs as normal.

Initialise each of G1 to G8 as a high output.

Open the SPI device associated with CE0 (/dev/spidev0.0). Note, nothing should be connected to CE0.

To communicate with ADCx do the following.

  1. Set Gx low.
  2. Do a SPI transfer to the opened SPI device.
  3. Set Gx high.

Repeat as needed for each ADC.

  • Hi Joan, what did you mean when you said open the SPI device associated with CE0? How do I do it and why am I doing that if nothing is connected to CE0? Commented Aug 21, 2017 at 20:31
  • Also, I am using the bcm2835 library with C with which I send 3 bytes of data (the first bit is set to 0, the 2nd is set to 0 for single reading as opposed to differential and the next 3 bits are for the channel number). Does that mean that the only change in my program will be to send another 3 bytes, but the first bit will be 1 instead of 0? Commented Aug 21, 2017 at 20:35
  • Each SPI device is associated with a GPIO for the slave select. When you do a transfer on that device it sets the associated GPIO low, does the transfer, and then sets the associated GPIO high. You are "fooling" the system by ignoring the GPIO it sets (by not connecting it) and toggling the slave select signal yourself. You should not have to make any changes to the data you send to the ADC.
    – joan
    Commented Aug 21, 2017 at 21:26
  • @always-learning-forever: you have to read the datasheet! You must send 2 bytes and read 2 bytes. The channel selection is done lowering the appropriate CS.
    – user51705
    Commented Aug 21, 2017 at 21:28
  • @joan Okay, so the commands where I select the chip and set the polarity of the chip to low, instead of those commands, I just change the GPIO to low and high, right? Commented Aug 21, 2017 at 22:31

The SPI device/driver[*] on a RPi can use: - hardware CS (Chip Select), 1 or 2 for SPI0 and 1 to 3 for SPI1; - software CS, using the NO_CS option (see the docs of the library you are using).

In your case it's better to use only "software" CS. Read the /boot/overlay/README file in the SD card to select the right overlay. To use the software CS you must open the SPI device /dev/spidev0.0 passing the right mode plus the NO_CS flag (0x40)[**]

When you use the software CS it's your duty to assert it: usually high when not used and low to select the slave chip.

It's possible to use a Port Expander or a Multiplexer to save some GPIOs, this will also complicate all!

[*] For simplicity I will not separate the device (hardware) from the driver (software) because they work together.

[**] This says to the driver that must not use the hardware CS, that can be used for other.

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.