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
make sure there IS a # before blacklist spi-bcm2708
, so it looks like this…
#blacklist spi-bcm2708
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.
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+.
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
Excellent. Thanks :)
The raspi-config tool also includes an option to enable SPI, which automatically works with the 3.18 kernel
http://www.raspberrypi.org/documentation/configuration/raspi-config.md
thanks for the explanations!
Has this changed in newer versions of raspbian?
Yes I think you’re meant to use the GUI config tool now. But it’s still valid for Wheezy
Thanks :-)
There is nothing in raspi-blacklist.conf. What should I do?
Don’t follow these now-outdated instructions, but instead use https://www.raspberrypi.org/documentation/configuration/raspi-config.md (which makes things much easier).
Depends on what distro and how up-to-date it is though :)
If Curl has nothing in his raspi-blacklist.conf file, then presumably his raspi-config is also new enough to have an option to enable SPI ;)
Or, (s)he’s tried to open it in the wrong directory ;p
lol ;-)
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
Yeah – if you look at the date when this page was done, things have changed a bit. It needs an update to the new way :)
i did the above described performa but i couldn’t make spi enable ..so anyone can help me out???