How to enable spi on the Raspberry Pi

 

From the command line (either before typing startx, or double-click LXDE), type…

sudo nano /etc/modprobe.d/raspi-blacklist.conf

You’ll then see

unaltered blacklist file

make sure there IS a # before blacklist spi-bcm2708, so it looks like this…
#blacklist spi-bcm2708

altered blacklist file

If you want to, you can also enable the i2c ports at this time too, by putting a # in front of the last line.
Once you’re done…

CTRL+O save
ENTER confirm
CTRL+X exit

Adding this # prevents SPI being disabled. If you had to change it, you’ll need to reboot to activate SPI.

You will also need to add “dtparam=spi=on” to your config.txt and reboot.

sudo nano /boot/config.txt

add…
dtparam=spi=on
…at the end of the file. Then
CTRL+O save
ENTER confirm
CTRL+X exit

Then reboot…

sudo reboot

And after that, you should be good to go. Enjoy using SPI.

 Posted by at 8:11 am

  20 Responses to “How to enable spi on the Raspberry Pi”

  1. Not quite! You will need to do the following to actually get spi running from python
    remove the comment “#” from the spi-bcm2708 and reboot
    lsmod – to see that spi-bcm2708 is in the list
    install python-dev ” sudo apt-get install python-dev”
    mkdir python-spi
    wget https://raw.github.com/doceme/py-spidev/master/setup.py
    wget https://raw.github.com/doceme/py-spidev/master/spidev_module.c
    Install “sudo python setup.py install”
    Then you will have installed the code you can find a guide at “tightdev.net/SpiDev_Doc.pdf”
    All the best.
    R

    • This page is called “How to enable spi on the Raspberry Pi”, not how to use it in Python. That is covered elsewhere, as appropriate.

      • Where i can find detail “how to use in python”

        Cheers

      • This post helped me finish the rest of the process needed. Should extend the article to include this information. User like me, interested in the subject, wants to know beginning to end in as short amount text as possible. And that has been achieved. A+.

  2. I came across this post looking for a fix to RPI problems with the more recent kernel upgrade (3.18)

    There is one other step to the above that you need to do:

    Add “dtparam=spi=on” to your /boot/config.txt and reboot.

    https://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f?newreg=d5f1e383852548aa9ec8158b694371f9
    http://www.raspberrypi.org/forums/viewtopic.php?p=675658#p675658

  3. thanks for the explanations!

  4. Has this changed in newer versions of raspbian?

  5. There is nothing in raspi-blacklist.conf. What should I do?

  6. lol ;-)

  7. Hello everybody,
    In my case: nogo but I am new to Raspi and Linux ( 2 days, 5lb, no hair).
    For Piface digital2 whicvh is supposed to need spi, it works well without
    Anyway, the blacklist is empty.

    It may be a question of version. For me:
    Raspberry Pi 3 B, 1GB RAM bought 5 days ago;
    Preinstalled NOOBS Raspbian:
    updated, upgraded yester day

    Piface Digital 2
    pigfacedigitalio installed yester day

    It might be a good idea to always state the different versions on any paper anyone publishes

  8. i did the above described performa but i couldn’t make spi enable ..so anyone can help me out???

Leave a Reply