Raspberry Pi ADC: Analog to Digital Converter Chip MCP3002

Analog to Digital Converter Chip MCP3002

The MCP3002 is an Analog-to-Digital Converter (ADC) integrated circuit (IC), which interfaces with the Serial Peripheral Interface (SPI) of the Raspberry Pi. This IC uses four pins for the SPI interface, as shown by the pink pins in the pinout diagram above. It has a 10-bit resolution, which is good enough for a wide range of applications such as light and temperature sensors. Therefore, if you are planning to build a light detecting sensor, then this chip will work. This is a low power CMOS chip that will operate on a voltage as little as 2.7 V making it ideal for battery-powered applications.

This is the lowest cost IC currently available in an eight-pin PDIP package and therefore popular with hobbyists and students. It has two multiplexed inputs providing a pair of channels for sampling purposes. In addition, it has built-in sample and hold circuitry for that extra control and precision.


Connecting the SPI Pins

Raspberry Pi GPIO Interface SPI

For proper communication between the MCP3002 integrated circuit and the Raspberry Pi, the SPI pins have to connect correctly. Both devices have an SPI interface, which is very simple to connect.

MCP3002 SPI PinsRaspberry Pi SPI Pins
124 or 26
519
621
723

The connection table above shows the SPI pins on the Raspberry Pi GPIO, and their connection to the SPI pins on the MCP2003 IC. Usually, the SPI interface of the MCP2003 IC operates in "Slave" mode, whilst the SPI interface on the Raspberry Pi operates in "Master" mode.

The Raspberry Pi SPI interface can communicate with up to two slave devices. It does that by choosing the slave device through the chip select pin 24 and pin 26. Hence, pin 1 on the MCP2003 can connect to either pin 24 or pin 26. If you are new to this, then choose the pins that your software expects to use. If you are using the Gertboard software then use their pin convention.

Pin 5 on the MCP2003 is "Data In" which connects to pin 19 on the Raspberry Pi GPIO, which is "Master Out Slave In – MOSI"

Pin 6 on the MCP2003 is "Data Out" which connects to pin 21 on the Raspberry Pi GPIO, which is "Master In Slave Out – MISO"

Pin 7 on the MCP2003 requires a clock signal provided by pin 23 on the Raspberry Pi GPIO.

Circuit Diagram

Circuit Diagram

As you can see, either channels CH1 or CH0 may sample analog values. The IC converts this value to digital and transfers it to the Raspberry Pi through the SPI consisting of pins 1, 5, 6, and 7. The chip and circuit are identical to that used on the Raspberry Pi Gertboard, hence any testing software available will work with this.

This Article Continues...

How an Analog-to-Digital Converter ADC Works
Raspberry Pi ADC: Analog to Digital Converter Chip MCP3002
Raspberry Pi Analog Input Circuit
Raspberry Pi LDR Light Sensor Circuit
ADC Circuit: Raspberry Pi Analog Input Circuit on Breadboard
MCP3002
Raspberry Pi SPI
Raspberry Pi Pinout