Gyroscope itg3205 problem

ello, I have a problem with a gyroscope (itg3205). It communicate with arduino through i2c. The i2c adress is 0x69. The only thing I get are the same values when I move the gyroscope.

#include <Wire.h> // I2C library, gyroscope
// Gyroscope ITG3200 
//#define GYRO 0x68 //  when AD0 is connected to GND ,gyro address is 0x68.
#define GYRO 0x69  // when AD0 is connected to VCC ,gyro address is 0x69  
#define G_SMPLRT_DIV 0x15
#define G_DLPF_FS 0x16
#define G_INT_CFG 0x17
#define G_PWR_MGM 0x3E
#define G_TO_READ 8 // 2 bytes for each axis x, y, z
// offsets are chip specific. 
int g_offx = 120;
int g_offy = 20;
int g_offz = 93;
int hx, hy, hz, turetemp;
//initializes the gyroscope
void initGyro()
{
 /*****************************************
 * ITG 3200
 * power management set to:
 * clock select = internal oscillator
 * no reset, no sleep mode
 * no standby mode
 * sample rate to = 125Hz
 * parameter to +/- 2000 degrees/sec
 * low pass filter = 5Hz
 * no interrupt
 ******************************************/
 writeTo(GYRO, G_PWR_MGM, 0x00);
 writeTo(GYRO, G_SMPLRT_DIV, 0x07); // EB, 50, 80, 7F, DE, 23, 20, FF
 writeTo(GYRO, G_DLPF_FS, 0x1E); // +/- 2000 dgrs/sec, 1KHz, 1E, 19
 writeTo(GYRO, G_INT_CFG, 0x00);
}
void getGyroscopeData(int * result)
{
 /**************************************
 Gyro ITG-3200 I2C
 registers:
 temp MSB = 1B, temp LSB = 1C
 x axis MSB = 1D, x axis LSB = 1E
 y axis MSB = 1F, y axis LSB = 20
 z axis MSB = 21, z axis LSB = 22
 *************************************/
 int regAddress = 0x1B;
 int temp, x, y, z;
 byte buff[G_TO_READ];
 readFrom(GYRO, regAddress, G_TO_READ, buff); //read the gyro data from the ITG3200
 result[0] = ((buff[2] << 8) | buff[3]) + g_offx;
 result[1] = ((buff[4] << 8) | buff[5]) + g_offy;
 result[2] = ((buff[6] << 8) | buff[7]) + g_offz;
 result[3] = (buff[0] << 8) | buff[1]; // temperature
 }
 //
void setup()
{
 Serial.begin(9600);
 Wire.begin();
 initGyro();
}
//
void loop()
{
 byte addr;
 int gyro[4];
 getGyroscopeData(gyro);
 hx = gyro[0] / 14.375;
 hy = gyro[1] / 14.375;
 hz = gyro[2] / 14.375;
 turetemp = 35+ ((double) (gyro[3] + 13200)) / 280; // temperature
 Serial.print(" X=");
 Serial.print(hx);
 Serial.print(" Y=");
 Serial.print(hy);
 Serial.print(" Z=");
 Serial.print(hz);
 Serial.print(" F=");
 Serial.print(turetemp);
 Serial.print((char)223);
 Serial.println("C");
 delay(50); 
}
//---------------- Functions
//Writes val to address register on ACC
void writeTo(int DEVICE, byte address, byte val) {
  Wire.beginTransmission(DEVICE); //start transmission to ACC 
  Wire.write(address);        // send register address
  Wire.write(val);        // send value to write
  Wire.endTransmission(); //end transmission
}
//reads num bytes starting from address register on ACC in to buff array
 void readFrom(int DEVICE, byte address, int num, byte buff[]) {
 Wire.beginTransmission(DEVICE); //start transmission to ACC 
 Wire.write(address);        //sends address to read from
 Wire.endTransmission(); //end transmission
 
 Wire.beginTransmission(DEVICE); //start transmission to ACC
 Wire.requestFrom(DEVICE, num);    // request 6 bytes from ACC
 
 int i = 0;
 while(Wire.available())    //ACC may send less than requested (abnormal)
 { 
   buff[i] = Wire.read(); // receive a byte
   i++;
 }
 Wire.endTransmission(); //end transmission
}

I connect the gyroscope and arduino: SCL to SCL, SDA to SDA, 3.3v and ground.

I found on the arduino forum a i2c adress scanner.
http://forum.arduino.cc/index.php?PHPSESSID=f37c1cga95b05sespgbop54172&topic=95022.15
But the only thing that I get from the scanner is no device founded. But I don't know if this scanner work are not or is it my gyroscope that is broke. Please can someone help me?

Hi rodale

I guess the ITG3205 is on a breakout board? Can you please post a link to details of the board.

Do you have any pullup resistors connected from SDA to 3.3V and from SCL to 3.3V?

Regards

Ray

I don't have any pull up resistors connected.

http://www.geeetech.com/wiki/index.php/ITG3205_Triple_Axis_Gyroscope_Breakout

On my breakout board is AD0 pin to VCC, it was already soldered together.

Thanks for the link. From the image and the connection diagram on that page, it looks like the breakout board may have the pullup resistors fitted on it.

Do you have the VIO pin connected to 3.3V as well as VDD?

Yes the VIO pin is also connected to the 3.3v.

Some things to try.

Connect the CLK input to GND (it may already be jumpered on the back of the board).

Add 4.7k resistors between SDA and 3.3V, and the same for SCL.

Try the different I2C scanner from this thread:

http://forum.arduino.cc/index.php?topic=197360.0

I tried the different things you suggested . When I use the i2c scanner from the forum thread it still no device found. I connected the CLK to the ground, it was not connected on the breakout board, and use the resistors but it was the same result. Thus this mean that the chip is broken or am I still doing something wrong?

Only other thing I can think of is to turn off internal pullup resistors on the Arduino.

Change your setup() to this (assuming you are using a Uno):

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  pinMode (A4, INPUT);
  digitalWrite (A4, LOW);
  pinMode (A5, INPUT);
  digitalWrite (A5, LOW);  
  initGyro();
}

I bought today a new gyroscope and this one is working. So the previous gyroscope was broken, thanks for helping me.