You are viewing an older revision! See the latest version

HMC6352 Digital Compass

hmc6352

The HMC6352 is a digital compass with an I2C interface.

Hello World!

main.cpp

#include "HMC6352.h"

HMC6352 compass(p28, p27);
Serial pc(USBTX, USBRX);

int main() {

    pc.printf("Starting HMC6352 test...\n");

    //Continuous mode, periodic set/reset, 20Hz measurement rate.
    compass.setOpMode(HMC6352_CONTINUOUS, 1, 20);

    while (1) {

        wait(0.1);

        pc.printf("Heading is: %f\n", compass.sample() / 10.0);

    }

}
HMC6352 Signal Namembed pin
VccVout
GndGnd
SCLp27
SDAp28

Library

Reference


All wikipages