The Python spidev module uses the Linux SPI driver. The Linux SPI driver sets the SPI GPIO into the appropriate mode when it initialises. Thereafter it assumes the SPI GPIO are in the correct mode.
The correct mode is ALT0 for the main SPI device and ALT4 for the auxiliary SPI device.
By setting the SPI GPIO to the wrong mode you are disconnecting the internal SPI hardware from the SPI GPIO.
Remove all occurrences of the following lines.
GPIO.setup(SCLK,GPIO.OUT)
GPIO.setup(CS,GPIO.OUT)
GPIO.setup(MISO,GPIO.IN)
GPIO.setup(CS,GPIO.LOW)
GPIO.output(CS,GPIO.LOW)
GPIO.output(CS,GPIO.HIGH)
The following code should read channel 0.
#!/usr/bin/env python
import pigpio
import time
pi = pigpio.pi()
if not pi.connected:
exit()
adc = pi.spi_open(0, 1000000, 0)
end_time = time.time() + 10.0
while time.time() < end_time:
count, data = pi.spi_xfer(adc, [0x80, 0])
if count == 2:
print("reading={}:{}".format(data[0], data[1]))
time.sleep(0.1)
pi.spi_close(adc)
pi.stop()