Using a MMC5603 Triple-axis Magnetometer sensor with an ESP8266

In this article we look at a Triple-axis Magnetometer, the MMC5603 and connect it to an ESP8266 board – a Wemos D1 Mini pro was what I had at hand

Sensor Information

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 very strong rare earth magnets

I bought an Adafruit breakout board, so the MMC5603 comes integrated with a voltage regulator and level-shifting circuitry to allow it to be used with 3.3V devices or 5V devices.

Along with a header, there is a SparkFun Qwiic compatible STEMMA QT connectors for the I2C bus so you just need to fit a suitable cable


    • Superior Dynamic Range and Accuracy:
      ±30 G FSR
    • 20bits operation mode
    • 0.0625mG per LSB resolution
    • 2 mG total RMS noise
    • Enables heading accuracy of 1º

Sensor true frequency response up to 1KHz
On-chip automatic degaussing with built-in SET/RESET function

    • Eliminates thermal variation induced offset error (Null field output)
    • Clears the residual magnetization resulting

from strong external fields
On-chip sensitivity compensation
On-chip temperature sensor
Selftest signal available
Data_ready Interrupt (I3C only)
Low power consumption
1 µA power down current
I2C slave, FAST (≤400 KHz) mode
I3C interface available
1.62V to 3.6V

Parts Required

You can connect to the sensor using dupont style jumper wire.

Name Link
Arduino Uno Aliexpress Link
Ebay Link
Amazon Link
Connecting cables Aliexpress Link
Ebay Link
Amazon Link


I used 3.3v from the Wemos D1 Pro – 5v should be ok as the adafruit sensor has a voltage regulator on it.


Code Example

I installed the Adafruit library using the Arduino ide which also installed the dependency library

Click the Manage Libraries … menu item, search for MMC56x3, and select the Adafruit_MMC56x3 library

If asked about dependencies, click on the “Install all” option

If the Dependencies window does appear, you already have the required dependencies installed.

If the dependencies are already installed, make sure that you have the latest ones installed using the Arduino Library Manager

This is the magsensor example – there are a few examples

#include <Adafruit_MMC56x3.h>

/* Assign a unique ID to this sensor at the same time */
Adafruit_MMC5603 mmc = Adafruit_MMC5603(12345);

void setup(void) {
  while (!Serial)
    delay(10); // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("Adafruit_MMC5603 Magnetometer Test");

  /* Initialise the sensor */
  if (!mmc.begin(MMC56X3_DEFAULT_ADDRESS, &Wire)) {  // I2C mode
    /* There was a problem detecting the MMC5603 ... check your connections */
    Serial.println("Ooops, no MMC5603 detected ... Check your wiring!");
    while (1) delay(10);

  /* Display some basic information on this sensor */

void loop(void) {
  // Get a new sensor event 
  sensors_event_t event;

  // Display the results (magnetic vector values are in micro-Tesla (uT))
  Serial.print("X: ");
  Serial.print("  ");
  Serial.print("Y: ");
  Serial.print("  ");
  Serial.print("Z: ");
  Serial.print("  ");

  // Read and display temperature
  float temp_c = mmc.readTemperature();
  Serial.print("Temp: "); 
  Serial.println(" *C");
  // Delay before the next sample



Here is  an example of what I saw in the serial monitor window – you may see some different results. I placed a magnet near the sensor – at the higher values

X: -652.38 Y: -511.49 Z: 666.37 uT
Temp: 17.00 *C
X: -652.68 Y: -514.96 Z: 667.18 uT
Temp: 17.00 *C
X: -424.29 Y: -160.08 Z: 412.38 uT
Temp: 17.00 *C
X: 33.26 Y: 115.93 Z: -139.43 uT
Temp: 16.20 *C
X: 49.84 Y: -28.80 Z: -116.92 uT
Temp: 15.40 *C
X: 49.96 Y: -29.28 Z: -116.55 uT
Temp: 16.20 *C
X: 49.96 Y: -29.39 Z: -116.69 uT