Arduino UNO I2C Problems

Hi!
I’m trying to connect an IMU 6DOF to my Arduino UNO using I2C protocol.
Days ago I can use it and obtain some data, but today when I load my sketch to the Arduino it seems that it can’t write to IMU and configure it.
I’m connecting A4 to SDA and A5 to SCL, is it correct? What’s happening?

Thank you!

accel_gyro.ino (3.1 KB)

Check the connections of the two pullup resistors to the I2C lines.

Do you have any other sensor that could be I2C interfaced. Then, configure it using i2c scanner code so that you can verify your connections are correct or not.
If that gets scanned try configuring IMU also with the same code.Otherwise you are facing the problem with the sensor hardware and you need to change it.

If not , I think you should connect 4.7k pull up resistors on SDA and SCL line if sensor is also not having on board pull up resistors and since your sensor has a 3.3 voltage regulator power it up by 5V available on Arduino UNO.

For the code if everything gets working, you can refer to [url=http://[ITG-3200](ITG3200/ITG-3200.ino at master · ControlEverythingCommunity/ITG3200 · GitHub) and ADXL345 Arduino . These are the two modules in your sensor. I hope it gets worked out.

Thank you, all works fine now! It was an Arduino hardware error. :frowning:

The 400kHz is high for the I2C bus, I hope you don't use long wires.
The readFrom() contains a bug, the Wire.requestFrom() should not be encapsulated by Wire.beginTransmission() and Wire.endTransmission(). Those two can be removed.