The Device APIs Working Group decided to put this general Sensor API specification on hold and work on each sensor separately (see e.g. the Device Proximity).
This section is non-normative
This specification provides several new DOM events that allow application code to obtain information given by the various sensors available on a hosting device. The information provided through this DOM event is raw sensor data. The specification is aimed at covering well-known sensors that are commonly found in devices.
There will be a DOM event for each of the sensor type which supplies the physical raw sensor data for that sensor type.
The following code snippet illustrates how to monitor sensor data, for instance the ambient temperature:
This specification defines conformance criteria that apply to a single product: the user agent that implements the interfaces that it contains.
Implementations that use ECMAScript to implement the APIs defined in this specification MUST implement them in a manner consistent with the ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]], as this specification uses that specification and terminology.
This section is non-normative
This specification is limited to provide DOM events for retrieving raw sensor information for physical sensors of a hosting device. The scope of this specification does not include providing utilities to manipulate this data, such as sensor fusing or tranformation libraries. Nor does it include direct control of these sensors.
A conforming implementation of this specification MUST provide a mechanism that protects the user's privacy and this mechanism should ensure that no sensitive information is made available through this API without the user's express permission. User agents MUST acquire permission through a user interface, unless they have prearranged trust relationships with users.
windowobject when there is a change in the sensor data. Registration for, and firing of the event must follow the usual behavior of DOM Events. If the UA does not support the sensor of interest then the event will not be fired.
User agents must also accept an event handler for addEventListener with the following interface:The event handler passed to
addEventListenermust provide the signature:
ondatacallback is raised when there is sensor data to report. The
valueis the sensor data as specified in section 6. The
minis the minimum value in the range the sensor detects, if available. If not available, a value of zero must be returned. The
maxis maximum value in the range the sensor detects, if available. If not available, a value of zero must be returned.
This section specifies a base set of DOM sensor events and related data formats. If the UA supports these sensor types, it MUST use this data format definition. UAs may choose which sensors they wish to support. A UA MUST fire the DOM Sensor Event for sensors it supports in accordance with the following table::
|DOM Sensor Event||Sensor Type||Data Type||Units|
|devicetemperature||A ambient temperature sensor||double||degree Celsius (ºC)|
|devicepressure||A pressure sensor||double||kiloPascal (kP)|
|devicehumidity||A releative humidity sensor||double||percentage|
|devicelight||A light sensor||double||Lux|
|devicenoise||A ambient noise sensor||double||dbA|
|deviceproximity||A proximity sensor||double||centimetres (cm)|
WAC Ipanema Device APIs Lightweight Participation WG, in particular Bryan Sullivan, Balaji N.V., and Kaushik Das.
Mozilla's Device Proximity and Light Sensor APIs, in particular Doug Turner
José Manuel Cantera Fonseca from Telefónica as one of the original contributors and editors to this specification.
Marcos Caceres from W3C, Wayne Carr and Sakari Poussa from Tizen