I2C magnetometer

From BitWizard WIKI
(Redirected from I2C magneto)
Jump to: navigation, search

General info

The I2C magnetometre is based on the MAG3110 from freescale.

Pinout

As with all bitwizard I2C boards, the board has a 4 pin female connector on the left and a male connector on the right so that you can daisychain multiple boards.

The pinout is GND, SDA, SCL, VCC.

Voltages

The chip is 3.3V, a regulator is provided on board. This regulator has a dropout of about 1V, so the board currently requires a 5V VCC. We'll move to a different regulator one of these days allowing clean 3.3V operation. (the dropout will be so low that the chip will have to make do with 3.299V if you provide 3.300V....)

Examples

This is a sample script that runs on raspberry pi to extract the X, Y and Z magneto values. It requires you install the bw_tool.

#!/bin/sh
mag="bw_tool -I -D /dev/i2c-1 -a 1c"
$mag -W 10:2:b
sleep 0.1
result=`$mag -R 0:l |sed -e 's/\(..\)/\1 /g' `
#echo $result
x=`echo $result | awk '{print $7$6}'`
y=`echo $result | awk '{print $5$4}'`
z=`echo $result | awk '{print $3$2}'`
echo x=$x y=$y z=$z

The numbers are presented in hex. The magnetic field of the earth is in fact quite small. (your nails don't pop out of the wall if they align with the magnetic field do they?) So the measurement requires some calibration, but the values do change when you change the orientation of the device.

Datasheets

[[1]]