MCP-3903 is a 6-channel synchronous 16-bit ADC.I have done the wiring of MCP-3903 i.e connected SCK,SDO & SDI with SPI_CLCK,SPI_MISO , SPI_MOSI of R pi, now I wanted to write a python program to read data from this 16-Bit ADC. Kindly help in finding the appropriate Python library for SPI interfacing of this IC.

  • What's wrong with the plain 'ol spidev?
    – goldilocks
    May 17, 2015 at 14:28
  • Thanks, nothing is wrong with it. Actually I am new at Python so I didn't know that this library is available in python..
    – Talha_191
    May 17, 2015 at 17:12

2 Answers 2


There are two popular approaches to using the Raspberry Pi to drive a SPI interface: you can either use Hardware SPI, or you could use bit-banged SPI.


No matter whether you use Hardware SPI or bit-banged SPI, you'll need to connect some pins of the MCP3903 to your processor. As you've probably already figured out, you need to connect several pins of that chip to the Raspberry Pi:

  • MCP3903 pin 17 and pin 18 to Rasp GND -- "AGND ... must be connected to the same ground as DGND"; p. 15.
  • MCP3903 pin 26 SDI to Rasp SPI_MOSI
  • MCP3903 pin 25 SDO to Rasp SPI_MISO
  • MCP3903 pin 24 SCK to Rasp SPI_CLK
  • MCP3903 pin 23 nCS to some Rasp GPIO pin, perhaps "CE0_N" (some SPI devices work with their nCS tied to ground, but it appears that at least some features of the MCP3903 require a processor to drive the nCS high and low at the appropriate times)
  • MCP3903 pin 28 DVDD to Rasp 3V3 (or some other 3.3 V power)
  • MCP3903 pin 1 AVDD to Rasp 5V Power (or some other 5 V power) -- "Proper decoupling capacitors (0.1 µF ceramic and 10 µF tantalum) should be mounted as close as possible to the AVDD pin" p. 28
  • MCP3903 pin nRESET to some Rasp GPIO pin (it is unclear if tying this pin to GND will work)
  • (optional) MCP3903 pin 18 nDRA to some Rasp GPIO pin to detect the data ready status (apparently you could leave nDRA unconnected, and read the same status bit through SPI communications).

You'll want to read the MCP3903 datasheet to see if I got any of the above wrong, and for many other tips.

Hardware SPI

In principle, any one of these tutorials should have all the information you need. In practice, different people find different tutorials more or less understandable.

While it's far more complicated than what you need, you might like to check out how people drive other SPI devices using Python on a Raspberry Pi -- many programmers find it easier to start with code does a lot more that more than they want, and then trim it down:

Bit-banged SPI



There doesn't appear to be a great deal of choice on the Pi.

The Python spidev module is the obvious choice for Python. https://github.com/doceme/py-spidev seems to be the one mainly used on the Pi.

The only other choice I'm aware of (apart from bit banging) is my own pigpio Python module. See spi_open.

An advantage of my module is that it supports both the standard (2 channels) and auxiliary (3 channels) SPI peripherals on the recent Pis, and it works over the network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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