Calibration - sparkfun MAG3110 Hook-Up Manual

Magnetometer
Table of Contents

Advertisement

- Tells you if the mag sensor is currently being calibrated
mag.isCalibrating()
- Reads the SYSMOD register. See the datasheet for more information
mag.getSysMode()
- This sets whether the MAG3110 will output raw (non-user corrected) or offset data. Giving the function a
mag.rawData(boolean)
output, and vice-versa.
- This gives data in µTeslas. It really just divides the normal output by 10 since this is the scale the MAG3110 uses.
mag.readMicroTeslas()
There are additional functions shown in other example sketches included with the library. A few of these are:
- This allows you to read any register of the MAG3110. Read the datasheet for more information. The library has all registers mapped in
mag.readRegister(address)
the format
MAG3110_REGISTER_NAME
mag.writeRegister(address, value)
change settings you didn't mean to!
- When the MAG3110 is in standby, this triggers a single measurement to take place. It lets you save power by keeping the device mostly
mag.triggerMeasurement()
inactive and only take data when you need to. Be aware this single-shot reading may be less accurate than active mode reading since the signal takes time to settle.
See the datasheet for more information. If you want to learn how to do triggered measurements, see the included example "SparkFun-MAG3110-Triggered".
You can also do triggered measurements while in active mode. This is more advanced and is covered in the datasheet.

Calibration

All these functions are great... but what if you need to find a portal to The Upside Down? You need a heading! This sensor and library allow you to obtain the
magnetic north heading very easily!
Note that this only works when the sensor is level with the z-axis pointing straight up or down. The heading will be relative to the positive x-axis (ie: the x-axis arrow
silkscreened on the board points to magnetic north).
To find out how to use the library's calibration, open up the included example sketch,
When you run the sketch, you will see unadjusted readings in the Serial output for the first 5 to 10 seconds. During this period, you must rotate the MAG3110 360
degrees while keeping it level!. This allows our sketch to get its bearings.
The reason for calibration is that your surroundings may have static magnetic fields that offset the MAG3110 readings. For example, if you have something magnetic
near the sensor this will add an offset to the sensor's readings.
This calibration code will center the x and y-axis readings around 0 or about there. The z-axis is not calibrated with this library. This calibration works by taking a
bunch of readings and trying to find the minimum and maximum values for the x and y axes. It then uses these min and max values to calculate an offset and a
scaling factor. The calibration code is based off of this code found here.
A Honeywell application note detailing how the heading is calculated can be found here.
.
- This allows you write a value to any register of the MAG3110. Be careful if you aren't sure what you're doing! You might
SparkFun-MAG3110-Calibration.ino
value will set the data to raw
true
.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the MAG3110 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Sen-12670

Table of Contents