SKU: SEN0183 CMPS11 - Tilt Compensated Compass Module

From DFRobot Electronic Product Wiki and Tutorial: Arduino and Robot

How to use

The CMPS has two interfaces: IIC and Serial mode. For specific information, please go to the Official website:
IIC mode
Serial mode
Here, we will try the IIC mode on Arduino UNO.


SEN0183 CMPS11 DIA.png


Copy the sketch into the arduino IDE, and upload.

This sketch is revised by LEFF in DFRobot, based on the official one with 
LCD05 display @

#include <Wire.h>

#define ADDRESS 0x60                                          // Defines address of CMPS10

void setup(){
  Wire.begin();                                               // Conects I2C

void loop(){
  byte highByte, lowByte, fine;              // highByte and lowByte store high and low bytes of the bearing and fine stores decimal place of bearing
  char pitch, roll;                          // Stores pitch and roll values of CMPS10, chars are used because they support signed value
  int bearing;                               // Stores full bearing

  Wire.beginTransmission(ADDRESS);           //starts communication with CMPS10
  Wire.write(2);                              //Sends the register we wish to start reading from

  Wire.requestFrom(ADDRESS, 4);              // Request 4 bytes from CMPS10
  while(Wire.available() < 4);               // Wait for bytes to become available
  highByte =;           
  lowByte =;            
  pitch =;              
  roll =;               

  bearing = ((highByte<<8)+lowByte)/10;      // Calculate full bearing
  fine = ((highByte<<8)+lowByte)%10;         // Calculate decimal place of bearing

  display_data(bearing, fine, pitch, roll);  // Display data to the Serial

void display_data(int b, int f, int p, int r){    // pitch and roll (p, r) are recieved as ints instead oif bytes so that they will display corectly as signed values.

  Serial.print("CMPS10 Example V:");
  Serial.println(soft_ver());                        // Display software version of the CMPS10

  delay(5);                                       // Delay to allow Serial to proscess data  

  Serial.print("Bearing = ");                      // Display the full bearing and fine bearing seperated by a decimal poin on the Serial


  Serial.print("Pitch = ");


  Serial.print("Roll = ");

int soft_ver(){
  int data;                                      // Software version of  CMPS10 is read into data and then returned

  // Values of 0 being sent with write need to be masked as a byte so they are not misinterpreted as NULL this is a bug in arduino 1.0
  Wire.write((byte)0);                           // Sends the register we wish to start reading from

  Wire.requestFrom(ADDRESS, 1);                  // Request byte from CMPS10
  while(Wire.available() < 1);
  data =;           


SEN0183 CMPS11 result.jpg

Official Forum



DFshopping car1.png Get it from CMPS11 - Tilt Compensated Compass Module or DFRobot Distributor.