I've been trying talk to a MCP3008 ADC from the Raspbeery Pi B+. There are loads of examples of this working out there but I don't seem to be able to configure the port.

I've followed the various posts out there and enabled SPI (using raspi-config), un-blacklisted it, etc

/boot/config.txt has this at the end

lsmod shows the driver spi_bcm2708 and
ls /dev/ shows both spidev0.0 and spidev0.1

The permissions are as follows;

pi@raspberrypi ~ $ ls -l /dev/spi*
crw-rw---T 1 root spi 153, 0 Jan  1  1970 /dev/spidev0.0
crw-rw---T 1 root spi 153, 1 Jan  1  1970 /dev/spidev0.1

I'm running the latest image and started from a fresh download

uname -a
Linux raspberrypi 3.18.7+ #755 PREEMPT Thu Feb 12 17:14:31 GMT 2015 armv6l GNU/Linux

I've installed wiringPi and downloaded spidev_test.c and compiled both but either get nothing or an error for the driver.

When trying to do a loopback test with MSIO and MSOI shorted I get this from spidev_test (I've modified the code to use spidev0.0).

pi@raspberrypi ~/mcp3008 $ ./spidev_test -l
can't set spi mode: Invalid argument

Worth noting that I had to use the spidev_test.c from kernel version 3.14 and not from the version I'm actually running 3.18 (some QUAD mode issue)

Has anyone got the B+ running with 3.18 and a working SPI setup?


You have a misconfiguration.

Remove the device_tree= line from /boot/config.txt. That says not to use device tree. The next line says use device tree for SPI.

Use one or the other, not both.

It's probably best to accept device tree is the future and start using it.

As a separate issue the Linux kernel SPI interface changed recently. You might need to search around for an updated version of spidev_test.c if it's old as it's no longer a reliable test.

However if /dev/spidev0.0 and /dev/spidev0.1 exist you can assume that SPI is functional on your Pi and actually try your own test program.

  • Hi, thanks for the response. I had tried without "device_tree=" and I get the same result. The wiringPi tests and Python tests have similar results. I'm going to try with another Pi I have currently controlling some lights and hopefully confirm if it is a hardware issue. The latest spidev_test.c (from kernel 3.18) just won't build giving this QUAD/DUAL mode error. Not sure why, assuming the Pi has a branched version of 3.18 – David Ritchie Mar 2 '15 at 11:22
  • Are /dev/spidev0.0 and /dev/spidev0.1 present? What permissions do they have, i.e. ls -l /dev/spi* – joan Mar 2 '15 at 12:38
  • Yes they are and the permisions are as follows pi@raspberrypi ~ $ ls -l /dev/spi* crw-rw---T 1 root spi 153, 0 Jan 1 1970 /dev/spidev0.0 crw-rw---T 1 root spi 153, 1 Jan 1 1970 /dev/spidev0.1 – David Ritchie Mar 2 '15 at 13:09
  • Sorry, I've re-read your question and see you already included details. Does the groups command show you are in the spi group? Ignoring spidev-test why do you think the MCP3008 isn't working. If you download my piscope (needs pigpio) you will be able to check on activity. pigpio will also let you read the MCP3008 from the command line for testing purposes. – joan Mar 2 '15 at 13:18
  • ...and to answer your question, I have successfully used SPI on the B+. – joan Mar 2 '15 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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