The MCP3008 integrated circuit (IC) chip is an analog to digital converter.
The three areas that must be addressed to collect data with the MCP3008 are, hardware and software and interfacing.
The section on “Enabling SPI Interface of Raspberry Pi” was found in the following link;
The command above will bring up the configuration tool.
Next go to the interfacing options.
Enable the SPI.
Hardware requirements are to have the MCP3008 wired per the method show in the link;
Connection Between Raspberry Pi and MCP3008
WARNING: do not attempt to wire up any devices while the RPi is running.
Place the MCP3008 on the breadboard and wire it up before connecting the ribbon cable to the RPi. Only after rechecking the wiring boot up RPi.
Software requirements can be satisfied using the following pip command;
sudo pip3 install adafruit-circuitpython-mcp3xxx
The documentation can be found here;
Run the command above to satisfy the software requirements.
Python example for the MCP3008 found here;
MCP3008 Single Ended:
import busio import digitalio import board import adafruit_mcp3xxx.mcp3008 as MCP from adafruit_mcp3xxx.analog_in import AnalogIn # create the spi bus spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI) # create the cs (chip select) cs = digitalio.DigitalInOut(board.D5) # create the mcp object mcp = MCP.MCP3008(spi, cs) # create an analog input channel on pin 0 chan = AnalogIn(mcp, MCP.P0) print('Raw ADC Value: ', chan.value) print('ADC Voltage: ' + str(chan.voltage) + 'V')
The following link demonstrates one method for connecting a photoresistor to the RPi through the MCP3008.
The following fritzing diagram was found in the above link.