I am trying to connect a HMC6352 compass module to my Raspberry Pi. The product page is here[0]. According to the datasheet[1] I need to send an "A" for a read command. However I am somewhat new to I2C and do not know how to accomplish this. I would like to do the coding in Python.
I know I have set up I2C correctly, and that the compass is correctly connected to the Pi, because I can see it when I run i2cdetect
:
pi@raspberrypi ~ $ sudo i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- 21 -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
You can see the compass on address 21, although the documentation says the default address is 42.
The ideal answer would be a block of python code that returns the current reading from the compass.
I am running Adafruit's Occidentals V2 for my OS.