I am trying to sample an analog voltage signal on the Raspberry Pi using an MCP3004 ADC. I am using the spidev package and the basic code is something like:
import spidev import time list =  timeout = time.time() + 5 spi = spidev.SpiDev() spi.open(0,0) def getAdc(channel) r = spixfer([1, (8+channel) << 4, 0]) adcOut = ((r&3) << 8 + r voltage = (adcOut * 3.3)/ (1023) list.append(voltage) print(voltage) while time.time()<timout getAdc(0) print(len(list))*
I am running the code for 5 seconds and it gives me around 1000 samples (which is sampling at 200 Hz). Is there a way I can increase this? I need at least 1 kHz.