ESP8266 and HMC5983 magnetometer example

The Honeywell HMC5983 is a temperature compensated three-axis integrated circuit magnetometer. This surface-mount, multi-chip module is designed for low-field magnetic sensing for applications such as automotive and personal navigation, vehicle detection, and pointing.

The HMC5983 includes our state-of-the-art, high-resolution HMC118X series magnetoresistive sensors plus an ASIC containing amplification, automatic degaussing strap drivers, offset cancellation, and a 12-bit ADC that enables 1° to 2° compass heading accuracy. The I²C or SPI serial bus allows for easy interface. The HMC5983 is a 3.0×3.0x0.9mm surface mount 16-pin leadless chip carrier (LCC).

The HMC5983 utilizes Honeywell’s Anisotropic Magnetoresistive (AMR) technology that provides advantages over other magnetic sensor technologies. Honeywell’s anisotropic, directional sensors excel in linearity, low hysteresis, null output and scale factor stability over temperature, and with very low cross-axis sensitivity. These sensors’ solid-state construction is designed to measure both the direction and the magnitude of magnetic fields, from milli-gauss to 8 gauss. Honeywell’s Magnetic Sensors are among the most sensitive and reliable low-field sensors in the industry.

Parts List

Here are the parts I used

 

Name Links
Wemos Mini
HMC5983
Connecting cables

 

Connection

Here is a layout, its an easy device to connect

The HM5883 is the same as the HMC5983

 

Code

You will need to install the following library – https://github.com/arduino/HMC5983

 

#include <HMC5983.h>
#include <Wire.h>

HMC5983 compass;

void setup () {
Serial.begin(9600);
compass.begin(); // use "true" if you need some debug information
}

void loop() {
float c = -999;
c = compass.read();
if (c == -999) {
Serial.println("Reading error, discarded");
} else {
Serial.println(c);
}
delay(500);
}

 

 

Output

Open the serial monitor – this is what you should expect to see. I moved the sensor around

13.84
22.05
23.39
38.34
5.99
9.68
17.69
24.28
16.61

 

Links

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here