I have wired according to these instructions.


I tried the methods of getting the value at the bottom of the page and it told me that there was a read error. naturally, i tried a different method, python

#Read a value from analogue input 0
#in A/D in the PCF8591P @ address 0x48
from smbus import SMBus

bus = SMBus(1)

print("Read the A/D")
print("Ctrl C to stop")
bus.write_byte(0x48, 0) # set control register to read channel 0
last_reading =-1

while(0 == 0): # do forever
    reading = bus.read_byte(0x48) # read A/D
    if(abs(last_reading - reading) > 2):
        last_reading = reading

that threw an error saying it to couldn't read the input. After several google searches, I found a fix that was simply bad wiring. I have reattached everything. still no different result. Any thoughts on how to fix this?


Check with i2cdetect that your device is indeed being scanned. Also, the original Pis had the i2c bus as bus 0, not bus 1; maybe that's your problem?

Also, the proper way to do an infinite loop in Python is while True:

  • I did i2cdetect -y 1 and it showed up in 48. Apr 14 '16 at 15:29
  • what is the actual error?
    – JayEye
    Apr 14 '16 at 15:43
  • I2cget -y 1 0x48 Apr 14 '16 at 16:24
  • Error: Read Failed Apr 14 '16 at 16:24
  • I mean, what does errno contain? "read failed" is not what the OS returns.
    – JayEye
    Apr 14 '16 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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