Table of Contents

Firefox OS Tricorder

The following slides are available in this presentation:

Firefox OS Tricorder

Reading Device Sensor Data in JavaScript

Robert Kaiser, "KaiRo" <>
Program Manager, Mozilla QA


What is a Tricorder?

Starfleet Tricorder, 2370

Sensor device as seen on "Star Trek"

Displays whatever data is needed at plot speeds and resolutions.

Firefox OS Tricorder App

Displays sensor data


Firefox OS Tricorder UI


Position Module

GPS, WiFi/Cell Location

API: Geolocation

Permission: geolocation

Position: Code

  this.watchID = navigator.geolocation.watchPosition(
    function(position) { ... },
    function(error) { ... },
    {enableHighAccuracy: true, maximumAge: 10000, timeout: 60000}


Gravity Module

Accelerometer, Magnetic Compass

APIs: deviceorientation, devicemotion events

Permissions: ---

Gravity: Code

  window.addEventListener("deviceorientation", this.orientEvent, true);
  window.addEventListener("devicemotion", this.motionEvent, true);

  orientEvent: function(orientData) {
    orientData.alpha / .beta / .gamma (in °)
  motionEvent: function(event) {
    event.accelerationIncludingGravity.x / .y / .z (in m/s²)

  window.removeEventListener("deviceorientation", this.orientEvent, true);
  window.removeEventListener("devicemotion", this.motionEvent, true);

Sound Module


APIs: WebRTC(getUserMedia), WebAudio

Permissions: audio-capture

Sound: Code

Environment Module

Light, Proximity; Flashlight

APIs: devicelight, deviceproximity events; Camera API

Permissions: ---; camera (for Flash)

Environment: Code

Device Module


APIs: Battery

Permissions: ---

Device: Code


Data & Mister Tricorder