Difference between revisions of "I2C magnetometer"
(Created page with "= 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 lef...") |
|||
Line 15: | Line 15: | ||
= examples = |
= examples = |
||
This is a sample script that runs on raspberry pi to extract the X, Y and Z |
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 |
#!/bin/sh |
||
Line 28: | Line 28: | ||
echo x=$x y=$y z=$z |
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. |
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 = |
= datasheets = |
Revision as of 15:27, 11 August 2015
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]]