2

I am trying to read digital input using the spi interface on the raspberry pi. Can someone explain why I am getting this UU? I am following this tutorial. I tried troubleshooting (shown below) based on this SO post with no success. I am using this device

pi@raspberrypi ~/Desktop/py-spidev-master $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- UU UU -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
pi@raspberrypi ~/Desktop/py-spidev-master $ i2cget -y 1 0x48
Error: Read failed
pi@raspberrypi ~/Desktop/py-spidev-master $ lsmod | grep i2c_
i2c_dev                 6709  0
i2c_bcm2708             6200  0
pi@raspberrypi ~/Desktop/py-spidev-master $ nano ../PiControl/test.py
pi@raspberrypi ~/Desktop/py-spidev-master $ less ../PiControl/test.py
pi@raspberrypi ~/Desktop/py-spidev-master $ cat ../PiControl/test.py
import spidev
import time
spi = spidev.SpiDev()
spi.open(0,0)
while True:
   resp = spi.xfer2([0x00])
   print resp[0]
   time.sleep(1)
pi@raspberrypi ~/Desktop/py-spidev-master $

Note: when I run the script above I get 0 every one second, despite the fact I have AIN0 connected to 3.3V output

Additional Info:

  • I had the device connected to the 3.3V power, Ground, SDA, and SCLK pins (changed to SCL to match the answer specs)
  • I have a B+ (40 pin)
  • I have not updated the software recently.

    After updating the software I now have:

    pi@raspberrypi ~/Desktop/PiControl $ sudo i2cdetect -y 1
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- 48 -- -- -- UU UU -- --
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- --
    

    1 Answer 1

    3

    SPI and I2C are completely different protocols. They are both serial data based but they use a different number of pins and indeed different pins on the Pi.

    The device you link, a PCF8591, is an I2C device.

    Could you describe how you have connected it to the Pi? If you are following that tutorial you will not have any success as it assumes a SPI device.

    Which model Pi do you have? For recent Pis with the 40 pin expansion header you should be connecting 3V3 (Pi pin 1) to power, ground (Pi pin 6) to ground, SDA (Pi pin 3) to SDA, and SCL (Pi pin 5) to SCL.

    The I2C UU entries are reserved addresses. Have you updated the Pi software recently? I.e. sudo apt-get update, sudo apt-get upgrade.

    6
    • I updated my answer in response to your post. Thanks for the clarification about the difference between i2c and spi....cant believe I missed that! Should I update the Pi to remove the reserved addresses?
      – Rilcon42
      Oct 3, 2015 at 18:33
    • It should be reasonably safe to do a sudo apt-get update and a sudo apt-get upgrade. That may take some time but should get you up to date.
      – joan
      Oct 3, 2015 at 18:52
    • @Rilcon42 Good. It's probably irrelevant to what you want but I have some example PCF8591 code at abyz.co.uk/rpi/pigpio/examples.html (Python and C, some with my pigpio, some without).
      – joan
      Oct 3, 2015 at 23:08
    • That looks awesome, but far above my head...... I will have to work up to it!
      – Rilcon42
      Oct 3, 2015 at 23:16
    • Any chance you could explain how to get the other UU's to go away as well? the 0x48 one is working after updating everything and fixing the incorrect pin, but the others are still UU.
      – Rilcon42
      Oct 4, 2015 at 0:14

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

    Not the answer you're looking for? Browse other questions tagged or ask your own question.