I have an MCP3204 12-bit Analog-to-Digital Converter (ADC), and a Raspberrypi.
Does anyone know what I need to plug where to get them to communicate?
Is there an SPI python library I can use?
O am looking to use the onboard GPIO spi which is faster than bit-bangging.

Schematic of MCP3204

Pin Diagram of The PI:
Pin Diagram of The PI

3 Answers 3


Ok, It seems like I found a way.

First, make sure the spi module is enabled. In the file /etc/modprobe.d/raspi-blacklist.conf comment out the line:

#blacklist spi-bcm2708

There is a project called webiopi. The project has a python lib that supports a couple ADCs. The supported ADCs are listed in this page and include the MCP3204. To install just the python library I used:

wget https://webiopi.googlecode.com/files/WebIOPi-0.6.0.tar.gz
tar xzvf WebIOPi-0.6.0.tar.gz
cd WebIOPi-0.6.0/python
sudo python setup.py install

(though I used a virtualenv).

Then I could pull data from the PI using this script, run as SUDO:

from webiopi.devices.analog import MCP3004, MCP3008, MCP3204, MCP3208

# Setup a MCP3204 on SPI CE0
mcp0 = MCP3204()
print mcp0.analogReadAllVolt()

The wiring is as follows (from ADC to Pi):

  1. Vcc and Vref to +3.3
  2. Analog Ground to Ground
  3. SCLK to SP10 SCLK
  4. CS/SHDN to SP10 CE0 N
  5. CH0 to some resistor (or what you want to measure)
  6. Digital ground to ground
  7. Din to SPI MOSI
  8. Dout to SPI MISO

Here is a diagram showing a similar connection I made once to an an AVR to show the pinout of the MCP3204:

the pinout of the MCP3204 connected to an AVR, connections are similar

Would love to hear your comments.


Try WiringPi2-Python from here: https://github.com/Gadgetoid/WiringPi2-Python

You will need to download and build WiringPi first:

git clone git://git.drogon.net/wiringPi && cd wiringPi && sudo ./build

Then try something like this:

import wiringpi2 as wpi
value = wpi.analogRead(70)
  • I saw plenty of articles about the mcp3002, just to make sure - the interface to them is Identical? because they have different bit sizes (12bit vs 10bit).
    – GuySoft
    Commented Jun 4, 2013 at 12:34
  • Ok, got WiringPi2-Python, but it does not work. The source shows its specific to mcp3002. Can anyone confirm this?
    – GuySoft
    Commented Jun 27, 2013 at 23:52

I had some trouble to get it working after Python install. It turned out that the SPI module was not loaded. Check if you have it loaded by lsmod and look (or grep) for SPI

If it is not there try to go into the boot config to set things up

  • I would do sudo apt-get update; sudo apt-get upgrade

  • run sudo raspi-config

  • Select the option to enable SPI. Depending on which version you have it may be in different places in the menu.

I also enabled it to be loaded to kernel at boot. After a reboot it should work.

To find if it works, run lsmod | grep SPI - if you see a SPI in the output it works.

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.