I want to use LCD and mcp3208 simultaneously.

spi0(gpio8,9,10,11) is port for LCD and spi1(gpio16,19,20,21) is port for mcp3208.

spi0 channel is always on and spi1 is opened when I want to collect data.


1) when I checked spidev, there are spidev0.0, 0.1 but spidev1.0,1.1. Should I make spidev1.0 and 1,1? If then, How can I make them??

2) Someone said using PIGPIO. so, I installed pigpio is raspberry pi3. My example code is like below.

import pigpio
import RPi.GPIO as GPIO

pi = pigpio.pi()

if not pi.connected:

# pi.spi_open(0, 1000000, 0)   # CE0, 1Mbps, main SPI
# pi.spi_open(0, 1000000, PI_SPI_FLAGS_AUX_SPI(1)) # CE0, 1Mbps, auxiliary SPI

lcd=pi.spi_open(0, 1000000, 0) # CE0, main SPI
pi.spi_read(lcd, 2)

subprocess.call('setterm -cursor off', shell=True)
subprocess.call('spincl -ib', shell=True)
# pins connected from the SPI port on the ADC to the RPi
SPICLK  = 11
SPICS   = 8

# set up the SPI interface pins


# pin connected to read
sensor_adc0 = 0;
sensor_adc1 = 1;
sensor_adc2 = 2;
sensor_adc3 = 3;
sensor_adc4 = 4;
sensor_adc5 = 5;
sensor_adc6 = 6;
sensor_adc7 = 7;
subprocess.call('clear', shell=True)

def readadc(adcnum, clockpin, mosipin, misopin, cspin):
        mcp = pi.spi_open(0, 1000000, PI_SPI_FLAGS_AUX_SPI(1))
        pi.spi_read(mcp, 1)
        if ((adcnum > 7) or (adcnum < 0)):
                return -1
        GPIO.output(cspin   , True)

        GPIO.output(clockpin, False)  # start clock low
        GPIO.output(cspin   , False)  # bring CS low

        commandout = adcnum
        commandout |= 0x18            # start bit + single-ended bit
        commandout <<= 3              # we only need to send 5 bits here
        for i in range(5):
            if (commandout & 0x80):
                GPIO.output(mosipin, True )
                GPIO.output(mosipin, False)
            commandout <<= 1
            GPIO.output(clockpin, True )
            GPIO.output(clockpin, False)

        adcout = 0

        # read in one empty bit, one null bit and 12 ADC bits
        for i in range(14):
                GPIO.output(clockpin, True )
                GPIO.output(clockpin, False)
                adcout <<= 1
                if (GPIO.input(misopin)):
                        adcout |= 0x1

        GPIO.output(cspin, True)

        adcout >>= 1 # first bit is 'null' so drop it
        return adcout

if __name__ == '__main__':
        sensor0 = readadc(sensor_adc0, SPICLK, SPIMOSI, SPIMISO, SPICS)
        print sensor0

It didn't work.

How can I fix it??

Thank you for your help.

  • The Pi only has kernel drivers for SPI0 with support for 2 channels. In fact you can use more with your own CE code, and/or hardware. There is no driver for SPI1 and it impractical to write one. There is plenty of code which uses SPI1, and supports additional channels. I don't see why the 2 SPI0 channels wouldn't work for your 2 devices, but there is non-kernel code to use SPI1 (I have never had the need).
    – Milliways
    Feb 3, 2017 at 7:30
  • I don't understand what you are trying to do. SPI is a bus system. Only one SPI device can be using the bus at any one instant (the one which has asserted slave select). What is the output of ls /dev/spi*?
    – joan
    Feb 3, 2017 at 9:44
  • How can I fix it??, the best way to fix it is to rewrite your code because it is such a mess. But before you rewrite it, take time to understand how SPI works and read the API document such as pigpio, for how to use spi_open in particular. SPI0 supports two channels by controlling CE0 and CE1 while sharing the rest of the signals (MOSI/MISO/CLK) in a time-division manner, but it can't be used at the same time.
    – hcheung
    Jun 2, 2018 at 0:38

2 Answers 2


just add this to /boot/config.txt and reboot


it should enable auxiliary SPI with SPI1 CE2 (GPIO16) for channel select

see also /boot/overlays/README




Thank you all for the tips.

In my case, just add this to /boot/config.txt and reboot


I changed too in the MFRC522 library the following parameter: /dev/spidev0.0 to /dev/spidev1.0

In the pins were like this:

  • SDA/CE2: 36
  • MISO: 35
  • MOSI: 38
  • SCKL: 40
  • RESET: 13

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.