10-bit ADC (SPI) MCP3008 - 8 Channel

New
Indicative market price: R95.57
-+
34 available
R86.88
Shipping
Standard courier shipping from R60
R60 Standard shipping applies to orders under R100, in most areas in South Africa. R30 Standard shipping applies to orders over R100. Some areas may attract a R30 surcharge. This will be calculated at checkout if applicable.
Check my rate
Free collection from Henley on Klip, Meyerton
The seller allows collection for this item and will be in contact with the full collection address once the order is ready. Ready for collection by Wednesday, 8 May.
Ready to ship in
The seller has indicated that they will usually have this item ready to ship within 2 business days. Shipping time depends on your delivery address. The most accurate delivery time will be calculated at checkout, but in general, the following shipping times apply:
 
Standard Delivery
Main centres:  1-3 business days
Regional areas: 3-4 business days
Remote areas: 3-5 business days
Buyer Protection How you're covered
Get it now, pay later

Product information

Condition:
New
Location:
South Africa
Product code:
777
Bob Shop ID:
613700806
The Raspberry Pi is a great computer but there's just one thing that most hardware hackers will find missing: a few inputs for connecting analog sensors. This is where the MCP3008 chip comes in handy, with eight 10-bit channels accessible over SPI. Thanks to the Raspberry Pi's SPI interfaces and its two 'Chip Select' pins available off of the main GPIO connector, the problem is solved.

Features

  • 10-bit resolution
  • 1 LSB max DNL
  • 1 LSB max INL
  • 8 input channels
  • Analog inputs programmable as single-ended or pseudo-differential pairs
  • On-chip sample and hold
  • SPI serial interface (modes 0,0 and 1,1)
  • Single supply operation: 2.7V - 5.5V
  • 200 ksps max. sampling rate at VDD=5V
  • 75 ksps max. sampling rate at VDD=2.7V
  • Low power CMOS technology
  • 5 nA typical standby current, 2 A max.
  • 500 A max. active current at 5V
  • Industrial temp range: -40C to 85C

Applications

  • Sensor Interface
  • Process Control
  • Data Acquisition
  • Battery Operated Systems

What's in the box?

1 x 10-bit ADC 8 Channel IC

Resources

The following sample assumes that you're running the latest official Raspbian distribution, that you're logged in as root and that you haven't yet customized Raspbian to use SPI from a Python script. By default, the kernel module managing SPI communications is not loaded on Raspbian, so let's ensure that the 'spidev' device is available.

root@raspberrypi:/# lsmodModule                  Size  Used by  snd_bcm2835            12808  0  snd_pcm                74834  1 snd_bcm2835  snd_seq                52536  0  snd_timer              19698  2 snd_seq,snd_pcm  snd_seq_device          6300  1 snd_seq  snd                    52489  5 snd_seq_device,snd_timer,snd_seq,snd_pcm,snd_bcm2835  snd_page_alloc          4951  1 snd_pcm  

If 'spidev' device is not listed, we need to remove it from the kernel module 'blacklist' so that it's automatically loaded on the next boot:

root@raspberrypi:/# nano /etc/modprobe.d/raspi-blacklist.conf  

Put a hash character in front of the 'blacklist spi-bcm2708' statement and save the file:

#blacklist spi-bcm2708  

then, manually load the SPI device:

root@raspberrypi:/# modprobe spidev  

The command should just complete without returning an error. Validate the list of modules:

root@raspberrypi:/# lsmod  Module                  Size  Used by  spi_bcm2708             4401  0  spidev                  5136  0  snd_bcm2835            12808  0  snd_pcm                74834  1 snd_bcm2835  snd_seq                52536  0  snd_timer              19698  2 snd_seq,snd_pcm  snd_seq_device          6300  1 snd_seq  snd                    52489  5 snd_seq_device,snd_timer,snd_seq,snd_pcm,snd_bcm2835  snd_page_alloc          4951  1 snd_pcm  

The 'spidev' device should now be available.

Next, install the 'git' package. It will be needed to install other packages from Github.

apt-get install git-core  

Install the 'python-dev' package. It will be needed to compile the 'py-spidev' package.

apt-get install python-dev  

Download and compile the 'py-spidev' package.

root@raspberrypi:/# cd /home  root@raspberrypi:/home# git clone git://github.com/doceme/py-spidev  root@raspberrypi:/home# cd py-spidev/  root@raspberrypi:/home# python setup.py install  

At this point, SPI is available from Python 2.7. Assuming that you have wired the MCP3008 to the Raspberry Pi's SPI bus using CE0 as the 'chip select' pin, you can read all eight analog inputs using the following Python script.

root@raspberrypi:/home# nano adc.py  

Paste the script below in the editor and save it.

import spidev  import time    spi = spidev.SpiDev()  spi.open(0,0)    # read SPI data from MCP3008 chip, 8 possible adc's (0 thru 7)  def readadc(adcnum):          if ((adcnum > 7) or (adcnum < 0)):                  return -1          r = spi.xfer2([1,(8 adcnum)<<4,0])          adcout = ((r[1]&3) << 8)   r[2]          return adcoutwhile True:          for adcInput in range(0,8):                  print "ADC(", adcInput,")=", readadc(adcInput)          time.sleep(1)  

To execute the script

root@raspberrypi:/home# python adc.py  

Sample output using a 10K Ohm trimpot connected to the ADC's pin 3 and all other pins pulled down to ground using a 10k resistor.

ADC( 0 )= 0  ADC( 1 )= 0  ADC( 2 )= 0  ADC( 3 )= 507  ADC( 4 )= 0  ADC( 5 )= 0  ADC( 6 )= 0  ADC( 7 )= 0  

Credits go to Jeremy for his work on the 'py-spidev' Python module which makes working with the MCP3008 straight forward. Alternatively, checkout wiringPi's SPI functions if you prefer using a 'C' API.

Related Tutorials & Samples

  • Loading I2C, SPI and 1-Wire drivers on the Raspberry Pi
  • Jeremy's Blog: Raspberry Pi hardware SPI analog inputs using the MCP3008
  • wiringPi 'C' API for interfacing with SPI, I2C, GPIOs and more
  • Adafruit Learning Syste Note: Stock is currently available in South Africa for national shipping!

More from this seller

View all
M2.5 x 20mm Male Female Hex Brass Standoff Spacer
R8
R30 shipping
9% OFF
Raspberry Pi Engraved Official Stainless Steel Pen
R150.69 R165.76
R30 shipping
9% OFF
M12 High Resolution Lens, 16MP, 105 FOV, 3.56mm Focal length, Compatible with Raspberry Pi High...
R220.28 R242.31
R30 shipping
9% OFF
Maker UNO Edu Kit (Arduino Compatible)
R371.08 R408.19
Add to cart

Similar products

R30 shipping
Servo Driver HAT (B) Servo Drive Board Right Angle Pinheader for Raspberry Pi 16-Channel 12-bit I2C
R670
R30 shipping
9% OFF
Raspberry Pi Camera Board - "Spy Camera" (5MP) 30cm
R366.45 R403.10
R30 shipping
Robot:bit Plug&Play 5V Multi-functional Expansion Board For Micro:bit
R705
R30 shipping
9% OFF
7.5inch E-Paper E-Ink Display Module for Raspberry Pi Pico, 800480, Black / White, SPI
R1,391.88 R1,531.07