CMPS11 Orientation reading

Hi Guys,

I've been working a project, which involves using a CMPS11 digital compass. I'm an amateur at programming, so please excuse me for my silly questions.
I'm building a robot, which need to know its heading accurately. I chose I2C communication as the update rate of the signals has to be at least 15hz.
I used this program to read out the orientation:
http://www.robot-electronics.co.uk/htm/cmps11i2c.htm

As far as I know, the "angle full" would give me the heading. For some reasons, It's not accurate at all, actually, pretty useless. I have no idea what it measures. Could you tell me how to yield the correct data from the sensor?

Regards,
Tamas

I found out how to solve the problem. I need to calibrate the sensor, but I have no idea how to do that. There are some guidelines on the net, but nothing exact.
http://www.robot-electronics.co.uk/htm/cmps11i2c.htm

Can someone tell me how to send the appropriate commands?

I tried to calibrate it today, but I couldn't make it to work. Can someone have a look at my code please?

#include <Wire.h>

#define ADDRESS 0x60

void setup(){
  Wire.begin();
  Serial.begin(9600);
  }

void loop(){
}

void calibrate(){

  Wire.beginTransmission(ADDRESS);
  Wire.write(0xF0);
  delay(25);

  Wire.beginTransmission(ADDRESS);
  Wire.write(0xF5);
  delay(25);

  Wire.beginTransmission(ADDRESS);
  Wire.write(0xF6);
  Wire.endTransmission();
  delay(25);

}

I don't normally use the Wire library, but it looks like you are not using it correctly. Spend some time with this documentation.

Hi Tomas,

Did you ever get this to work? I am trying to do the same thing (use the CMPS11 with I2C communication), but I cannot seem to get it to work. I am using the CMPS11 I2C sample code that is provided here:

https://www.robot-electronics.co.uk/files/arduino_cmps11_i2c.ino

But this code always gets held up on the "while(Wire.available() < 5); // Wait for all bytes to come back" line. Apparently no bytes ever come back!

I was wondering if you ran into any problems like this or could give me any advice of how to make this work. I am attaching a picture of my Arduino Uno and CMPS11 device so you can see my wiring too.

Thank you!

Jordan