9dof sensor stick ITG-3200 reading issues

I purchased the 9dof sensor stick and experience issues related to the ITG-3200 sensor readings. The ADXL345 and HMC5883L works fine.

Here is the code for ITG-3200

#include <Wire.h>

#define DEVICE (0x69)    //ITG-3200 device address

void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9200);  // start serial for output
  
  // Wake up the gyro
  Wire.beginTransmission(DEVICE);
Wire.send(0x3E);
Wire.send(0x80);  //send a reset to the device
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE);
Wire.send(0x15);
Wire.send(0x00);  	//sample rate divider
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE);
Wire.send(0x16); 
Wire.send(0x18); // ±2000 degrees/s (default value)
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE);
Wire.send(0x17);
Wire.send(0x05);   // enable send raw values
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE);
Wire.send(0x3E);
Wire.send(0x00);
Wire.endTransmission(); //end transmission
}

void loop()
{
int i = 0;
byte buff[8]; // msb and lsb for all three axes and temp

Wire.beginTransmission(DEVICE); 
Wire.send(0x32);        //sends address to read from
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE); //start transmission to device
Wire.requestFrom(DEVICE, 8);    // request 8 bytes from device

while(Wire.available())   // ((Wire.available())&&(i<8))
{ 
buff[i] = Wire.receive();  // receive one byte
i++;
}
Wire.endTransmission(); //end transmission

  // Parse them
  int temp = buff[1] | (((int)buff[0])<<8);
  int x = buff[2] | (((int)buff[3])<<8);
  int y = buff[4] | (((int)buff[5])<<8);
  int z = buff[6] | (((int)buff[7])<<8);
  char buf[100];
  sprintf(buf, "temp:%d, x:%d, y:%d, z:%d\r\n",temp, x,y,z);
  Serial.print(buf);

  delay(200);
}

and here is the print window, It does not output normal data, it does not change when rotating:

temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968

Any suggestions?

I did some testing with another ITG-3200 sensor (not on the 9dof sensor stick) and its working just fine:

This is very frustrating because it appears on both 9dof sensor sticks I bought from Sparkfun!

#include <Wire.h>

#define DEVICE (0x69)    // ITG-3200 device address

void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9200);  // start serial for output
  
  // Wake up the gyro
Wire.beginTransmission(DEVICE);
Wire.send(0x3E);
Wire.send(0x80);  //send a reset to the device
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE);
Wire.send(0x15);
Wire.send(0x00);  	//sample rate divider
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE);
Wire.send(0x16); 
Wire.send(0x18); // ±2000 degrees/s (default value)
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE);
Wire.send(0x17);
Wire.send(0x05);   // enable send raw values
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE);
Wire.send(0x3E);
Wire.send(0x00);
Wire.endTransmission(); //end transmission
}

void loop()
{
int i = 0;
byte buff[8]; // lsb and msb for all three axes

Wire.beginTransmission(DEVICE); 
Wire.send(0x1B);        //sends address to read from
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE); //start transmission to device
Wire.requestFrom(DEVICE, 8);    // request 6 bytes from device

while(Wire.available())   // ((Wire.available())&&(i<8))
{ 
buff[i] = Wire.receive();  // receive one byte
i++;
}
Wire.endTransmission(); //end transmission



  // Parse them
  int temp = buff[1] | (((int)buff[0])<<8);
  int x = buff[3] | (((int)buff[2])<<8);
  int y = buff[5] | (((int)buff[4])<<8);
  int z = buff[7] | (((int)buff[6])<<8);
  int tempc = 35.0+((temp+13200)/280.0); // temperature in degree Celsius
  char buf[100];
  sprintf(buf, "tempc:%d,x:%d, y:%d, z:%d\r\n",tempc,x,y,z);
  Serial.print(buf);

  delay(200);
}

Correct readings from ITG-3200 sensor (not on the sensor stick) in print window:

tempc:25,x:-25, y:92, z:-21

tempc:25,x:-26, y:94, z:-24

tempc:26,x:-36, y:92, z:-31

tempc:25,x:817, y:747, z:243

tempc:25,x:3261, y:-286, z:604

tempc:26,x:-5083, y:194, z:165

tempc:25,x:13442, y:93, z:420

tempc:25,x:-17854, y:-598, z:-3342

tempc:25,x:-1128, y:-250, z:556

tempc:25,x:8751, y:-88, z:1404

tempc:25,x:-13454, y:651, z:-1572

tempc:25,x:19688, y:1327, z:182

tempc:25,x:-6441, y:-1456, z:-3122

tempc:25,x:-1357, y:-897, z:361

tempc:25,x:4745, y:-417, z:1388

tempc:25,x:-1738, y:133, z:-387

tempc:25,x:-3618, y:-208, z:-495

tempc:25,x:-2597, y:153, z:484

tempc:25,x:-769, y:49, z:7

tempc:25,x:6240, y:-514, z:327

tempc:25,x:6171, y:-892, z:566

tempc:25,x:136, y:268, z:820

tempc:25,x:501, y:562, z:499

tempc:25,x:-2344, y:-580, z:-687

tempc:25,x:-1241, y:-2033, z:896

Strange readings from the ITG-3200 on the sensor stick 1:

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

tempc:85,x:-17433, y:-17689, z:-17498

Strange readings from the ITG-3200 on the sensor stick 2:

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

tempc:65,x:24299, y:-3816, z:-1889

Hi there…

Please help me out in the following issue…We have to submit our project and the following issue is causing problem…

I am currently working on the interfacing of 9D0F Razor IMU with Arduino Mega 2560.I have bought the following IMU unit from you people.

9 Degrees of Freedom - Razor IMU

http://www.sparkfun.com/products/9623

When i connect the above mentioned IMU unit and Arduino Mega2560 board using Arduino IDE v1.0 software according to the following Sketch…

/*

Read data from the 9DOF Razor IMU board via arduino mega2560 board and send to the serial monitor of your Arduino Environment on your Computer continuously.

  1. Upload this Sketch to the Arduino board

  2. Disconnect the USB cable from the PC.

  3. Connect the jumper wires between the two boards according to the following table:

9DOF Razor IMU | Arduino Mega2560

---------------|--------------------

TX0…|RX1(Pin19)…

RX1…|TX1(Pin18)…

3.3V…|3V3…

GND…|GND…

---------------|--------------------

  1. make sure to turn on your IMU with the ON/OFF button given on th IMU Board.

5.Connect again the USB Cable to the PC.

  1. Open Serial Monitor.

7.set the baudrate of serial monitor(38400) according to the one given in Serial.begin(38400);

8.Now you will see the data continuously coming to your serial monitor.

*/

void setup()

{

Serial.begin(38400);

Serial1.begin(38400);

}

void loop()

{

if(Serial1.available())

{

char data = Serial1.read();

Serial.print(data);

}

}

I compile and upload this sketch in Arduin Mega2560 board…I get the data in the following form…

$, 1.23, 3.60, 4.70, #

$, -1.23, 3.60,8.70, #

$, 7.00, -3.60, 4.70, #

$, 1.23, 3.60, 4.70, #

$, 6.23, 4.60, 0.70, #

$, 1.23, 3.60, 4.70, #

$, -1.23, -3.60, 5.70, #

and so on.

The problem is that these above values are of Gyroscopes Roll,Pitch and yaw values respectively…

I want to get the data of 3 axis Accelerometer, 3 axis Magnetometer,and 3 axis Gyroscopes from this IMU board and print this data onto the Serial monitor of Arduino IDE.

Please help me through this to get the values of the above three sensors…

Waiting for reply…

Thanking you people in advance…

xcskiing:
I purchased the 9dof sensor stick and experience issues related to the ITG-3200 sensor readings. The ADXL345 and HMC5883L works fine.

Here is the code for ITG-3200

#include <Wire.h>

#define DEVICE (0x69) //ITG-3200 device address

void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9200); // start serial for output

// Wake up the gyro
Wire.beginTransmission(DEVICE);
Wire.send(0x3E);
Wire.send(0x80); //send a reset to the device
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE);
Wire.send(0x15);
Wire.send(0x00); //sample rate divider
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE);
Wire.send(0x16);
Wire.send(0x18); // ±2000 degrees/s (default value)
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE);
Wire.send(0x17);
Wire.send(0x05); // enable send raw values
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE);
Wire.send(0x3E);
Wire.send(0x00);
Wire.endTransmission(); //end transmission
}

void loop()
{
int i = 0;
byte buff[8]; // msb and lsb for all three axes and temp

Wire.beginTransmission(DEVICE);
Wire.send(0x32); //sends address to read from
Wire.endTransmission(); //end transmission

Wire.beginTransmission(DEVICE); //start transmission to device
Wire.requestFrom(DEVICE, 8); // request 8 bytes from device

while(Wire.available()) // ((Wire.available())&&(i<8))
{
buff[i] = Wire.receive(); // receive one byte
i++;
}
Wire.endTransmission(); //end transmission

// Parse them
int temp = buff[1] | (((int)buff[0])<<8);
int x = buff[2] | (((int)buff[3])<<8);
int y = buff[4] | (((int)buff[5])<<8);
int z = buff[6] | (((int)buff[7])<<8);
char buf[100];
sprintf(buf, “temp:%d, x:%d, y:%d, z:%d\r\n”,temp, x,y,z);
Serial.print(buf);

delay(200);
}




and here is the print window, It does not output normal data, it does not change when rotating:




temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968
temp:908, x:145, y:200, z:14968




Any suggestions?

Hi there…

Please help me out in the following issue…We have to submit our project and the following issue is causing problem…

I am currently working on the interfacing of 9D0F Razor IMU with Arduino Mega 2560.I have bought the following IMU unit from you people.

9 Degrees of Freedom - Razor IMU

http://www.sparkfun.com/products/9623

When i connect the above mentioned IMU unit and Arduino Mega2560 board using Arduino IDE v1.0 software according to the following Sketch…

/*

Read data from the 9DOF Razor IMU board via arduino mega2560 board and send to the serial monitor of your Arduino Environment on your Computer continuously.

  1. Upload this Sketch to the Arduino board

  2. Disconnect the USB cable from the PC.

  3. Connect the jumper wires between the two boards according to the following table:

9DOF Razor IMU | Arduino Mega2560

---------------|--------------------

TX0…|RX1(Pin19)…

RX1…|TX1(Pin18)…

3.3V…|3V3…

GND…|GND…

---------------|--------------------

  1. make sure to turn on your IMU with the ON/OFF button given on th IMU Board.

5.Connect again the USB Cable to the PC.

  1. Open Serial Monitor.

7.set the baudrate of serial monitor(38400) according to the one given in Serial.begin(38400);

8.Now you will see the data continuously coming to your serial monitor.

*/

void setup()

{

Serial.begin(38400);

Serial1.begin(38400);

}

void loop()

{

if(Serial1.available())

{

char data = Serial1.read();

Serial.print(data);

}

}

I compile and upload this sketch in Arduin Mega2560 board…I get the data in the following form…

$, 1.23, 3.60, 4.70, #

$, -1.23, 3.60,8.70, #

$, 7.00, -3.60, 4.70, #

$, 1.23, 3.60, 4.70, #

$, 6.23, 4.60, 0.70, #

$, 1.23, 3.60, 4.70, #

$, -1.23, -3.60, 5.70, #

and so on.

The problem is that these above values are of Gyroscopes Roll,Pitch and yaw values respectively…

I want to get the data of 3 axis Accelerometer, 3 axis Magnetometer,and 3 axis Gyroscopes from this IMU board and print this data onto the Serial monitor of Arduino IDE.

I saw your code and i noticed that you are using Wire library in order to get data from IMU…I am confused…I made the above simple program for ATmega2560 in Arduino Mega 2560 board and then i upload the program in it and then i connect it with imu and then i get the values as mentioned above…

Please tell me the code if it uses wire library communication in order to get data from the IMu…

Please help me through this to get the values of the above three sensors…

Waiting for reply…

Thanking you people in advance…