When reading values from CMSP14 using I2C with Raspberry PI, I read the byte values in register 0x01 Compass Bearing 8-bit. As i rotate the module the values will increase until 255 and then will go to 128 and then continue to increase to 255 (for the next 180 degrees) and repeat. Effectively, there are no numbers less than 128. Is this normal? I was expecting a value 0-255 over 360 degrees.
Hello @jayjones !
Great to see you around! The readings are certainly not good, readings should range from 0 to 255. Try changing the pins for the ones you read in the raspberry and verify that you are measuring correctly with the sensor. I’ll leave you some reading and documentation materials:
- https://www.robotshop.com/media/files/content/d/dev/pdf/tilt-compensated-magnetic-compass-cmps14-datasheet.pdf
- https://robot-electronics.co.uk/i2c-tutorial
- https://robot-electronics.co.uk/htm/raspberry_pi_examples.htm
Hope this could help you!
1 Like
I discovered the errors were caused by the lack of support for the Rpi to do I2C clock stretching. Many posts elsewhere on that topic (some related to BNO055/BNO080). The fix for me was to add this line to /boot/config.txt
dtparam=12c_arm_baudrate=10000
reboot and all is well