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?