I am having trouble making this gyroscope to work. I can sort of get Z axis readings from it. If I don't move it, the X and Y axises constantly display -1. When I move the gyro, the X and Y would jump a little bit (a few hundred) but as soon as I stop, they go back to -1. Any suggestion is appreciated. Thanks!!
I've struggled with I2C sensors and broken library implementations. In my experience the fastest way to debug the problem is capturing a trace and making sure it looks correct.
There are many common ways to screw up with I2C:
- No pull-ups or too weak pull-ups
- Confusing 7-bit and 8-bit I2C addresses
- Broken software implementation omitting the NACK at the end of a read
- Not using repeated starts when they are required
- SDA and SCL are swapped
Check out my tutorial of I2C with more debugging tips.
For the ITG3200 I would make sure reading the WHO_AM_I register is successful before trying to read the values. Also see this question which details the weirdness of the Vlogic with that gyro.
Try to read WHO_AM_I register first which would return 0x69 or 0x68 depending on your circuit. After that make sure you make the right configuration which requires writing 9 on DLPF_FS register and 25 on SMPLRT_DIV ( this configurations are default, you might need different divider and remove Low pass filter etc. ). IF all is well and still you get the same result, it would be working properly. Gyroscopes works with the motion change rule. It does not calculate your angle but it calculates the angle change in time. Returning -1 and change on the movement seems fine to me. Also you need to consider that these are the ADC values and ITG-3200 has a inner adc values. You need to hold it still and test the results to get the best outcome.