HMC6352 Digital Compass

Note

This page has been moved to the Components section of the website. Please see http://developer.mbed.org/components/HMC6352-Digital-Compass/ .

hmc6352

The HMC6352 is a digital compass with an I2C interface.

Hello World!

Import program

00001 #include "HMC6352.h"
00002 
00003 HMC6352 compass(p9, p10);
00004 Serial pc(USBTX, USBRX);
00005 
00006 int main() {
00007 
00008     pc.printf("Starting HMC6352 test...\n");
00009     
00010     //Continuous mode, periodic set/reset, 20Hz measurement rate.
00011     compass.setOpMode(HMC6352_CONTINUOUS, 1, 20);
00012 
00013     while (1) {
00014 
00015         wait(0.1);
00016 
00017         pc.printf("Heading is: %f\n", compass.sample() / 10.0);
00018 
00019     }
00020 
00021 }
HMC6352 Signal Namembed pin
VccVout
GndGnd
SCLp10/p27
SDAp9/p28

Use either p9 and p10, or p28 and p27, depending on which I2C pins you wish to use.

API

Import library

Public Member Functions

HMC6352 (PinName sda, PinName scl)
Constructor.
int sample (void)
Sample the device and return the result.
void setSleepMode (int enterOrExit)
Enter into or exit from sleep mode.
void setReset (void)
Update bridge offsets.
void setCalibrationMode (int enterOrExit)
Enter into or exit from calibration mode.
void saveOpMode (void)
Save the current operation mode byte to EEPROM.
int getSlaveAddress (void)
Read the memory location on the device which contains the slave address.
int getOffset (int axis)
Read the current offset for X or Y axis magnetometer.
void setOffset (int axis, int offset)
Set the offset for X or Y axis magnetometer.
int getTimeDelay (void)
Get the current time delay.
void setTimeDelay (int delay)
Set the time delay of the device.
int getSumNumber (void)
Get the number of measurements being summed each sample.
void setSumNumber (int sum)
Set the number of measurements being summed each sample.
int getSoftwareVersion (void)
Get the software version on the device.
int getOpMode (void)
Get the current operation mode.
void setOpMode (int mode, int periodicSetReset, int measurementRate=0)
Set the operation mode.
int getOutputMode (void)
Get the current output mode of the device.
void setOutputMode (int mode)
Set the output mode of the device.

Library

Import libraryHMC6352

Honeywell HMC6352 digital compass library.

Reference


All wikipages