Teensy 4.0 + CMPS12 compass

Example code of connecting Teensy 4.0 with a CMPS12 Compass. The tilt compensating compass and can measure bearing, roll and pitch. This is a good tilt compensation compass. The compass appears to calibrate itself each time it is turned on. I have connected using i2c protocol and using 4.7k ohms resistors (yellow-violet-red-gold) on the i2c wires. When communication is idle, the pull-up resistors will return the wire voltage to 3.3v.


I2C protocol3.3 volts

copy/paste Sketch