Help! I2C on Arduino Uno with ADXL345 and ITG3200

Hello people,

I've been having problems communicating using I2C with the Arduino Uno. It frequently freezes without warning, and occasionally Wire.endTransmission() returns 2 or 4 (NACK or other). I tried fixing it for 3 weeks now with no success. I've searched as hard as I can but I can't find anything that solves this problem so please help!

In this thread I will focus on the ADXL345 but the same problems exist with my ITG3200.

My ADXL345 breakout is setup as follows (everything on a breadboard): - VCC to 3.3V from LM1086 regulator (details below) - GND to GND - CS to VCC - INT1 and INT2 not connected - SDO to GND - SDA and SCL to LV TXI pins on Sparkfun's logic level converter (details below)

The LM1086 has 10uF 25V tantalum caps between INPUT and GND and OUTPUT and GND. I tried using the 5V out from the Arduino as INPUT, as well as a 6V battery pack. This made no difference.

The logic level converter's LV and HV pins go to VCC and 5V from Arduino respectively, and the GNDs are common (all common in this setup). The TXO pins go to analog pins 4 and 5 for I2C. They're also connected through pullup resistors to 5V (on the HV side). I tried various values of the resistors, including 1k, 2k, 4k7 and 10k. Same problems every time.

I also tried the other sketches that people have had success with, and the same problems were exhibited. I'm pretty sure the problem isn't with the code. Just in case this is important, I use Arduino 0021 and the Wire.h library. More importantly, I've left almost everything as default to keep things simple. So if I understand the library correctly, the internal pullups are enabled by default and the I2C runs at 100kHz.

I also tried rewiring everything, using different parts of the breadboard (I only have 1), using different wires but of course none of that helped.

Here's a more detailed description of situation. Occasionally when I run the sketch (monitored with the Serial Monitor), everything runs nicely at 500Hz, setup of the sensor, reading from the register and printing the values through Serial. The longest time it has run is about 3 minutes. After that, Wire.endTransmission() will sometimes return many 2s and 4s, sometimes nothing but very quickly the entire program will freeze.

Subsequent resets (using the reset button) will mostly lead to completely unsuccessful sequences. Communication via I2C fails completely. Even a hard reset (power down and up again) doesn't help.

Unfortunately, that is just how it works most frequently. The problem is entirely unpredictable!

I've tried all the ways I can think of and I'm completely out of ideas! Any suggestions?

Thank you very much!

I2C is bidirectional the Level_shifter (Spark-Fun) will not work properly

two resistors and on transistor(or mosfet) per signal is a posible solution

for SCL , and SDA (4 resistors and 2 transistors total)

see:

http://www.mikrocontroller.net/topic/92447

Thanks for replying!

I'm under the impression that the TX lines on the Sparkfun level shifters are bidirectional! I checked the schematics and it seems to me the TX lines (which use the MOSFETs) are bidirectional so they should work for I2C..