The 'i2c Python library 'of think bowl provides the 'hmc5883l' sensor interface to conveniently obtain sensor information.
# Hmc5883l
Here is the installation method
Http://www.cnblogs.com/hangxin1940/archive/2013/04/04/2999015.html
Http://www.cnblogs.com/hangxin1940/archive/2013/04/05/3000395.html
For detailed code, please move to https://bitbucket.org/thinkbowl/i2clibraries/src/14683feb0f96/i2c_hmc5883l.py? At = Master
# _ Init _ (port, ADDR = 0x1e, Gauss = 1.3)
Constructor
Port 'Port', type A is 0, type B is 1
'Addr 'address. The default value is 1E.
'Gauss 'Gaussian value. The default value is 1.3,
# _ STR __()
Power Management settings. It can be a variable starting with 'pm.
# Setcontinuousmode ()
Set that each axis is constantly updated.
# Setscale (Gauss)
Set the measurement range. The value must be 0.88, 1.3, 1.9, 2.5, 4.0, 4.7, 5.6, or 8.1 Gauss.
# Setdeclination (degrees, minutes = 0)
Sets the magnetic angle compensation in the north direction.
# Getoptions (Register)
Obtains register information, which is usually called by other methods.
# Getdeclination ()
Returns the padding angle of the source image.
# Getdeclinationstring ()
Returns the string format of the True North Magnetic offset compensation.
# Getheading ()
Returns the current point
# Getheadingstring ()
Returns the string format currently pointed.
# Getaxes ()
Returns the direction of each axis.