Properties

public static

configuration

Configuration values that can be altered.
Make sure to call any of the following functions to save the settings in device after altering the configuration settings:

public static

configuration.BASIC

Basic configuration settings.

It is good practice to read the basic configuration settings from the device on startup 
in case the settings in flash memory do not match the default settings specified in configuration.BASIC.
SENSOR_COMBINATION:            Specify which sensors are enabled (default: All)
ACCELEROMETER_RANGE:           Default: 2g
ACCELEROMETER_RATE:            Default: 100 Hz
GYROSCOPE_RANGE:               Default: 2000 deg/s
GYROSCOPE_RATE:                Default: 100 Hz
MAGNETOMETER_RATE:             Reserved for future use
ENVIRONMENTAL_SENSORS_RATE:    Default: 2 Hz
SENSOR_FUSION_RATE:            Default: 10 Hz
SENSOR_FUSION_RAW_DATA_ENABLE: Enable/Disable sensor fusion raw data (Default: Enabled)
CALIBRATION_MODE:              Default: Static
AUTO_CALIBRATION_MODE:         Default: Basic

Example

// Change accelerometer range to 16g
iotsensor.configuration.BASIC.ACCELEROMETER_RANGE = iotsensor.enums.ACCELEROMETER_RANGE._16g;
		
// Set basic configuration in device
iotsensor.setBasicConfiguration();

// Optional - Store basic configuration in flash
iotsensor.storeBasicConfigurationInFlash();

// Optional - Retrieve new settings from device
iotsensor.readBasicConfiguration(
	function(data)
	{
     console.log('Settings: ' + data);
	}
);
public static

configuration.CAL_COEF

Calibration Coefficients settings.

SENSOR_TYPE: Magnetometer (Default: 2)
Q_FORMAT: Precision of matrix coefficients (Default: 14)
OFFSET_VECTOR: 3x1 Int16 array listed in [x, y, z] order (Default: [0, 0, 0])
MATRIX: 3x3 Int16 array (Default: [[16384, 0, 0], [0, 16384, 0], [0, 0, 16384]])
SENSOR_TYPE is set to 2 (magnetometer) and should not be changed.

Example

// Set Q_FORMAT
iotsensor.configuration.CAL_COEF.Q_FORMAT = 12;

// Set offset vector
iotsensor.configuration.OFFSET_VECTOR = new Int16Array([100, 100, 100]);

// Set matrix
iotsensor.configuration.MATRIX = [new Int16Array([100, 0, 0]), new Int16Array([0, 100, 0]), new Int16Array([0, 0, 100])];

// Set Calibration coefficients in device
iotsensor.setCalibrationCoefficients();

// Retrieve calibration coefficients from device
iotsensor.readCalibrationCoefficients(
	function(data)
	{
		console.log('Calibration coefficients: ' + data);
	}
);
public static

configuration.CAL_CONTROL

Calibration control settings.

SENSOR_TYPE: Magnetometer (Default: 2)
CONTROL_FLAGS: Uint8 array listed in [byte2, byte3] order (Default: [12, 0])
PARAMETERS: Uint8Array(12) (Default: all zeros)
SENSOR_TYPE is set to 2 (magnetometer) and should not be changed.

Example

// Set calibration control flag byte 2 (CONTROL_FLAG[0])
iotsensor.configuration.CAL_CONTROL.CONTROL_FLAGS[0] = 28 // 0011100

// Set calibration control flags in device
iotsensor.setCalibrationControl();

// Retrieve calibration control flags from device
iotsensor.readCalibrationControl(
	function(data)
	{
		console.log('Calibration control ' + data);
	}
);
public static

configuration.SFL_COEF

Sensor Fusion Coefficients settings.

BETA_A:             Unsigned Q15 fixed-point format in range 0x0000 (0) to 0x8000 (1.0) (default: 0x028F: 0.02)
BETA_M:             Unsigned Q15 fixed-point format in range 0x0000 (0) to 0x8000 (1.0) (default: 0x028F: 0.02)
TEMPERATURE_REPORT: 32 bit unsigned integer (reserved for future use)

Example

// Change Beta A to 2000
iotsensor.configuration.SFL_COEF.BETA_A = 2000;
		
// Set basic configuration in device
iotsensor.setSflCoefficients();

// Retrieve sensor fusion coefficients from device
iotsensor.readSflCoefficients(
	function(data)
	{
		console.log('Sfl coefficients: ' + data);
	}
);
public static

enums

Available values that can be used to configure the sensors
These objects can not be altered.

public static

enums.ACCELEROMETER_RANGE

Accelerometer Range - Default: 2G (0x03)

 _2:  2G
 _4:  4G
 _8:  8G
 _16: 16G

Example

// Set accelerometer range to 4G
iotsensor.configuration.BASIC.ACCELEROMETER_RANGE = iotsensor.enums.ACCELEROMETER_RANGE._4;
public static

enums.ACCELEROMETER_RATE

Accelerometer Rate - Default: 100Hz (0x08)

 _0_78:  0.78 Hz
 _1_56:  1.56 Hz
 _3_12:  3.12 Hz
 _6_25:  6.25 Hz
 _12_5:  12.5 Hz
 _25:    25 Hz
 _50:    50 Hz
 _100:   100 Hz

Example

// Set accelerometer rate to 50 Hz
iotsensor.configuration.BASIC.ACCELEROMETER_RATE = iotsensor.enums.ACCELEROMETER_RATE._50;
public static

enums.AUTO_CALIBRATION_MODE

Auto Calibration Mode - Default: Basic (0)

 _basic:       Basic
 _smartfusion: Smart Fusion

Example

// Set auto calibration mode to Smart Fusion
iotsensor.configuration.BASIC.AUTO_CALIBRATION_MODE = iotsensor.enums.AUTO_CALIBRATION_MODE._smartfusion;
public static

enums.CALIBRATION_MODE

Calibration Mode - Default: Static (1)

 _none:       None
 _static:     Static
 _continuous: Continuous
 _one_shot:   One Shot

Example

// Set calibration mode to none
iotsensor.configuration.BASIC.CALIBRATION_MODE = iotsensor.enums.CALIBRATION_MODE._none;
public static

enums.ENVIRONMENTAL_SENSORS_RATE

Environmental Sensors Rate - Default: 2Hz (4)

 _0_5: 0.5 Hz
 _1:   1 Hz
 _2:   2 Hz

Example

// Set environmental sensors rate to 1 Hz
iotsensor.configuration.BASIC.ENVIRONMENTAL_SENSORS_RATE = iotsensor.enums.ENVIRONMENTAL_SENSORS_RATE._1;
public static

enums.GYROSCOPE_RANGE

Gyroscope Range - Default: 2000 deg/s (0x00)

 _500:   500 deg/s
 _1000:  1000 deg/s
 _2000:  2000 deg/s

Example

// Set gyroscope range to 500 deg/s
iotsensor.configuration.BASIC.GYROSCOPE_RANGE = iotsensor.enums.GYROSCOPE_RANGE._500;
public static

enums.GYROSCOPE_RATE

Gyroscope Rate - Default: 100 Hz (0x08)

 _0_78:  0.78 Hz (RAW project only)
 _1_56:  1.56 Hz (RAW project only)
 _3_12:  3.12 Hz (RAW project only)
 _6_25:  6.25 Hz (RAW project only)
 _12_5:  12.5 Hz (RAW project only)
 _25:    25 Hz
 _50:    50 Hz
 _100:   100 Hz

Example

// Set gyroscope rate to 50 Hz
iotsensor.configuration.BASIC.GYROSCOPE_RATE = iotsensor.enums.GYROSCOPE_RATE._50;
public static

enums.MAGNETOMETER_RATE

Magnetometer Rate - Reserved for future use

public static

enums.SENSOR_COMBINATION

Sensor Combination - Default: All (0x0F)

Changing SENSOR_COMBINATION to any other than '_all' will disable all environmental sensors
 _gyro:           Gyroscope
 _accel_gyro:     Accelerometer & Gyroscope
 _accel_gyro_mag: Accelerometer, Gyroscope & Magnetometer
 _all:            All sensors (including environmental sensors)

Example

// Enable only gyroscope
iotsensors.configuration.BASIC.SENSOR_COMBINATION = iotsensor.enums.SENSOR_COMBINATION._gyro;
public static

enums.SENSOR_FUSION_RATE

Sensor Fusion Rate - Default: 10Hz (10)

 _10: 10 Hz
 _15: 15 Hz
 _20: 20 Hz
 _25: 25 Hz

Example

// Set environmental sensor fusion rate to 25 Hz
iotsensor.configuration.BASIC.SENSOR_FUSION_RATE = iotsensor.enums.SENSOR_FUSION_RATE._25;
public static

enums.SENSOR_FUSION_RAW_DATA_ENABLE

Sensor Fusion Raw Data Enable - Default: Enabled (1)

NOTE: Disabling Sensor Fusion Raw Data disables to possibility to read Accelerometer, Gyroscope and Magnetometer
 _disabled: Disabled
 _enabled:  Enabled

Example

// Disable Sensor Fusion raw data
iotsensor.configuration.BASIC.SENSOR_FUSION_RAW_DATA_ENABLE = iotsensor.enums.SENSOR_FUSION_RAW_DATA_ENABLE._disabled;

Methods

public

getFastAccelerometerCalibration(callbackFun)

Read fast accelerometer status. 0: Stopped, 1: Started

Example

// Fast accelerometer cal status. 0: Stopped, 1: Started
iotsensor.getFastAccelerometerCalibration(
	function(data)
	{
		console.log('Fast accelerometer calibration status: ' + data);
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with running status: callbackFun(data).

public

getRunningStatus(callbackFun)

Get running status. 0: Stopped, 1: Running

Example

// Running status. 0: Stopped, 1: Running
iotsensor.getRunningStatus(
	function(data)
	{
		console.log('Running status: ' + data);
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with running status: callbackFun(data).

public

readBasicConfiguration(callbackFun)

Return the basic configuration. Returns a readable object to callbackFun

Calling this function will also store the data in configuration.BASIC
Make sure to call this function upon initialization in order to get the most recent settings

Example

iotsensor.readBasicConfiguration(
	function(data)
	{
		console.log('Basic configuration:'
 				+ ' ' + data.SENSOR_COMBINATION
 				+ ' ' + data.ACCELEROMETER_RANGE
 				+ ' ' + data.ACCELEROMETER_RATE
 				+ ' ' + data.GYROSCOPE_RANGE
 				+ ' ' + data.GYROSCOPE_RATE
 				+ ' ' + data.MAGNETOMETER_RATE
 				+ ' ' + data.ENVIRONMENTAL_SENSORS_RATE
 				+ ' ' + data.SENSOR_FUSION_RATE
 				+ ' ' + data.SENSOR_FUSION_RAW_DATA_ENABLE
 				+ ' ' + data.CALIBRATION_MODE
 				+ ' ' + data.AUTO_CALIBRATION_MODE);
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with running status: callbackFun(data).

public

readCalibrationCoefficients(callbackFun)

Read calibration coefficients. Returns a readable object to callbackFun.

Calling this function will also store the data in configuration.CAL_COEF
Make sure to call this function upon initialization in order to get the most recent settings

Example

iotsensor.readCalibrationCoefficients(
	function(data)
	{
		console.log('Calibration coefficients:'
 				+ ' ' + data.SENSOR_TYPE
 				+ ' ' + data.Q_FORMAT
 				+ ' ' + data.OFFSET_VECTOR
 				+ ' ' + data.MATRIX);
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with running status: callbackFun(data). A data array is passed as a parameter.

public

readCalibrationControl(callbackFun)

Read calibration control flags. Returns a readable object to callbackFun.

Calling this function will also store the data in configuration.CAL_COEF
Make sure to call this function upon initialization in order to get the most recent settings

Example

iotsensor.readCalibrationControl(
	function(data)
	{
		console.log('Calibration control values:'
 				+ ' ' + data.SENSOR_TYPE
 				+ ' ' + data.CONTROL_FLAGS[0]
 				+ ' ' + data.CONTROL_FLAGS[1]
 				+ ' ' + data.PARAMETERS);
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with running status: callbackFun(data). A data array is passed as a parameter.

public

readParametersFromFlash()

Read parameters from flash memory

Example

iotsensor.readParametersFromFlash();
public

readSflCoefficients(callbackFun)

Return the sensor fusion coefficients. Returns a readable object to callbackFun.

Calling this function will also store the data in configuration.SFL_COEF
Make sure to call this function upon initialization in order to get the most recent settings

Example

iotsensor.readSflCoefficients(
	function(data)
	{
		console.log('Sfl coefficients:'
 				+ ' ' + data.BETA_A
 				+ ' ' + data.BETA_M
 				+ ' ' + data.TEMPERATURE_REPORT);
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with running status: callbackFun(data). A data array is passed as a parameter.

public

resetSflAndCalibrationConfiguration()

Reset sensor fusion and calibration configuration to default.

Example

iotsensor.resetSflAndCalibrationConfiguration();
public

resetToFactoryDefaults()

Reset to factory defaults. All settings from iotsensor.configuration.BASIC are restored.

Example

iotsensor.resetToFactoryDefaults();
public

sensorStatusCallback(callbackFun)

Set the sensor status callback.
This function is called everytime the sensor receives a START or STOP command and sends a reply back to the device.

Example

iotsensor.sensorStatusCallback(
	function(data)
	{
		console.log('Sensor status: ' + data);
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with START/STOP reply (1: START, 0: STOP): callbackFun(data).

public

setBasicConfiguration()

Set the basic configuration in device.

Settings are not stored in flash. Call storeBasicConfiguration() to do so.

Example

iotsensor.setBasicConfiguration();
public

setCalibrationCoefficients()

Set calibration coefficients in device.

Settings are not stored in flash. Call storeCalibrationAndControl() to do so.

Example

iotsensor.setCalibrationCoefficients();
public

setCalibrationControl()

Set calibration control flags in device.

Settings are not stored in flash. Call storeCalibrationAndControl() to do so.

Example

iotsensor.setCalibrationCoefficients();
public

setSflCoefficients()

Set the sensor fusion configuration in device.

Settings are not stored in flash. Call storeCalibrationAndControl() to do so.

Example

iotsensor.setSflCoefficients();
public

storeBasicConfigurationInFlash()

Store basic configuration in flash memory.

Call setBasicConfiguration() before calling this function.

Example

iotsensor.storeBasicConfigurationInFlash();
public

storeCalibrationAndControl()

Store calibration coefficients and control configuration in flash memory.

Call setCalibrationCoefficients() and setControlFlags() before calling this function.

Example

iotsensor.storeCalibrationAndControl();