Magnetic fields and current go hand-in-hand. When current flows through a wire, a
magnetic field is created. This is the basic principle behind electromagnets. This is
also the principle used to measure magnetic fields with a magnetometer. The
direction of Earth's magnetic fields affects the flow of electrons in the sensor, and
those changes in current can be measured and calculated to derive a compass
heading or other useful information.
How to Use it:
So you're ready to start using this chip with your Arduino are you? Well lucky for you,
we have everything you need to get your project rolling.
Hardware:
First we'll need to solder on some headers to the breakout board so it will fit into a
breadboard. For soldering suggestions, this tutorial is helpful.
The breakout board includes the HMC5883 sensor and all filtering capacitors
necessary. There are two unpopulated pads in case you need pull up resistors (no
need for them if you're using the Arduino/ATmega328).
Communication with the HMC5883 is simple and all done through an I C interface.
We will go into this in further detail momentarily. All you need to know for now is how
to wire it up. Attach the SDA line to A4 and the SCL line to A5. Also attach Vcc to
3.3V and GND to GND.
2
Page 3 of 7