I think you need
import spidev not
import Spidev it is case sensitive.
The
spi.open(0,0) line follows the format spi.open(bus, device) and opens the specified SPI device /dev/spidev-bus.device
You can use the command
find /sys/bus | grep spi in a terminal if you want to view the connected SPI devices. It will show you something a bit like this:-
Code: Select all
pi@raspberrypi ~ $ find /sys/bus | grep spi
/sys/bus/spi
/sys/bus/spi/devices
/sys/bus/spi/devices/spi0.0
/sys/bus/spi/devices/spi0.1
/sys/bus/spi/drivers
/sys/bus/spi/drivers/mcp251x
/sys/bus/spi/drivers/mcp251x/bind
/sys/bus/spi/drivers/mcp251x/module
/sys/bus/spi/drivers/mcp251x/uevent
/sys/bus/spi/drivers/mcp251x/unbind
/sys/bus/spi/drivers/spidev
/sys/bus/spi/drivers/spidev/bind
The pi only presents one SPI bus (bus 0), you are connecting two devices to that bus.
Code: Select all
spi_ce0.open(0,0) # Open SPI bus 0, device 0 (CE0 - aka GPIO8 - header pin 24)
will open one device
Code: Select all
spi_ce1.open(0,1) # Open SPI bus 0, device 1 (CE1 - aka GPIO7 - header pin 26)
will open the other device. CE0 and CE1 are also known as Chip Select or Chip Enable.
Use
spi_ce0.close() and
spi_ce1.close() to close.
Each of your devices has 8 channels.
Can't find the thread you want? Try googling : YourSearchHere site:raspberrypi.org