Recent changes
Slingshot user guide
tag Guide, user
NFCLamp user guide
tag Guide, user
Homepage
MPL115A2
Compiler Error 42
From the mbed microcontroller Cookbook.  

HMC6352 Digital Compass

hmc6352

The HMC6352 is a digital compass with an I2C interface.

Hello World!

» Import this 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
SCLp27
SDAp28

API

» Import this library into a program

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 this library into a programHMC6352

Honeywell HMC6352 digital compass library.

Reference




calendar Page history
Last modified 27 Nov 2010, by   user Aaron Berk   tag No tags | 2 comments  

2 comments on HMC6352 Digital Compass:

10 Feb 2011

The Sparkfun breakout board for this module has the two I2C pullups on it already - so no need to add external ones.

http://www.sparkfun.com/datasheets/Sensors/Magneto/HMC6352-v16.pdf

16 Apr 2011

... Deleted ...

Please login to post comments.