# Adafruit MMC5603 - Triple-axis Magnetometer

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/113/954/medium800thumb/adafruit_products_5579-05_1.jpg?1659552141)

Sense the magnetic fields surrounding us with this handy triple-axis magnetometer (compass) module. Magnetometers can sense where the strongest magnetic force is coming from, generally used to detect magnetic north, but can also be used for measuring magnetic fields. This sensor tends to be paired with a 6-DoF (degree of freedom) accelerometer/gyroscope to create a 9-DoF inertial measurement unit that can detect its orientation in real-space, thanks to Earth's stable magnetic field. [It's a great match for the LSM6DSOX from ST!](https://www.adafruit.com/product/4438)

![](https://cdn-learn.adafruit.com/assets/assets/000/123/023/medium800/adafruit_products_5579-04.jpg?1690384239)

We based this breakout on the MMC5603, a great general purpose magnetometer with a very wide range and both I2C and SPI interfaces. This compact sensor is very easy to use. Simply download our library and connect the SCL pin to your I2C clock pin, and SDA pin to your I2C data pin and upload our test program to read out magnetic field data. If you'd like, you can also use SPI to receive data (we just happen to prefer I2C here).

![](https://cdn-learn.adafruit.com/assets/assets/000/123/024/medium800/adafruit_products_5579-02.jpg?1690384251)

This sensor can sense ranges from ±30 Gauss (±3000uT or ±3mT) with no range-setting required and full 20 bit output, up to 1000 Hz rate reading. The range makes it good for reading Earth's magnetic field (which maxes at about 0.6 Gauss) or some basic magnets. It isn't good for&nbsp;[very strong rare earth magnets, for that check out the TLV293](https://www.adafruit.com/product/4366).

![](https://cdn-learn.adafruit.com/assets/assets/000/123/025/medium800/adafruit_products_5579-03.jpg?1690384260)

To make life easier, so you can focus on your important work, we've taken the MMC5603 and put it onto a breakout PCB along with support circuitry to let you use this little wonder with 3.3V (Feather/Raspberry Pi) or 5V (Arduino/ Metro328) logic levels. Additionally, since it speaks I2C, you can easily connect it up with two wires (plus power and ground!).&nbsp; We've even included [SparkFun qwiic](https://www.sparkfun.com/qwiic)&nbsp;compatible**&nbsp;[STEMMA QT](https://learn.adafruit.com/introducing-adafruit-stemma-qt)** connectors for the I2C bus, so&nbsp; **you don't even need to solder!** &nbsp;Just wire up to your favorite micro and&nbsp;[you can use our CircuitPython/Python](https://github.com/adafruit/Adafruit_CircuitPython_MMC56x3)&nbsp;or&nbsp;[Arduino drivers](https://github.com/adafruit/Adafruit_MMC56x3) to easily interface with the MMC5603 and get magnetic measurements ASAP.

It's fully assembled and tested.&nbsp; Comes with a bit of 0.1" standard header in case you want to use it with a breadboard or perfboard.&nbsp; Four 2.5mm (0.1") mounting holes for easy attachment.

# Adafruit MMC5603 - Triple-axis Magnetometer

## Pinouts

![](https://cdn-learn.adafruit.com/assets/assets/000/113/975/medium800/adafruit_products_double.jpg?1659624000)

The default I2C address is **0x30**.

## Power Pins

- **VIN** &nbsp;- this is the power pin. Since the sensor chip uses 3 VDC, we have included a voltage regulator on board that will take 3-5VDC and safely convert it down. To power the board, give it the same power as the logic level of your microcontroller - e.g. for a 5V microcontroller like Arduino, use 5V.
- **3vo** &nbsp;- this is the 3.3V output from the voltage regulator, you can grab up to 100mA from this if you like.
- **GND** &nbsp;- common ground for power and logic.

## I2C Logic Pins

- **SCL&nbsp;** - I2C clock pin, connect to your microcontroller I2C clock line. This pin is level shifted so you can use 3-5V logic, and there's a&nbsp; **10K pullup** &nbsp;on this pin.
- **SDA&nbsp;** -I2C data pin, connect to your microcontroller I2C data line. This pin is level shifted so you can use 3-5V logic, and there's a&nbsp; **10K pullup** &nbsp;on this pin.
- **[STEMMA QT](https://learn.adafruit.com/introducing-adafruit-stemma-qt)&nbsp;-&nbsp;**These connectors allow you to connectors to dev boards with&nbsp; **STEMMA QT** &nbsp;connectors or to other things with&nbsp;[various associated accessories](https://www.adafruit.com/?q=JST%20SH%204).

## Power LED

- **Power LED -&nbsp;** In the upper left corner, above the STEMMA connector, on the front of the board, is the power LED, labeled **&nbsp;on**. It is the green LED.

# Adafruit MMC5603 - Triple-axis Magnetometer

## Python & CircuitPython

It's easy to use the **MMC5603** with Python or CircuitPython, and the [Adafruit\_CircuitPython\_MMC56x3](https://github.com/adafruit/Adafruit_CircuitPython_MMC56x3) module. This module allows you to easily write Python code that reads the values from the **MMC5603**'s magnetometer and ambient temperature sensor. You can use this sensor with any CircuitPython microcontroller board or with a computer that has GPIO and Python [thanks to Adafruit\_Blinka, our CircuitPython-for-Python compatibility library](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).

## CircuitPython Microcontroller Wiring

First, wire up a MMC5603 to your board exactly as shown below. Here's an example of wiring a Feather M4 to the sensor with I2C using one of the handy&nbsp;[**STEMMA QT**](https://learn.adafruit.com/introducing-adafruit-stemma-qt)&nbsp;connectors:

- **Board 3V** &nbsp;to&nbsp;**sensor VIN (red wire)**
- **Board GND** &nbsp;to&nbsp; **sensor**** &nbsp;GND (black wire)**
- **Board SCL** &nbsp;to&nbsp; **sensor**** &nbsp;SCL (yellow wire)**
- **Board SDA** &nbsp;to&nbsp; **sensor**** &nbsp;SDA (blue wire)**

![adafruit_products_featherStemma_bb.png.jpg](https://cdn-learn.adafruit.com/assets/assets/000/113/976/medium640/adafruit_products_featherStemma_bb.png.jpg?1659624431)

You can also use standard&nbsp; **0.100" pitch** &nbsp;headers to wire it up on a breadboard:

- **Board 3V** &nbsp;to&nbsp; **sensor**** &nbsp;VIN (red wire)**
- **Board GND** &nbsp;to&nbsp; **sensor**** &nbsp;GND (black wire)**
- **Board SCL** &nbsp;to&nbsp; **sensor**** &nbsp;SCL (yellow wire)**
- **Board SDA** &nbsp;to&nbsp; **sensor**** &nbsp;SDA (blue wire)**

![adafruit_products_featherBB_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/113/977/medium640/adafruit_products_featherBB_bb.png?1659624524)

## Python Computer Wiring

Since there's&nbsp;_dozens_&nbsp;of Linux computers/boards you can use, below shows wiring for Raspberry Pi. For other platforms,&nbsp;[please visit the guide for CircuitPython on Linux to see whether your platform is supported](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).&nbsp;

Here's the Raspberry Pi wired to the sensor using I2C and a&nbsp;[**STEMMA QT**](https://learn.adafruit.com/introducing-adafruit-stemma-qt)&nbsp;connector:

- **Pi 3V** &nbsp;to&nbsp; **sensor**** &nbsp;VIN (red wire)**
- **Pi GND** &nbsp;to&nbsp; **sensor**** &nbsp;GND (black wire)**
- **Pi SCL** &nbsp;to&nbsp; **sensor**** &nbsp;SCL (yellow wire)**
- **Pi SDA** &nbsp;to&nbsp; **sensor**** &nbsp;SDA (blue wire)**

![adafruit_products_piStemma_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/113/978/medium640/adafruit_products_piStemma_bb.png?1659624571)

Finally here is an example of how to wire up a Raspberry Pi to the sensor using a solderless breadboard:

- **Pi 3V** &nbsp;to&nbsp; **sensor**** &nbsp;VIN (red wire)**
- **Pi GND** &nbsp;to&nbsp; **sensor**** &nbsp;GND (black wire)**
- **Pi SCL** &nbsp;to&nbsp; **sensor**** &nbsp;SCL (yellow wire)**
- **Pi SDA** &nbsp;to&nbsp; **sensor**** &nbsp;SDA (blue wire)**

![adafruit_products_piBreadboard_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/113/979/medium640/adafruit_products_piBreadboard_bb.png?1659624599)

## Python Installation of MMC56x3 Library

You'll need to install the&nbsp; **Adafruit\_Blinka** &nbsp;library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3.&nbsp;[Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux)!

Once that's done, from your command line run the following command:

- `pip3 install adafruit-circuitpython-mmc56x3`

If your default Python is version 3, you may need to run&nbsp;`pip`&nbsp;instead. Make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

## CircuitPython Usage

To use with CircuitPython, you need to first install the MMC56x3 library, and its dependencies, into the&nbsp; **lib** &nbsp;folder on your&nbsp; **CIRCUITPY** &nbsp;drive. Then you need to update&nbsp; **code.py** &nbsp;with the example script.

Thankfully, we can do this in one go. In the example below, click the&nbsp; **Download Project Bundle** &nbsp;button below to download the necessary libraries and the&nbsp; **code.py** &nbsp;file in a zip file. Extract the contents of the zip file, and copy the&nbsp; **entire&nbsp;**** lib **&nbsp;** folder **&nbsp;and the&nbsp;** code.py **&nbsp;file to your&nbsp;** CIRCUITPY**&nbsp;drive.

Your&nbsp; **CIRCUITPY/lib** &nbsp;folder should contain the following folders and file:

- **adafruit\_bus\_device/**
- **adafruit\_register/**
- **adafruit\_mmc56x3.mpy**

![CIRCUITPY](https://adafruit.github.io/Adafruit_CircuitPython_Bundle/mmc56x3_mmc56x3_simpletest.py.png )

## Python Usage

Once you have the library&nbsp;`pip3`&nbsp;installed on your computer, copy or download the following example to your computer, and run the following, replacing&nbsp; **code.py** &nbsp;with whatever you named the file:

`python3 code.py`

## Example Code
https://github.com/adafruit/Adafruit_CircuitPython_MMC56x3/blob/main/examples/mmc56x3_simpletest.py

 **If running CircuitPython:** &nbsp;Once everything is saved to the&nbsp; **CIRCUITPY** &nbsp;drive,&nbsp;[connect to the serial console](https://learn.adafruit.com/welcome-to-circuitpython/kattni-connecting-to-the-serial-console)&nbsp;to see the data printed out!

**If running Python:&nbsp;** The console output will appear wherever you are running Python.

![](https://cdn-learn.adafruit.com/assets/assets/000/113/998/medium800/adafruit_products_cpREPL.jpg?1659628149)

Twist and turn your MMC5603 and see the values from the magnetometer and temperature sensor print out to the REPL!

First you import the necessary modules and libraries. Then you instantiate the sensor on I2C.

Then you're ready to read data from the sensor's magnetometer and temperature sensor.

Finally, inside the loop, you see the x, y and z values from the magnetometer alongside the ambient temperature reading.

The magnetometer measures force on the x, y and z axes in micro-Teslas (uT) and the temperature sensor reads the ambient temperature in Celsius.

That's all there is to using the MMC5603 with CircuitPython!

# Adafruit MMC5603 - Triple-axis Magnetometer

## Python Docs

# Adafruit MMC5603 - Triple-axis Magnetometer

## Arduino

Using the MMC5603&nbsp;with Arduino involves wiring up the sensor to your Arduino-compatible microcontroller, installing the&nbsp;[Adafruit\_MMC56x3](https://github.com/adafruit/Adafruit_MMC56x3)&nbsp;library and running the provided example code.

## Wiring

Wire as shown for a&nbsp; **5V** &nbsp;board like an Uno. If you are using a **&nbsp;3V** &nbsp;board, like an Adafruit Feather, wire the board's 3V pin to the MMC5603 VIN.

Here is an Adafruit Metro wired up to the MMC5603 using the STEMMA QT connector:

- **Board 5V** &nbsp;to&nbsp; **sensor&nbsp;**** VIN (red wire)**  
- **Board GND** &nbsp;to&nbsp; **sensor** &nbsp;**GND (black wire)**  
- **Board SCL** &nbsp;to&nbsp; **sensor** &nbsp;**SCL (yellow wire)**  
- **Board SDA** &nbsp;to&nbsp; **sensor** &nbsp;**SDA (blue wire)**

![adafruit_products_metroStemma_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/113/980/medium640/adafruit_products_metroStemma_bb.png?1659625195)

Here is an Adafruit Metro wired up using a solderless breadboard:

- **Board 5V** &nbsp;to&nbsp; **sensor**** &nbsp;****VIN (red wire)**  
- **Board GND** &nbsp;to&nbsp; **sensor** &nbsp;**GND (black wire)**  
- **Board SCL** &nbsp;to&nbsp; **sensor** &nbsp;**SCL (yellow wire)**  
- **Board SDA** &nbsp;to&nbsp; **sensor** &nbsp;**SDA (blue wire)**

![adafruit_products_metroBB_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/113/981/medium640/adafruit_products_metroBB_bb.png?1659625225)

## Library Installation

You can install the&nbsp; **Adafruit MMC56x3** library&nbsp;for Arduino using the Library Manager in the Arduino IDE.

![](https://cdn-learn.adafruit.com/assets/assets/000/113/982/medium800/adafruit_products_Arduino_Open_Library_Manager.png?1659625264)

Click the&nbsp; **Manage Libraries ...** &nbsp;menu item, search for&nbsp; **Adafruit MMC56x3** ,&nbsp;and select the&nbsp; **Adafruit MMC56x3** &nbsp;library:

![](https://cdn-learn.adafruit.com/assets/assets/000/113/983/medium800/adafruit_products_lib.jpg?1659625606)

If asked about dependencies, click "Install all".

![](https://cdn-learn.adafruit.com/assets/assets/000/113/984/medium800/adafruit_products_depends.jpg?1659625635)

If the "Dependencies" window does not come up, then you already have the dependencies installed.&nbsp;

Warning: 

## Example Code
https://github.com/adafruit/Adafruit_MMC56x3/blob/main/examples/magsensor/magsensor.ino

![](https://cdn-learn.adafruit.com/assets/assets/000/113/996/medium800/adafruit_products_arduinoSerial.jpg?1659628108)

Upload the sketch to your board and open up the Serial Monitor ( **Tools -\> Serial Monitor** ) at 115200 baud. You should see the values from the embedded temperature sensor and magnetometer being printed out. You'll see the values change depending on the movement of the sensor.

# Adafruit MMC5603 - Triple-axis Magnetometer

## Arduino Docs

# Adafruit MMC5603 - Triple-axis Magnetometer

## Downloads

## Files

- [MMC5603 Datasheet](https://cdn-learn.adafruit.com/assets/assets/000/113/957/original/MMC5603NJ_RevB_7-12-18.pdf?1659554945)
- [EagleCAD PCB files on GitHub](https://github.com/adafruit/Adafruit-MMC5603-PCB)
- [3D models on GitHub](https://github.com/adafruit/Adafruit_CAD_Parts/tree/main/5579%20MMC5603%20Magnetometer)
- [Fritzing object in the Adafruit Fritzing Library](https://github.com/adafruit/Fritzing-Library/blob/master/parts/Adafruit%20MMC5603%20Triple-axis%20Magnetometer%20-%20STEMMA%20QT.fzpz)

## Schematic and Fab Print
![](https://cdn-learn.adafruit.com/assets/assets/000/113/955/medium800/adafruit_products_schem.png?1659554851)

![](https://cdn-learn.adafruit.com/assets/assets/000/113/956/medium800/adafruit_products_fab.png?1659554857)

![](https://cdn-learn.adafruit.com/assets/assets/000/136/476/medium800/adafruit_products_5579_MMC5603_Magnetometer.jpg?1745606172 )


## Primary Products

### Adafruit Triple-axis Magnetometer - MMC5603

[Adafruit Triple-axis Magnetometer - MMC5603](https://www.adafruit.com/product/5579)
Sense the magnetic fields surrounding us with this handy triple-axis magnetometer (compass) module. Magnetometers can sense where the strongest magnetic force is coming from, generally used to detect magnetic north, but can also be used for measuring magnetic fields. This sensor tends to be...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5579)
[Related Guides to the Product](https://learn.adafruit.com/products/5579/guides)

## Featured Products

### STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long

[STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long](https://www.adafruit.com/product/4399)
This 4-wire cable is&nbsp;50mm / 1.9" long and fitted with JST SH female 4-pin connectors on both ends. Compared with the chunkier JST PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/4399)
[Related Guides to the Product](https://learn.adafruit.com/products/4399/guides)
### JST SH 4-pin Cable with Alligator Clips - STEMMA QT / Qwiic

[JST SH 4-pin Cable with Alligator Clips - STEMMA QT / Qwiic](https://www.adafruit.com/product/4398)
This cable will make it super easy to use our plug-and-play STEMMA QT boards with boards like Circuit Playground. On one end you get a Qwiic / STEMMA QT connector (technically known as a JST SH 4-pin plug)&nbsp; into 4 individual wires with grippy alligator clips. We're carrying these to...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4398)
[Related Guides to the Product](https://learn.adafruit.com/products/4398/guides)
### STEMMA QT / Qwiic JST SH 4-Pin Cable - 200mm Long

[STEMMA QT / Qwiic JST SH 4-Pin Cable - 200mm Long](https://www.adafruit.com/product/4401)
This 4-wire cable is a little over 200mm / 7.8" long and fitted with JST-SH female 4-pin connectors on both ends. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/4401)
[Related Guides to the Product](https://learn.adafruit.com/products/4401/guides)
### STEMMA QT / Qwiic JST SH 4-pin to Premium Male Headers Cable

[STEMMA QT / Qwiic JST SH 4-pin to Premium Male Headers Cable](https://www.adafruit.com/product/4209)
This 4-wire cable is a little over 150mm / 6" long and fitted with JST-SH female 4-pin connectors on one end and premium Dupont male headers on the other. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4209)
[Related Guides to the Product](https://learn.adafruit.com/products/4209/guides)
### STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long

[STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long](https://www.adafruit.com/product/4210)
This 4-wire cable is a little over 100mm / 4" long and fitted with JST-SH female 4-pin connectors on both ends. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/4210)
[Related Guides to the Product](https://learn.adafruit.com/products/4210/guides)

## Related Guides

- [Adafruit EYESPI Breakout Board](https://learn.adafruit.com/adafruit-eyespi-breakout-board.md)
- [ Adafruit DRV8833 DC/Stepper Motor Driver Breakout Board](https://learn.adafruit.com/adafruit-drv8833-dc-stepper-motor-driver-breakout-board.md)
- [Adafruit AD5693R 16-Bit DAC Breakout Board](https://learn.adafruit.com/adafruit-ad5693r-16-bit-dac-breakout-board.md)
- [Adafruit PiCowbell Adalogger for Pico](https://learn.adafruit.com/adafruit-picowbell-adalogger-for-pico.md)
- [WiFi Music Alert Box ](https://learn.adafruit.com/wifi-music-alert-box.md)
- [Dancing Inflatables: Make your Holiday Display Move](https://learn.adafruit.com/dancing-inflatables-make-your-holiday-display-move.md)
- [Adafruit 1-Wire Thermocouple Amplifier - MAX31850K](https://learn.adafruit.com/adafruit-1-wire-thermocouple-amplifier-max31850k.md)
- [CircuitPython on the Arduino Nano RP2040 Connect](https://learn.adafruit.com/circuitpython-on-the-arduino-nano-rp2040-connect.md)
- [MagTag IoT Menorah](https://learn.adafruit.com/magtag-iot-menorah.md)
- [MCP4725 12-Bit DAC Tutorial](https://learn.adafruit.com/mcp4725-12-bit-dac-tutorial.md)
- [Matrix Portal RGB Display Handbag](https://learn.adafruit.com/matrix-portal-rgb-display-handbag.md)
- [Exercise Buddy: Motion aware BLE media controller](https://learn.adafruit.com/exercise-buddy.md)
- [PyPortal Google Calendar Event Display](https://learn.adafruit.com/pyportal-google-calendar-event-display.md)
- [Touch Deck: DIY Customizable TFT Control Pad](https://learn.adafruit.com/touch-deck-diy-tft-customized-control-pad.md)
- [Adafruit Grayscale 1.5" 128x128 OLED Display](https://learn.adafruit.com/adafruit-grayscale-1-5-128x128-oled-display.md)
