Adafruit HMC5883L Breakout - Triple-Axis Magnetometer Compass Sensor

Similar documents
Adafruit VL53L0X Time of Flight Micro-LIDAR Distance Sensor Breakout

Adafruit HTU21D-F Temperature & Humidity Sensor

Adafruit SHT31-D Temperature & Humidity Sensor Breakout

Adafruit BME280 Humidity + Barometric Pressure + Temperature Sensor Breakout

Adafruit BMP280 Barometric Pressure + Temperature Sensor Breakout

Adafruit DS3231 Precision RTC Breakout

Adafruit 1-Wire Thermocouple Amplifier - MAX31850K

Adafruit Mini TFT " 160x80

Adafruit BME280 Humidity + Barometric Pressure + Temperature Sensor Breakout

Adafruit 1-Wire Thermocouple Amplifier - MAX31850K

Adafruit MAX31865 RTD PT100 or PT1000 Amplifier

Adafruit LSM9DS1 Accelerometer + Gyro + Magnetometer 9-DOF Breakout

Adafruit BME680. Created by lady ada. Last updated on :10:23 AM UTC

Adafruit Metro Mini. Created by lady ada. Last updated on :12:28 PM UTC

Adafruit Terminal Block Breakout FeatherWing

Adafruit LSM9DS0 Accelerometer + Gyro + Magnetometer 9-DOF Breakouts

Adafruit CAP1188 Breakout

Adafruit TB A DC/Stepper Motor Driver Breakout Board

Adafruit PowerBoost Charger

Adafruit 1-Wire GPIO Breakout - DS2413

2.2" TFT Display. Created by lady ada. Last updated on :19:15 PM UTC

TSL2561 Luminosity Sensor

Adafruit Ethernet FeatherWing

1.5" & 2.1" Monochrome 128x64 OLED Display Module

Adafruit Powerboost 1000 Basic

Adafruit 3.5" 320x480 Color TFT Touchscreen Breakout

Bosch BMP085 Breakout Board

2.3" Monochrome 128x32 OLED Display Module

Adafruit MAX31865 RTD PT100 or PT1000 Amplifier

2.3" Monochrome 128x32 OLED Display Module

Adafruit PowerBoost Charger

Adafruit 2.4" Color TFT Touchscreen Breakout

Adafruit MAX98357 I2S Class-D Mono Amp

Adafruit Powerboost 1000C

1.5" & 2.1" Monochrome 128x64 OLED Display Module

TLC5947 and TLC59711 PWM LED Driver Breakouts

Adafruit seesaw. Created by Dean Miller. Last updated on :30:23 AM UTC

MMA8452Q Accelerometer Breakout Hookup Guide

Adafruit HUZZAH32 - ESP32 Feather

Introducting Itsy Bitsy 32u4

Adafruit I2S MEMS Microphone Breakout

Adafruit USB Power Gauge Mini-Kit

Adafruit 20W Stereo Audio Amplifier - MAX9744

DS1307 Real Time Clock Breakout Board Kit

mcube Proprietary APS v1.0 1 / mcube Inc. All rights reserved.

Adafruit PDM Microphone Breakout

Qwiic Shield for Arduino & Photon Hookup Guide

MC3635 FEATURES GENERAL DESCRIPTION

Adafruit INA219 Current Sensor Breakout

CORTESIA ELECTRONICCA

Adafruit Optical Fingerprint Sensor

Adafruit 20W Stereo Audio Amplifier - MAX9744

GENERAL DESCRIPTION MC3635 FEATURES

Adafruit DotStar FeatherWing

Compass Module 3-Axis HMC5883L (#29133)

Getting Started with the nrf8001 Bluefruit LE Breakout

WS2812B RGB LED Strip

Adafruit 5" and 7" 800x480 TFT HDMI Backpack

ESPino - Specifications

MAG3110 Magnetometer Hookup Guide

Adafruit Analog Accelerometer Breakouts

Adafruit 2.8" Color TFT Touchscreen Breakout v2

Adafruit 2.8" TFT Touch Shield v2 - Capacitive or Resistive

Adafruit BNO055 Absolute Orientation Sensor

One Grove Base Shield board this allows you to connect various Grove units (below) to your Seeeduino board; Nine Grove Grove units, consisting of:

36mm LED Pixels. Created by Phillip Burgess. Last updated on :45:20 PM EDT

P16105: CubeSat Attitude Determination Control System (ADCS) Testing Apparatus Presents

MP6500 Stepper Motor Driver, Digital Current Control

LIS3DH Hookup Guide. Introduction. SparkFun Triple Axis Accelerometer Breakout - LIS3DH SEN Required Materials

Stand-alone programming AVRs using CircuitPython

AT42QT101X Capacitive Touch Breakout Hookup Guide

Adafruit Feather 32u4 Basic Proto

Adafruit OLED FeatherWing

Sierra Radio Systems. Digital Compass. Reference Manual. Version 1.0

ARDUINO MINI 05 Code: A000087

Goal: We want to build an autonomous vehicle (robot)

Arduino ADK Rev.3 Board A000069

VL6180 Hookup Guide. Introduction. Board Overview - VL6180 Breakout. Covered in this Tutorial. Suggested Reading

Introduction to Arduino (programming, wiring, and more!)

Matrix and 7-Segment LED Backpack with the Raspberry Pi

IOX-16 User s Manual. Version 1.00 April Overview

ARDUINO MEGA ADK REV3 Code: A000069

Newhaven Display International, Inc Galvin Ct. Elgin IL, Ph: Fax:

Adafruit INA219 Current Sensor Breakout

Arduino Uno. Arduino Uno R3 Front. Arduino Uno R2 Front

AXE Stack 18. BASIC-Programmable Microcontroller Kit. An inexpensive introduction to microcontroller technology for all ability levels

Adafruit 2.8" TFT Touch Shield v2 - Capacitive or Resistive

Native MP3 decoding on Arduino

Introducing Gemma. Created by lady ada. Last updated on :08:07 AM UTC

Trinket RGB Shield Clock

RedBoard Hookup Guide

Make Your Own Fritzing Parts a

ARDUINO MEGA 2560 REV3 Code: A000067

Freeduino USB 1.0. Arduino Compatible Development Board Starter Guide. 1. Overview

ADXL343 Breakout Learning Guide

ARDUINO LEONARDO WITH HEADERS Code: A000057

Adafruit INA219 Current Sensor Breakout

Metro Minimalist Clock

Propeller Project Board USB (#32810)

Introducing Pro Trinket

Transcription:

Adafruit HMC5883L Breakout - Triple-Axis Magnetometer Compass Sensor Created by lady ada Last updated on 2016-09-14 07:05:05 PM UTC

Guide Contents Guide Contents Overview Pinouts Assembly Prepare the header strip: Add the breakout board: And Solder! Wiring and Test Download & Install Libraries Download Adafruit_Sensor Download Adafruit_HMC5883 Load Demo Downloads Datasheets & Files Schematic Breakout board design 2 3 5 8 9 9 10 12 13 13 13 14 17 17 17 18 Page 2 of 18

Overview He told you "Go West, young maker!" - but you don't know which way is West! Ah, if only you had this triple-axis magnetometer compass module. A magnetometer can sense where the strongest magnetic force is coming from, generally used to detect magnetic north. We based this breakout on a popular and well loved magnetometer, the HMC5883L. This compact sensor uses I2C to communicate and its very easy to use. Since it's a 3.3V max chip, we added circuitry to make it 5V-safe logic and power, for easy use with either 3 or 5V microcomtrollers. Simply connect VCC to +3-5V and ground to ground. Then read data from the I2C clock and data pins. There's also a Data Ready pin you can use to speed up reads (check the datasheet (http://adafru.it/dab) for details) Page 3 of 18

This is the same magnetometer sensor that is inside the LSM303. So if you want an accelerometer as well as a magnetometer, check out the LSM303 (http://adafru.it/1120) - it has basically this sensor + a nice digital 3-axis accelerometer! Specs: I2C interface 1-2 degree heading accuracy Integrated 12-bit ADC 160Hz max data rate Range of -8 to +8 Gauss Page 4 of 18

Pinouts Page 5 of 18

This is a fairly simple breakout. The sensor itself is super tiny and in the middle of the PCB. We have all the useful pins broken out in to a 0.1" spaced header at the bottom VIN - this is the power in pin, give it 3-5VDC. It is reverse-polarity protected. Use the same voltage as you do for the controlling microcontroller's logic. For an Arduino, 5V is best. GND - this is the common power and data ground pin 3vo - This is the 3.3V output from the onboard regulator. It will be at 3.3V and you can grab up to 100mA from this to power other items SDA and SCL - these are the I2C data and clock pins used to send and receive data from the module to your microcontroller. There are 10K pullups on these pins to the VIN pin. You can connect these pins to 5V I2C lines, there are level shifters on board to safely bring the pins down to 3V RDY - this it the 'data ready' pin output. If you want to stream data at high speed (higher than 100 times a second) you may want to listen to this pin for when data is ready to be read. Check the datasheet for more details about using the RDY pin, we don't use it because we don't read that fast! Page 6 of 18

Page 7 of 18

Assembly Assembly is really easy, you can use straight or 'right-angle' style headers to attach to the PCB. We'll be using the plain straight headers included The board comes with all surface-mount components pre-soldered. The included header strip can be soldered on for convenient use on a breadboard or with 0.1" connectors. You can also skip this step and solder on wires. Page 8 of 18

Prepare the header strip: Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard - long pins down Add the breakout board: Place the breakout board over the pins so that the short pins poke through the breakout pads Page 9 of 18

And Solder! Be sure to solder all 5 pins for reliable electrical contact. (For tips on soldering, be sure to check out our Guide to Excellent Soldering (http://adafru.it/atk)). You're done! Check your solder joints visually and continue onto Page 10 of 18

the next steps Page 11 of 18

Wiring and Test This 3-axis magnetometer breakout is thankfully very easy to use. It only requires 2 power pins and 2 data pins. We'll be demoing it with an Arduino but any other microcontroller can be used if you are willing to port the I2C code. We suggest using an Arduino to start since its guaranteed to work Connect VIN to 5V pin on the Arduino. If you have a 3V logic Arduino, connect VIN to 3V instead Connect GND to the ground pin on the Arduino Connect the SDA pin on the breakout to the I2C data SDA pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A4, on a Mega it is also known as digital 20 and on a Leonardo/Micro, digital 2 Connect the SCL pin on the breakout to the I2C clock SCL pin on your Arduino. On Page 12 of 18

an UNO & '328 based Arduino, this is also known as A5, on a Mega it is also known as digital 21 and on a Leonardo/Micro, digital 3 The HMC5883L has a fixed I2C address, you can only connect one sensor per microcontroller! Download & Install Libraries Lucky for you we have written a very nice sensor library for the HMC5883L, which is based off of our Adafruit_Sensor framework library. Download Adafruit_Sensor To begin, you will need to download Adafruit_Sensor from our github repository (http://adafru.it/azm). You can do that by visiting the github repo and manually downloading or, easier, just click this button to download the zip Download Adafruit_Sensor Library http://adafru.it/cmo Rename the uncompressed folder Adafruit_Sensor and check that the Adafruit_Sensor folder contains Adafruit_Sensor.h Place the Adafruit_Sensor library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. We also have a great tutorial on Arduino library installation at: http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use (http://adafru.it/aym) Download Adafruit_HMC5883 Next you can download the Adafruit HMC5883 "Unified" library. The "Unified" means that it is based on Adafruit_Sensor and will give you normalized values back in microteslas instead of arbitrary numbers from 0 to 1023 or whatever is used internally. Again, either visit the github repo (http://adafru.it/dac) or, better, download by clicking below Download Adafruit_HMC5883_U library http://adafru.it/dad Rename the uncompressed folder Adafruit_HMC5883_U and check that the Adafruit_HMC5883_U folder contains Adafruit_HMC5883_U.cpp and Page 13 of 18

Adafruit_HMC5883_U.h Place the Adafruit_Adafruit_HMC5883_U library folder your arduinosketchfolder/libraries/ folder as you did with Adafruit_Sensor Finally, restart the IDE! Load Demo Open up File->Examples->Adafruit_HMC5883_U->magsensor and upload to your Arduino wired up to the sensor Page 14 of 18

And open up the serial console. You will see some quick spec's about the HMC5883 and then a stream of data with X Y Z magnetometer data in uteslas and then a calculated heading. If you hold the module so that it is parallel with the ground then it will point you in the direction of North! Page 15 of 18

If you have to mount the module so that some other axis is parallel with the ground (X or Y) you will have to modify the heading code to take the arctan of X&Z or Y&Z instead of X&Y Page 16 of 18

Downloads Datasheets & Files Grab the HMC5883L datasheet here (http://adafru.it/dab), it has a lot more specifications available! This handy app note from Honeywell talks about how to calculate heading from a magnetometer's raw data (http://adafru.it/dae) Fritzing object in the Adafruit Fritzing library (http://adafru.it/ap3) EagleCAD PCB files on GitHub (http://adafru.it/qpe) Schematic Click to enlarge Page 17 of 18

Breakout board design Layout diagram in inches: Last Updated: 2016-09-14 07:05:04 PM UTC Page 18 of 18