Calibration the CMPS10
I would recommend evaluating the CMPS10 performance first before implementing this function. Its purpose is to remove offsets caused by constant magnetic sources around the CMPS10. First of all you need to determine North and align the CMPS10 with it, then enter the calibration mode by writing 0xF0 to the command register (22). To calibrate the first point write 0xF5 to the command register, this should also light the LED, then move the object through 90° and write 0xF5 to the command register. Repeat this twice more so four points are calibrated and the LED should also turn off to confirm calibration completion. Please make sure that the CMPS10 is not located near to ferrous objects as this will distort the magnetic field and induce errors in the reading.
Restoring Factory Calibration
Should you need to revert to the factory calibration then write the following to the command register in 3 separate transactions with 100ms between each transaction: 0x20,0x2A,0x60. These commands must be sent in the correct sequence to restore the calibration, additionally, No other command may be issued in the middle of the sequence. The sequence must be sent to the command register at location 22, which means 3 separate write transactions on the I2C
bus. (A write transaction is [start sequence] [I2C address] [register address] [command byte] [stop sequence] then a 100mS delay).