[9] Troubleshooting

So you just finished interfacing your very first I2C device but it doesn't want to work. Here are some things to check:


1) Verify pull-up resistors. Check if the resistors are connected from SDA to Vcc and from SCL to Vcc. Most third party I2C sensors readily available on the market do not have pull-up resistors. Also, most MCUs do not have built in pull-up resistors in them.


2) Are you using the correct pins for I2C? Check your data sheet and verify.


3) Are you sure that you are using an I2C device? Some I2C devices are marketed as serial devices. Some serial devices are not I2C devices, ie use SPI instead, which is another serial protocol.


4) Verify that the speed you are using is supported by the I2C device. When all else fails go back to using 100kHz.


5) Are you accessing the correct device? Verify the device address you are sending on the I2C bus. Verify that the correct R/W bit is set depending on the operation that you are performing.


6) Getting weird or totally incorrect values? Verify if your I2C device requires a delay period before reading the results. Also note that some EEPROMs are slow. So the value for the delay period should be in the ms (millisecond) range. For I2C devices describes as a “24xx series EPROM, with a different I2C address” but is not actually an EEPROM, you likely have an I2C device that needs a delay period before reading (ie. WRITE => DELAY PERIOD (ms)=> READ).


An oscilloscope and/or a logic analyzer is good to have when troubleshooting problems on the I2C bus.