Its connection test fails, so you would expect it to give a constant output (most likely 0, although they arent initialized here, so any random value could be the case, as long as it is constant).
Normally because connection test fails I would say you really got a wiring error (either I2C, or power supply), or the address pin wrong. But that wouldnt explain the changing values. Although I really would make sure again you didnt mix up SDA and SCL.
Something not really that much related to his specific issue, but still relevant enough to mention: this library uses i2cdev files for i2c communication, so have easy commands for writing/reading stuff, that is handy to have. However this is the read command used in the library:
char command[1];
command[0] = regAddr;
char *redData = (char*)malloc(length);
i2c.write(devAddr<<1, command, 1, true);
i2c.read(devAddr<<1, redData, length);
for(int i =0; i < length; i++) {
data[i] = redData[i];
}
return length;
I don't really see the use of first reading to redData, and then copying everything to data. However more important, and correct me if I am wrong since it isnt really my area, but isn't this a memory leak? In a function that will be called quite often. redData is everytime malloc'ed, but it isnt removed afterwards. And since it is just an internal variable no one else can remove it either. Won't be the issue now though.
Just to be sure, you can try the code from here: http://mbed.org/forum/electronics/topic/3097/?page=1#comment-19479. Then at least you can make sure the library isnt the issue.
Hello, I am currently trying to use the Sparkfun breakout board MPU6050 to measure angle. The code I am using is this:
This, and the Library were obtained from
http://mbed.org/users/garfieldsg/code/mpu6050_test/
I cannot make sense of the output I am getting in Tera Term, and the device always fails the test within the program
I have the device connected to p27 (scl) and p28 (sca)
Can anyone give me a hint into what I am doing wrong?
Thanks