I am using 3 PCF8591 ADC connected via i2c to a raspberry pi.
At first all 3 of the ADC worked. All of a sudden I started having issued with them. Occasionally one of the i2c devices stops showing up (i2cdetect -y 1). And now when reading some devices they show up and connect however they always read 0. I attributed this to a damaged ADC so I replaced it but got the same issue. Sometimes is works, sometimes it doesn't. Often after first starting it will work for about 10 seconds then start reading 0.
This is the layout of the PCB I used. I realised I had forgotten the pull up resistors so I jumpered 2 4.3k resistors from the SDA and SCL pins to 3.3V pin. I haven't had heaps of experience with PCB layouts so I'm wondering if I did something very wrong that is causing the i2c to not work all the time outside of the two pull up resistors I missed. I do not want to get another batch of PCBs made if I have made some other big mistake.
bus = smbus.SMBus(1) def readADCPin(pin): bus.write_byte(address,pin) x = 0 value = 0 numReadings = 4 tot = 0 while x < numReadings: value += bus.read_byte(address) x+=1 value /= numReadings return value
This is the code I am using. As you can see I'm using SMbus to talk to the different devices.