Go Down

Topic: I2C 'Unreliability' (Read 329 times) previous topic - next topic

snudge

Nov 23, 2019, 12:12 pm Last Edit: Nov 23, 2019, 12:13 pm by snudge
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?

DrAzzy

#1
Nov 23, 2019, 12:31 pm Last Edit: Nov 23, 2019, 12:36 pm by DrAzzy
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.
ATTinyCore and megaTinyCore for all ATtiny, DxCore for DA/DB-series! github.com/SpenceKonde
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

snudge

Thanks DrAzzy,

From the schematic here:

https://cdn.sparkfun.com/assets/learn_tutorials/3/7/3/SparkFun-LSM9DS1-Breakout-schematic.pdf

...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...

snudge

Seems to be working...fingers crossed!

gilshultz

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

This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

wvmarle

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,
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

MorganS

The Due already has pullups on one of its I2C interfaces. Maybe you have too much pullup now?
"The problem is in the code you didn't post."

DrAzzy

The Due is a 3.3v board, not a 5v one. So that part is fine.
ATTinyCore and megaTinyCore for all ATtiny, DxCore for DA/DB-series! github.com/SpenceKonde
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Go Up