obniz Parts Library

HMC5883L

GitHub
HMC5883L
Usable Devices :
obniz_board
Found at :
www.adafruit.com

Compass Sensor - HMC5883L

TRIPLE-AXIS magnetometer (compass)

Calibration is important to get correct direction.

Datasheet

wired(obniz, { [gnd, sda, scl, i2c]});

Connect to an obniz Board.

obniz Board can't supply a power to this sensor directly.
Use external 3.3v or use linear regulator to drop 5v output of obniz Board to 3.3v.

// Javascript Example
var compass = obniz.wired("HMC5883L", {gnd:1 , sda:2 , scl:3 });
compass.init();
while(true) {
  var obj = await compass.get();
  console.log(obj.x, obj.y, obj.z);
}

init();

initialize the sensor.

// Javascript Example
var compass = obniz.wired("HMC5883L", {gnd:1 , sda:2 , scl:3 });
compass.init();

[await] get()

get x,y,z result object from a sensor.

// Javascript Example
var compass = obniz.wired("HMC5883L", {gnd:1 , sda:2 , scl:3 });
compass.init();
while(true) {
  var obj = await compass.get();
  console.log(obj.x, obj.y, obj.z);
}

Supported from: obniz.js 3.5.0