Ambient Atmospheric Pressure (Barometric) Sensor

Editor’s Draft,

This version:
https://w3c.github.io/barometer/
Latest published version:
https://www.w3.org/TR/barometer/
Version History:
https://github.com/w3c/barometer/commits/gh-pages/index.bs
Feedback:
public-device-apis@w3.org with subject line “[barometer] … message topic …” (archives)
Issue Tracking:
GitHub
Issues
Editor:
Kenneth Christiansen (Intel Corporation)
Bug Reports:
via the w3c/barometer repository on GitHub
Test Suite:
web-platform-tests on GitHub

Abstract

This specification defines a concrete sensor interface to monitor to measure the atmospheric pressure.

Status of this document

This is a public copy of the editors’ draft. It is provided for discussion only and may change at any moment. Its publication here does not imply endorsement of its contents by W3C. Don’t cite this document other than as work in progress.

If you wish to make comments regarding this document, please send them to public-device-apis@w3.org (subscribe, archives). When sending e-mail, please put the text “barometer” in the subject, preferably like this: “[barometer] …summary of comment…”. All comments are welcome.

This document was produced by the Device and Sensors Working Group.

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

This document is governed by the 1 September 2015 W3C Process Document.

1. Introduction

The Barometric Sensor extends the Generic Sensor API [GENERIC-SENSOR] to provide information about the ambient atmospheric pressure, as detected by the device’s primary barometric sensor.

The pressure level is reported in hPa (millibar) and represents the local atmospheric pressure level, in contrast to many home barometers which are often adjusted to report the pressure as was it at sea level as that is used in weather reports.

2. Examples

let sensor = new BarometicSensor();
sensor.start();

sensor.onchange = event => console.log(event.reading.pressure);

sensor.onerror = function(event) {
    console.log(event.error.name, event.error.message);
};

3. Security and Privacy Considerations

There are no specific security and privacy considerations beyond those described in the Generic Sensor API [GENERIC-SENSOR].

4. Model

The Barometic Sensor’s associated Sensor subclass is the BarometricSensor class.

The Barometic Sensor’s associated SensorReading subclass is the BarometricSensorReading class.

The Barometic Sensor has a default sensor, which is the device’s main barometic detector.

The Barometic Sensor has a single supported reporting mode which is "auto".

The Barometic Sensor’s permission name is "barometer". It has no associated PermissionDescriptor.

The Barometic Sensor has an associated abstract operation to retrieve the sensor permission which must simply return a permission whose name is "barometer".

The Barometic Sensor has an associated abstract operation to construct a SensorReading object which creates a new BarometicSensorReading object and sets its pressure attribute to positive infinity.

Pressure is a value that represents the the local atmospheric pressure level. Its unit is the hPa (millibar).

5. API

5.1. The BarometricSensor Interface

[Constructor(optional SensorOptions sensorOptions)]
interface BarometricSensor : Sensor {
  readonly attribute BarometricSensorReading? reading;
};

To Construct an BarometricSensor Object the user agent must invoke the construct a Sensor object abstract operation.

5.2. The BarometricSensorReading Interface

[Constructor(BarometricSensorReadingInit barometricSensorReadingInit)]
interface BarometricSensorReading : SensorReading {
    readonly attribute unrestricted double? pressure;
};

dictionary BarometricSensorReadingInit {
  unrestricted double? pressure;
};

5.2.1. The BarometricSensorReading constructor

5.2.2. The pressure attribute

The pressure attribute of the BarometricSensorReading interface represents the local atmospheric pressure level in hPa (millibar).

6. Acknowledgements

Tobie Langel for the work on Generic Sensor API and inputs on this specification.

Conformance

Document conventions

Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.

All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]

Examples in this specification are introduced with the words “for example” or are set apart from the normative text with class="example", like this:

This is an example of an informative example.

Informative notes begin with the word “Note” and are set apart from the normative text with class="note", like this:

Note, this is an informative note.

Conformant Algorithms

Requirements phrased in the imperative as part of algorithms (such as "strip any leading space characters" or "return false and abort these steps") are to be interpreted with the meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.

Conformance requirements phrased as algorithms or specific steps can be implemented in any manner, so long as the end result is equivalent. In particular, the algorithms defined in this specification are intended to be easy to understand and are not intended to be performant. Implementers are encouraged to optimize.

Conformance Classes

A conformant user agent must implement all the requirements listed in this specification that are applicable to user agents.

A conformant server must implement all the requirements listed in this specification that are applicable to servers.

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[GENERIC-SENSOR]
Tobie Langel; Rick Waldron. Generic Sensor API. 24 March 2016. WD. URL: https://w3c.github.io/sensors/
[PERMISSIONS]
Mounir Lamouri; Marcos Caceres. The Permissions API. 7 April 2015. WD. URL: https://w3c.github.io/permissions/
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119

IDL Index

[Constructor(optional SensorOptions sensorOptions)]
interface BarometricSensor : Sensor {
  readonly attribute BarometricSensorReading? reading;
};

[Constructor(BarometricSensorReadingInit barometricSensorReadingInit)]
interface BarometricSensorReading : SensorReading {
    readonly attribute unrestricted double? pressure;
};

dictionary BarometricSensorReadingInit {
  unrestricted double? pressure;
};