(SKU:RB-02S077)SparkFun Triple Axis Magnetometer Breakout - HMC5883L

From ALSRobot-Wki
Jump to: navigation, search
3zszlp.jpg

Contents

overview

This is a breakout board for Honeywell’s HMC5883L, a 3-axis digital compass. Communication with the HMC5883L is simple and all done through an I2C interface. There is no on-board regulator, so a regulated voltage of 2.16-3.6VDC should be supplied.The breakout board includes the HMC5883L sensor and all filtering capacitors as shown. The power and 2-wire interface pins are all broken out to a 0.1" pitch header.


Technical parameters and performance

  1. Simple I2C interface
  2. 2.16-3.6VDC supply range
  3. Low current draw
  4. 5 milli-gauss resolution
  5. Dimensions: 0.7x0.7" (17.78x17.78mm)

using method

Pin definition

  • GND: (GND)
  • VIN: power supply (VCC)
  • SCL: clock signal
  • SDA: data signal
3zszlp1.jpg

Connect Icon

SCL and SDA ports are respectively received from the controller for simulations of 5 and 4 I/O ports. VIN and GND received power 3.3V and GND.

3zszlp2.jpg

Application Routine

According to the program will be three axis digital compass and UNO connection, serial output of the Y, Z, X three axis data.

Sample code

#include <Wire.h> //I2C Arduino Library

#define address 0x1E //0011110b, I2C 7bit address of HMC5883

void setup(){
  //Initialize Serial and I2C communications
  Serial.begin(9600);
  Wire.begin();
  
  //Put the HMC5883 IC into the correct operating mode
  Wire.beginTransmission(address); //open communication with HMC5883
  Wire.send(0x02); //select mode register
  Wire.send(0x00); //continuous measurement mode
  Wire.endTransmission();
}

void loop(){
  
  int x,y,z; //triple axis data

  //Tell the HMC5883 where to begin reading data
  Wire.beginTransmission(address);
  Wire.send(0x03); //select register 3, X MSB register
  Wire.endTransmission();
  
 
 //Read data from each axis, 2 registers per axis
  Wire.requestFrom(address, 6);
  if(6<=Wire.available()){
    x = Wire.receive()<<8; //X msb
    x |= Wire.receive(); //X lsb
    z = Wire.receive()<<8; //Z msb
    z |= Wire.receive(); //Z lsb
    y = Wire.receive()<<8; //Y msb
    y |= Wire.receive(); //Y lsb
  }
  
  //Print out values of each axis
  Serial.print("x: ");
  Serial.print(x);
  Serial.print("  y: ");
  Serial.print(y);
  Serial.print("  z: ");
  Serial.println(z);
  
  delay(250);
} 

Program effect

Open the serial monitor can observe the output of the X, Y, Z three axis data.

Product recommendation

Buy address:SparkFun Triple Axis Magnetometer Breakout - HMC5883L

Personal tools
Namespaces

Variants
Actions
Navigation
Tools