AK8975 Class
- ID: ak8975
- Name: 3-axis Magnetometer
- Other Names: AK9875
- Category: compass
- Manufacturer: seeed
- Connection: i2c
- Link: http://www.akm.com/akm/en/file/datasheet/AK8975.pdf
This is a 3-axis magnetometer, which can be used alone, or coupled with another device (such as the mcu9150 9-axis motion sensor).
Item Index
Methods
AK8975
-
bus
-
address
ak8975 constructor
Parameters:
-
bus
Numberi2c bus to use
-
address
Numberthe address for this device
Returns:
init
()
Boolean
set up initial values and start operation
Returns:
true if successful
setMode
-
mode
put the chip into a specific mode
Parameters:
-
mode
CNTL_MODES_Tone of the CNTL_MODES_T values
Returns:
true if successful
isReady
()
Boolean
check to see if the ST1_DRDY bit is set, indicating the device can accept commands
Returns:
true if device is ready, false otherwise
waitforDeviceReady
()
Boolean
check to see if device is ready and sleep/retry if not. Returns once device indicates it's ready.
Returns:
true if device is ready, false if retries exhausted
update
-
selfTest
take a measurement
Parameters:
-
selfTest
Booleantrue if we are running a self test, false (default) otherwise.
Returns:
true if successful, false otherwise
selfTest
()
Boolean
do a self test sequence. When self test is executed, the device activates internal calibrated magnets, and measures them, updating the measurement registers. Once complete, the data can be read as usual ( getMagnetometer() ) and the returned values compared against the following limits to determine correctness:
-100 < X < +100; -100 < Y < +100; -1000 < Z < -300
Returns:
true if successful, false otherwise
getMagnetometer
-
x
-
y
-
z
return the compensated values for the x, y, and z axes. The unit of measurement is in micro-teslas (uT).
Parameters:
-
x
Float *pointer to returned X axis value
-
y
Float *pointer to returned Y axis value
-
z
Float *pointer to returned Z axis value