I2C 'Unreliability'

I am having problems with getting I2C comms to start. Here's the story...

I am trying to get the Sparkfun LSM9DS1 IMU breakout board to work with an Arduino Due. I have hooked up the board's interface to the Arduino with ground and 3.3 volt power and SDA and SCL connected to pins 20 and 21 respectively. The Sparkfun board is unmodified.

The wires are currently around 20cm long.

I am running either Sparkfun's LSM9DS1_Basic_I2C program or my own (very cut down) version and I am monitoring the serial output on the serial monitor on the PC.

The problem is that for some reason the data will not always start (and I see the error which is generated by the if (!imu.begin()) statement).

However, I can get it to start reliably if I power up the board and then, after a few seconds, connect the SDA line. Once it has started it is completely reliable.

Has anyone got any ideas why this might be happening?

does it work if you put a delay(5000) in setup before calling imu.begin()? Sometimes devices require time to start up before you talk to them.

If not - is there a physical pullup resistor on the I2C lines anywhere? If not, add one (4.7 or 10k is good), between each I2C line and 3.3v. If that fixes it, it would imply that the time during startup of the arduino before I2C is enabled (during which time the I2C lines are floating), the device interprets the random transitions of the I2C lines as a malformed attempt to communicate and gets confused.

Thanks DrAzzy,

From the schematic here:


...it seems that SDA and SCL already have pullups on the board. I haven't touched the pads so the pullups are still operational.

I did try a delay of a second or so at some point early on in the code but can't remember where so I will try your suggestion, see if it works and report back...

Seems to be working...fingers crossed!

I think you have the arduino operating at 5V and hopefully the Sparkfun LSM9DS1 IMU breakout board operating at 3.3, that is its rating. I would start checking the voltages to be sure. This response is to help you get started in solving your problem, not solve it for you. Good Luck & Have Fun! Gil

What Arduino?

Many operate at 5V - you'd need to use the 3.3V output to power the board (schematic says Vdd should be 1.8V-3.6V), and add level shifters to the I2C lines. Otherwise you may destroy the chip. This schematic does not show level shifters or regulator,

The Due already has pullups on one of its I2C interfaces. Maybe you have too much pullup now?

The Due is a 3.3v board, not a 5v one. So that part is fine.