Home CodeEspruino Espruino and HMC5883l example

Espruino and HMC5883l example

by shedboy71

The Honeywell HMC5883 is a surface mount multi-chip module designed for low field magnetic sensing with a digital interface for applications such as low cost compassing and magnetometry. The HMC5883 includes our state of the art, high-resolution HMC118X series magneto-resistive sensors plus Honeywell developed ASIC containing amplification, automatic degaussing strap drivers, offset cancellation, 12-bit ADC that enables 1° to 2° compass heading accuracy.
The I2C serial bus allows for easy interface

FEATURES

 12-Bit ADC Coupled with Low Noise AMR Sensors Achieves 5 milli-Gauss Resolution in ±8 Gauss Fields
 Built-In Self Test 
 Low Voltage Operations (1.6 to 3.3V)
 I2C Digital Interface
 Lead Free Package Construction
 Wide Magnetic Field Range (+/-8 Oe)
 Fast 116 Hz Maximum Output Rate

 

Schematic and Connection

 

 

Code

 

[codesyntax lang=”javascript”]

I2C1.setup( { scl: B6, sda: B7 } );
var compass=require("HMC5883").connect(I2C1,C11,0);

compass.setGain(1);
compass.setup(0,0);

compass.reads(function(a) {console.log(a);});

[/codesyntax]
Output
{ “x”: 43.24000078439, “y”: -125.12000226974, “z”: -164.68000298738, “overflow”: false }
{ “x”: 46.92000085115, “y”: -124.20000225305, “z”: -162.84000295400, “overflow”: false }
{ “x”: 15.64000028371, “y”: 111.32000201940, “z”: -234.60000425577, “overflow”: false }
Links

https://www.espruino.com/HMC5883

HMC5883L Triple Axis Compass Magnetometer Sensor Module 3V-5V For Arduino GY-273

Share

You may also like