W3C home > Mailing lists > Public > public-device-apis-log@w3.org > September 2016

Re: [magnetometer] Why magneticFieldX instead of x?

From: Rick Waldron via GitHub <sysbot+gh@w3.org>
Date: Thu, 22 Sep 2016 17:54:16 +0000
To: public-device-apis-log@w3.org
Message-ID: <issue_comment.created-248978243-1474566854-sysbot+gh@w3.org>
> We could have a high-level "Compass API" along the lines of J5 to go
 with the low-level Magnetometer. Actually, discussed this briefly at 
F2F yesterday.

What would be the distinction? Why not just provide one: 

Magnetometer {

> How do J5 apps that require true north handle magnetic declination

They would have to: 

1. Include a GPS to be of any use at all
2. Use lat/long to determine present local magnetic declination angle
3. Add or subtract the angle from the value of the `heading` property

Just now I ran a program that prints the heading in degrees as read 
from an HMC5883L, with the sensor on my desk. On the other side of my 
keyboard, I placed my iPhone with the compass app open and lined it up
 to north. Then I lined up the sensor's x axis to north (which was 
off). From there, I looked my present declination angle on 
http://www.magnetic-declination.com/ (at the moment, I'm in Boston), 
and it was -14 degrees. So my program looked like this: 

const five = require("../");
const board = new five.Board();

board.on("ready", () => {
  const mag = new five.Magnetometer({
    controller: "HMC5883L"

  mag.on("change", () => {
    console.log(Math.round(mag.heading - 14));

I'm sure a phone or pc with gps could expose that data in an elegant 

GitHub Notification of comment by rwaldron
Please view or discuss this issue at 
using your GitHub account
Received on Thursday, 22 September 2016 17:54:24 UTC

This archive was generated by hypermail 2.4.0 : Monday, 4 July 2022 12:47:52 UTC