title: Access A/D converter using spidev in Python
body: <p>I'm working on a project where I want to collect a voltage input using the 24 bit ADS1211U A/D converter and a Raspberry pi 2 model B.</p>
  
  <p>I've installed the latest spidev module in python 3 and according to the datasheet of the A/D I'm supposed to send one byte to instruct the A/D what I want (to read from the data output register) and then read three bytes (24 bits of information).</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>import spidev
  from time import sleep
  
  # Open SPI bus
  spi = spidev.SpiDev()
  spi.open(0,0)
  
  sleepTime = 0.5
  
  def readADC():
      spi.writebytes([128]) # send '10000000' to read from DOR
      rawData = spi.readbytes(3) # read 24 bits of information
      print(rawData)
  
  try:
      while True:
          readADC()
          sleep(sleepTime)
  except KeyboardInterrupt:
      spi.close()
  </code></pre>
  
  <p>After connecting the MOSI -> MOSI, MISO -> MISO, CLK -> CLK and CS -> CE0, as well as power and GND, I don't seem to get any reading of significance. All I get is 24 zeroes when I run the program.</p>
  
  <p>Is there something essential I've missed regarding the spidev module or <em>should</em> it work only I've messed up the wiring somehow?</p>
  
  <p>The datasheet of the ADS1211U can be found here: <a href="http://www.ti.com/lit/ds/sbas034b/sbas034b.pdf" rel="nofollow">http://www.ti.com/lit/ds/sbas034b/sbas034b.pdf</a></p>
  
  <p>Sorry if I didn't articulate the problem enough, I'll gladly give more information if needed.</p>
  
  <p>Any help would be greatly appreciated!</p>