Methods

public

accelerometerCallback(callbackFun)

RAW and SFL
Set the accelerometer notification callback. This function is called everytime new data is available.
Data is returned in g (x, y, z)

Example

iotsensor.accelerometerCallback(
	function(data)
	{
		console.log('Accelerometer data: ' 
					+ data.x + 'g '
					+ data.y + 'g '
					+ data.z + 'g');
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with accelerometer data: callbackFun(data).

public

accelerometerOff()

RAW and SFL
Turn off accelerometer notification.

Example

iotsensor.accelerometerOff();
public

accelerometerOn()

RAW and SFL
Turn on accelerometer notification.

Make sure the callback function is set before turning on the sensor

Example

iotsensor.accelerometerOn();
public

barometerCallback(callbackFun)

RAW and SFL
Set the barometer notification callback. This function is called everytime new data is available.
Data is returned in Pascal (whole number)

Example

iotsensor.barometerCallback(
	function(data)
	{
		console.log('Barometer data: ' + data + 'Pa');
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with barometer data: callbackFun(data).

public

barometerOff()

RAW and SFL
Turn off barometer notification.

Example

iotsensor.barometerOff();
public

barometerOn()

RAW and SFL
Turn on barometer notification.

Make sure the callback function is set before turning on the sensor

Example

iotsensor.barometerOn();
public

disableAllSensors()

RAW and SFL
Turn off all sensors.

Example

iotsensor.disableAllSensors();
public

errorCallback(errorFun)

Set the error handler function.
If no errorCallback is set, the default handler will be called:

console.log(evothings.iotsensor.currentTime() + ' IoT Sensor error: ' + error);

Parameter

Name Type Optional Description

errorFun

function()

 

Callback called with error: errorFun(error)

public

getDeviceModel() → string

Return the device model

Example

var model = iotsensor.getDeviceModel();
console.log('Device model ' + model);
Returns

string 

public

getFirmwareString() → string

Return the firmware version on the device

Example

var version = iotsensor.getFirmwareString();
console.log('Firmware version: ' + version);
Returns

string 

public

gyroscopeCallback(callbackFun)

RAW and SFL
Set the gyroscope notification callback. This function is called everytime new data is available.
Data is returned in degrees per second (x, y, z)

Example

iotsensor.gyroscopeCallback(
	function(data)
	{
		console.log('Gyroscope data: ' 
					+ data.x + 'degrees per second '
					+ data.y + 'degrees per second '
					+ data.z + 'degrees per second');
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with gyroscope data: callbackFun(data).

public

gyroscopeOff()

RAW and SFL
Turn off gyroscope notification.

Example

iotsensor.gyroscopeOff();
public

gyroscopeOn()

RAW and SFL
Turn on gyroscope notification.

Make sure the callback function is set before turning on the sensor

Example

iotsensor.gyroscopeOn();
public

humidityCallback(callbackFun)

RAW and SFL
Set the humidity notification callback. This function is called everytime new data is available.
Data is returned in % (whole number)

Example

iotsensor.humidityCallback(
	function(data)
	{
		console.log('Humidity data: ' + data + '%');
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with humidity data: callbackFun(data).

public

humidityOff()

RAW and SFL
Turn off humidity notification.

Example

iotsensor.humidityOff();
public

humidityOn()

RAW and SFL
Turn on humimdity notification.

Make sure the callback function is set before turning on the sensor

Example

iotsensor.humidityOn();
public

isAccelerometerAvailable() → boolean

Checks if the accelerometer is available.

Example

// Check if accelerometer is available
if(iotsensor.isAccelerometerAvailable())
{
	iotsensor.accelerometerOn();
}
Returns

boolean 

public

isBarometerAvailable() → boolean

Checks if the barometer is available.

Example

// Check if barometer is available
if(iotsensor.isBarometerAvailable())
{
	iotsensor.barometerOn();
}
Returns

boolean 

public

isGyroscopeAvailable() → boolean

Checks if the gyroscope is available.

Example

// Check if gyroscope is available
if(iotsensor.isGyroscopeAvailable())
{
	iotsensor.gyroscopeOn();
}
Returns

boolean 

public

isHumidityAvailable() → boolean

Checks if the humidity sensor is available.

Example

// Check if humidity sensor is available
if(iotsensor.isHumidityAvailable())
{
	iotsensor.humidityOn();
}
Returns

boolean 

public

isMagnetometerAvailable() → boolean

Checks if the magnetometer is available.

Example

// Check if magnetometer is available
if(iotsensor.isMagnetometerAvailable())
{
	iotsensor.magnetometerOn();
}
Returns

boolean 

public

isSflAvailable() → boolean

Checks if Sensor Fusion is available.

Example

// Check if sensor fusion is available
if(iotsensor.isSflAvailable())
{
	iotsensor.sflOn();
}
Returns

boolean 

public

isTemperatureAvailable() → boolean

Checks if the temperature sensor is available.

Example

// Check if temperature sensor is available
if(iotsensor.isTemperatureAvailable())
{
	iotsensor.temperatureOn();
}
Returns

boolean 

public

magnetometerCallback(callbackFun)

RAW and SFL
Set the magnetometer notification callback. This function is called everytime new data is available.
Data is returned in micro Tesla (x, y, z)

Example

iotsensor.magnetometerCallback(
	function(data)
	{
		console.log('Magnetometer data: ' 
					+ data.x + 'µT '
					+ data.y + 'µT '
					+ data.z + 'µT');
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with magnetometer data: callbackFun(data).

public

magnetometerOff()

RAW and SFL
Turn off magnetometer notification.

Example

iotsensor.magnetometerOff();
public

magnetometerOn()

RAW and SFL
Turn on magnetometer notification.

Make sure the callback function is set before turning on the sensor

Example

iotsensor.magnetometerOn();
public

sflCallback(callbackFun)

SFL only
Set the sensor fusion notification callback. This function is called everytime new data is available.
Data is returned in 4 axis (w, x, y, z)

Example

iotsensor.sflCallback(
	function(data)
	{
		console.log('Sensor fusion data: ' 
					+ data.w + ' '
					+ data.x + ' '
					+ data.y + ' '
					+ data.z);
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with sensor fusion data: callbackFun(data).

public

sflOff()

SFL only
Turn off sensor fusion notification.

Example

iotsensor.sflOff();
public

sflOn()

SFL only
Turn on sensor fusion notification.

Make sure the callback function is set before turning on sensor fusion

Example

iotsensor.sflOn();
public

statusCallback(statusFun)

Set the status handler function.
If no statusCallback is set, the default handler will be called:

console.log(evothings.iotsensor.currentTime() + ' IoT Sensor status: ' + status);

Parameter

Name Type Optional Description

statusFun

function()

 

Callback called with status: statusFun(status);

public

temperatureCallback(callbackFun)

RAW and SFL
Set the temperature notification callback. This function is called everytime new data is available.
Data is returned in degrees Celcius (2 decimals)

Example

iotsensor.temperatureCallback(
	function(data)
	{
		console.log('Temperature data: ' + data + '°C');
	}
);

Parameter

Name Type Optional Description

callbackFun

function()

 

Callback called with temperature data: callbackFun(data).

public

temperatureOff()

RAW and SFL
Turn off temperature notification.

Example

iotsensor.temperatureOff();
public

temperatureOn()

RAW and SFL
Turn on temperature notification.

Make sure the callback function is set before turning on the sensor

Example

iotsensor.temperatureOn();