1

New member (Pete) here, and I have delayed seeking help from a forum for the first month of my efforts with Pi, figuring I might in some ways remember things better if I work through the learning curve myself. Talking of remembering I’m the wrong side of 70 now and short term memory is becoming an issue- lots of repetition usually sorts it. In the past I’ve done lots of home automation stuff using the Picaxe platform so not a complete newbie but C++ code seems a step up from Basic. Anyway, my specific issue here is that I cannot find/download/install/import a code snippet called spidev. I am trying to hook up up an MCP2003 ADC to as I need to analyse an analogue voltage, what with Pi lacking an analogue input. All web advice/tutorials so far states that spidev is needed, but I cannot persuade pi to install it. In fact using Synaptic to check the online ‘store’ it seems not be there so not surprising. Might there be an alternative code? If not can anyone point out a way of accessing an analogue input. I might add that I’ve not got far with I2C either for a 9 axis device, but let’s stick with SPI for now. It may be something stupid on my behalf but I’ve installed lots of other code so far. Final thought- is Spidev not built into Pi these days? I have latest build installed. Thanks, PF

3
  • 1
    If you want help try writing in paragraphs and asking concrete questions. As it stands you appear to be asking vague questions about some unreferenced post you have read.
    – Milliways
    Jan 11 at 11:18
  • You are more likely to get help if you are using the standard Raspberry Pi OS. What do you mean by spidev? Show the code you are using.
    – joan
    Jan 11 at 11:18
  • (1) If you are using Rpi3/4 with latest RpiOS installed, SPI stuff is already built in, but you need to activate it. (2) If you are using Rpi Pico, SPI is also built in. You just need to initialize it (3) For Rpi/Pico I recommend to use Python/MicroPython which is newbie friendly. (4) For Rpi ADC, I recommend MCP3008, which is most popular. Goto AdaFruit or SparkFun for newbies' tutorial. (5) For Pico, ADC is built in. Google Tom's Hardware for newbie friendly tutorial and demo programs. (6) I would recommend Pico over Rpi4B/RpiZ...
    – tlfong01
    Jan 11 at 12:43

2 Answers 2

1

You seem to be thinking of the spidev Linux kernel driver. I don't currently use spi myself (i2c is an alternative in some cases), so what follows involves a bit of guesswork:

On the RPi, I think the driver is included, but you will need to enable support for it using either raspi-config or the device tree via /boot/config.txt. You should be able to find the details you need via an Internet search.

There's also a Python module for interfacing with SPI devices from user space via the spidev linux kernel driver. If you code in Python, this article provides a brief walk-through that may be useful.

I'll stop here, but hopefully this will get you started. Feel free to ask more questions if you like. This is generally a helpful site, and most of the users are cordial; there are exceptions of course, but don't let that put you off. You should take the Tour, and read some of the guidance on asking good questions, etc. Learning how the site works is a small investment that will lead to better answers.

0

If your question is about using the SPI kernel driver things have changed since Device Tree. You should forget any ancient tutorial suggesting the need for a download.

You CAN enable by editing config.txt, but the normal way would be to enable SPI in raspi-config. The same applies for other interfaces, but for many you would be better to use an appropriate dtoverlay.

There is a python module spidev which can be installed using apt.

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.