MCP3008 voltage values are 2x larger than expected
Posted: Wed Feb 26, 2020 9:02 pm
I'm currently using a MCP3008 and my analog input is coming from an arbitrary waveform generator. The generator is producing a sine wave with a peak to peak voltage of 0.5 and an offset of 0.5 volts. I would expect the MCP3008 to get values between 0.25 and 0.75, but instead I'm getting between 0.5 and 1.5.
Here is the code I'm using:
Pictures of the setup are here: https://imgur.com/a/GtUIoQ7, sorry if they're not clear, I'll take more if necessary.
Thanks in advance!
Here is the code I'm using:
Code: Select all
import os
import time
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 chip select (cs)
cs = digitalio.DigitalInOut(board.CE0)
# create the mcp object
mcp = MCP.MCP3008(spi, cs)
# analog input channel on pin 0
chan0 = AnalogIn(mcp, MCP.P0)
while True:
print("Voltage: ", chan0.voltage)
time.sleep(0.1)
Thanks in advance!