RawSensors

RhoElements 2.x API

Overview

The RawSensors Module is used to retrieve the raw data values of the specified sensors.

Syntax

RawSensors (Module) <META> Syntax

<META HTTP-Equiv="RawSensors" content="[method / parameter]">

<META HTTP-Equiv="RawSensors" content="sensorEvent:url('[jsFunction | url]')">

RawSensors JavaScript Object Syntax:
By default the JavaScript Object 'RawSensors' will exist on the current page and can be used to interact directly with the RawSensors.
To Invoke RawSensors methods via JavaScript use the following syntax: rawsensors.method();

e.g. RawSensors.getSensorData();

To Set RawSensors parameters via JavaScript use the following syntax: rawsensors.parameter = 'value'; remembering to enclose your value in quotes where appropriate.

e.g. RawSensors.accelerometer = 'value';

To Set RawSensors return events via JavaScript use the following syntax: rawsensors.event = JavaScript Function;

e.g. RawSensors.sensorEvent = 'doFunction(%json)';

To set multiple EMML parameters / events on a single line use the following syntax: rawsensors.setEMML("[Your EMML Tags]");

e.g. RawSensors.setEMML("accelerometer:value;sensorEvent:url('JavaScript:doFunction(%json)');getSensorData");

Methods

Items listed in this section indicate methods or, in some cases, indicate parameters which will be retrieved.

NameDescriptionDefault Value
getSensorDataThis immediately returns the raw data of the specified sensors via the sensorEventN/A

Parameters

Items listed in this section indicate parameters, or attributes which can be set.

NamePossible ValuesDescriptionDefault Value
accelerometer:[Value] Enabled, DisabledThis enables/disables the accelerometer sensor data retrieval.Disabled
deviceOrientation:[Value] Enabled, DisabledThis enables/disables the device orientation sensor data retrieval.Disabled
tiltangle:[Value] Enabled, DisabledThis enables/disables the tiltangle sensor data retrieval.Disabled
motion:[Value] Enabled, DisabledThis enables/disables the motion sensor data retrieval.Disabled
ecompass:[Value] Enabled, DisabledThis enables/disables the ecompass sensor data retrieval.Disabled
magnetometer:[Value] Enabled, DisabledThis enables/disables the magnetometer sensor data retrieval.Disabled
gyroscope:[Value] Enabled, DisabledThis enables/disables the gyroscope sensor data retrieval.Disabled
ambientlight:[Value] Enabled, DisabledThis enables/disables the ambientlight sensor data retrieval.Disabled
proximity:[Value] Enabled, DisabledThis enables/disables the proximity sensor data retrieval.Disabled
proximitylongrange:[Value] Enabled, DisabledThis enables/disables the proximitylongrange sensor data retrieval.Disabled
pressure:[Value] Enabled, DisabledThis enables/disables the pressure sensor data retrieval.Disabled
temperature:[Value] Enabled, DisabledThis enables/disables the temperature sensor data retrieval.Disabled
humidity:[Value] Enabled, DisabledThis enables/disables the humidity sensor data retrieval.Disabled
gravity:[Value] Enabled, DisabledThis enables/disables the gravity sensor data retrieval.Disabled
linearAcceleration:[Value] Enabled, DisabledThis enables/disables the linear acceleration sensor data retrieval.Disabled
rotation:[Value] Enabled, DisabledThis enables/disables the rotation sensor data retrieval.Disabled
orientation:[Value] Enabled, DisabledThis enables/disables the orientation sensor data retrieval.Disabled
all:[Value] Enabled, DisabledThis enables/disables all the available sensors data retrieval.Disabled
minimumInterval:[Value] Value in milli secondsThe minimum amount of time gap between two sensor update events, specified in milliseconds. The interval cannot be set to less than 200 milliseconds, if a value of less than 200 milli seconds is specified, the interval will be defaulted to 200 milli seconds.1000 milliseconds

Events

Values are returned to the caller in RhoElements via Events. Most modules contain events and those returned from this module are given below along with the event parameters. Events can cause a navigation to a new URL or a JavaScript function on the page to be invoked. Each event will in most cases have a number of parameters associated with it which will either be strings or JavaScript arrays. Event parameters can be accessed either directly or via JSON objects.


sensorEvent

The sensorEvent event is triggered when a parameter of the specfiied sensors is changed.

IDNameDescription
1accelerometerXX co-ordinate value of the Accelerometer sensor in SI units (m/s^2)
2accelerometerYY co-ordinate value of the Accelerometer sensor in SI units (m/s^2)
3accelerometerZZ co-ordinate value of the Accelerometer sensor in SI units (m/s^2)
4deviceOrientationvalue of the orientation sensor
5tiltangleXX co-ordinate value of the tiltangle sensor in degrees units
6tiltangleYY co-ordinate value of the tiltangle sensor in degrees units
7tiltangleZZ co-ordinate value of the tiltangle sensor in degrees units
8motionvalue of the motion sensor
9ecompassvalue of the ecompass sensor
10magnetometerXX value of the magnetometer sensor in micro-Tesla (uT) units
11magnetometerYY value of the magnetometer sensor in micro-Tesla (uT) units
12magnetometerZZ value of the magnetometer sensor in micro-Tesla (uT) units
13gyroscopeXX co-ordinate value of the gyroscope sensor in radians/second units
14gyroscopeYY co-ordinate value of the gyroscope sensor in radians/second units
15gyroscopeZZ co-ordinate value of the gyroscope sensor in radians/second units
16ambientLightvalue of the ambient Light sensor in SI lux units
17proximityvalue of the proximity sensor in centimeters units
18proximitylongrangevalue of the proximitylongrange sensor
19pressurevalue of the pressure sensor in hPa (millibar) units
20temperaturevalue of the temperature sensor in degree Celsius units
21humidityvalue of the humidity sensor in percent units
22gravityXX co-ordinate value of the gravity sensor in SI units (m/s^2)
23gravityYY co-ordinate value of the gravity sensor in SI units (m/s^2)
24gravityZZ co-ordinate value of the gravity sensor in SI units (m/s^2)
25linearAccelerationXX co-ordinate value of the linear acceleration sensor in SI units (m/s^2)
26linearAccelerationYY co-ordinate value of the linear acceleration sensor in SI units (m/s^2)
27linearAccelerationZZ co-ordinate value of the linear acceleration sensor in SI units (m/s^2)
28rotationXX co-ordinate value of the rotation sensor as a combination of an angle and an axis
29rotationYY co-ordinate value of the rotation sensor as a combination of an angle and an axis
30rotationZZ co-ordinate value of the rotation sensor as a combination of an angle and an axis
31orientationXX co-ordinate value of the orientation sensor in degrees units
32orientationYY co-ordinate value of the orientation sensor in degrees units
33orientationZZ co-ordinate value of the orientation sensor in degrees units

Remarks

sensor data format

Since the json object returned by the event contains the data for all of the sensors if a sensor is not enabled or absent then that data is undefined (null) and should not be used.

minimum interval

As some of the sensor values change rapidly the minimum interval between two updates should be specified as a reasonable value, otherwise there can be a performance impact.

Cross platform consistency

As this plugin returns the raw sensor values reported by the operating system the values might differ between platforms. Which sensors are supported on which platform are dependant on the hardware available on the device.

Requirements

RhoElements Version2.1 or above
Supported DevicesAll supported devices. On Windows this is only supported in MPA3.0 devices.
Minimum RequirementsNone.
PersistenceNon Persistent - Changes to this module will not persist when navigating to a new page.

HTML/JavaScript Examples

The following example enables all the sensors and waits for the updates through the sensor event:

<META HTTP-EQUIV="RawSensors" CONTENT="sensorEvent:url('JavaScript:onSensor(%json);');all:enabled; ">

<SCRIPT>
    function onSensor(jsonObject)
    {
        var theOutput = "<BR><BR><B>Accelerometer  </B>";        
        theOutput = theOutput + "X: " + jsonObject.accelerometerX + ", Y: " + jsonObject.accelerometerY + ", Z: " + jsonObject.accelerometerZ + "<BR>";
        theOutput = theOutput + "<B>Orientation  </B>";        
        theOutput = theOutput + "X: " + jsonObject.deviceOrientation  + "<BR>";
        theOutput = theOutput + "<B>Tilt  </B>";
        theOutput = theOutput + "X: " + jsonObject.tiltangleX  + ", Y: " + jsonObject.tiltangleY  + ", Z: " + jsonObject.tiltangleZ  + "<BR>";
        theOutput = theOutput + "<B>Motion  </B>";
        theOutput = theOutput + "X: " + jsonObject.motion  + "<BR>";
        theOutput = theOutput + "<B>Ecompass  </B>";
        theOutput = theOutput + "X: " + jsonObject.ecompass  + "<BR>";
        theOutput = theOutput + "<B>Magnetometer  </B>";
        theOutput = theOutput + "X: " + jsonObject.magnetometerX  + ", Y: " + jsonObject.magnetometerY  + ", Z: " + jsonObject.magnetometerZ  + "<BR>";
        theOutput = theOutput + "<B>Gyroscope  </B>";
        theOutput = theOutput + "X: " + jsonObject.gyroscopeX  + ", Y: " + jsonObject.gyroscopeY  + ", Z: " + jsonObject.gyroscopeZ  + "<BR>";
        theOutput = theOutput + "<B>AmbientLight  </B>";
        theOutput = theOutput + "X: " + jsonObject.ambientLight  + "<BR>";
        theOutput = theOutput + "<B>Proximity  </B>";
        theOutput = theOutput + "X: " + jsonObject.proximity  + "<BR>";
        theOutput = theOutput + "<B>Proximitylongrange  </B>";
        theOutput = theOutput + "X: " + jsonObject.proximitylongrange  + "<BR>";
        theOutput = theOutput + "<B>Pressure  </B>";
        theOutput = theOutput + "X: " + jsonObject.pressure  + "<BR>";
        theOutput = theOutput + "<B>Temperature  </B>";
        theOutput = theOutput + "X: " + jsonObject.temperature  + "<BR>";
        theOutput = theOutput + "<B>Humidity  </B>";
        theOutput = theOutput + "X: " + jsonObject.humidity  + "<BR>";
        theOutput = theOutput + "<B>Gravity  </B>";
        theOutput = theOutput + "X: " + jsonObject.gravityX  + ", Y: " + jsonObject.gravityY  + ", Z: " + jsonObject.gravityZ  + "<BR>";
        theOutput = theOutput + "<B>Linear Acceleration  </B>";
        theOutput = theOutput + "X: " + jsonObject.linearAccelerationX  + ", Y: " + jsonObject.linearAccelerationY  + ", Z: " + jsonObject.linearAccelerationZ  + "<BR>";
        theOutput = theOutput + "<B>Rotation  </B>";
        theOutput = theOutput + "X: " + jsonObject.rotationX  + ", Y: " + jsonObject.rotationY  + ", Z: " + jsonObject.rotationZ  + "<BR>";
        theOutput = theOutput + "<B>Orientation  </B>";
        theOutput = theOutput + "X: " + jsonObject.orientationX  + ", Y: " + jsonObject.orientationY  + ", Z: " + jsonObject.orientationZ  + "<BR>";
        outputDiv.innerHTML = theOutput;
    }
</SCRIPT>
<div id="outputDiv">Sensor Output Goes Here</div>
<P>
  <INPUT align="center" type="button" value="Retrieve Sensor Data" onclick="RawSensors.getSensorData();"><br>