Linker kit Base Shield for Raspberry Pi with ADC Interface V3.0
This is a Linker kit base shield for Raspberry Pi with ADC interface. All the Linker kit modules can be plugged onto Raspberry Pi through this base shield. Moreover, this shield has an on-board ADC chip so that analog output modules can be used on Raspberry Pi. The ADC chip used is MCP3004. It talks to Raspberry Pi using SPI interface.
This board is an upgrade edition. It has level protection on board and you can select VCC level to either 3.3V or 5V by a jumper and compatible to Rpi B+.
There are 7 4-pin 2.54mm spacing housing on the base shield:
- JP1: A0, A1, VCC, GND.
- JP2: A2, A3, VCC, GND.
- JP3: SCL, SDA, VCC, GND.
- JP4: RXD, TXD, VCC, GND.
- JP5: P17, P18, VCC, GND.
- JP6: P27, P22, VCC, GND.
- JP7: P23, P24, VCC, GND.
These connectors cover Analog, I2C, and GPIO.
Install Base Shield on Raspberry Pi
The ADC chip used on this base shield is MCP3004 (10 bit resolution, 4 channels, SPI interface). In the following, we are going to cover how to use Python to read the ADC output:
As we use SPI communication, we need to enable SPI module in kernel. To do that, we can edit the blacklist of kernel, and enable spi:
sudo vi /etc/modprobe.d/raspi-blacklist.conf
Locate the line begins with "blacklist spi-bcm2708" and change it to "#blacklist spi-bcm2708".
After this, we can check the module by "lsmod", and observe the following content:
Module Size Used by
spi_bcm2708 4421 0
Now we will install python-pip (pip is a package used to install and manage python software package, and it is used replace esay_install):
sudo apt-get install python-imaging python-imaging-tk python-pip python-dev git
Next, we will install spidev using pip:
sudo pip install spidev
Then we will install WiringPi (the driver for IOs on Raspberry pi, that can be used in C, shell script or Python, etc):
sudo pip install wiringpi
The interface python code for MCP3004 is as following:
Save the above code to a file named linker_adc.py, and enter into the directory to execute:
The following are the results:
91/1023 =>0.293V 93/1023 =>0.300V 94/1023 =>0.303V