Namespace: instance

.iotsensor. instance

Abstract IoTSensor instance object that defines a common interface.

Methods


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)
Parameters:
Name Type Description
callbackFun function Callback called with accelerometer data: callbackFun(data).
Example
iotsensor.accelerometerCallback(
	function(data)
	{
		console.log('Accelerometer data: ' 
					+ data.x + 'g '
					+ data.y + 'g '
					+ data.z + 'g');
	}
);

accelerometerOff()

RAW and SFL
Turn off accelerometer notification.
Example
iotsensor.accelerometerOff();

accelerometerOn()

RAW and SFL
Turn on accelerometer notification.
Make sure the callback function is set before turning on the sensor
Example
iotsensor.accelerometerOn();

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)
Parameters:
Name Type Description
callbackFun function Callback called with barometer data: callbackFun(data).
Example
iotsensor.barometerCallback(
	function(data)
	{
		console.log('Barometer data: ' + data + 'Pa');
	}
);

barometerOff()

RAW and SFL
Turn off barometer notification.
Example
iotsensor.barometerOff();

barometerOn()

RAW and SFL
Turn on barometer notification.
Make sure the callback function is set before turning on the sensor
Example
iotsensor.barometerOn();

disableAllSensors()

RAW and SFL
Turn off all sensors.
Example
iotsensor.disableAllSensors();

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);
Parameters:
Name Type Description
errorFun function Callback called with error: errorFun(error)

getDeviceModel()

Return the device model
Returns:
Type
string
Example
var model = iotsensor.getDeviceModel();
console.log('Device model ' + model);

getFirmwareString()

Return the firmware version on the device
Returns:
Type
string
Example
var version = iotsensor.getFirmwareString();
console.log('Firmware version: ' + version);

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)
Parameters:
Name Type Description
callbackFun function Callback called with gyroscope data: callbackFun(data).
Example
iotsensor.gyroscopeCallback(
	function(data)
	{
		console.log('Gyroscope data: ' 
					+ data.x + 'degrees per second '
					+ data.y + 'degrees per second '
					+ data.z + 'degrees per second');
	}
);

gyroscopeOff()

RAW and SFL
Turn off gyroscope notification.
Example
iotsensor.gyroscopeOff();

gyroscopeOn()

RAW and SFL
Turn on gyroscope notification.
Make sure the callback function is set before turning on the sensor
Example
iotsensor.gyroscopeOn();

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)
Parameters:
Name Type Description
callbackFun function Callback called with humidity data: callbackFun(data).
Example
iotsensor.humidityCallback(
	function(data)
	{
		console.log('Humidity data: ' + data + '%');
	}
);

humidityOff()

RAW and SFL
Turn off humidity notification.
Example
iotsensor.humidityOff();

humidityOn()

RAW and SFL
Turn on humimdity notification.
Make sure the callback function is set before turning on the sensor
Example
iotsensor.humidityOn();

isAccelerometerAvailable()

Checks if the accelerometer is available.
Returns:
Type
boolean
Example
// Check if accelerometer is available
if(iotsensor.isAccelerometerAvailable())
{
	iotsensor.accelerometerOn();
}

isBarometerAvailable()

Checks if the barometer is available.
Returns:
Type
boolean
Example
// Check if barometer is available
if(iotsensor.isBarometerAvailable())
{
	iotsensor.barometerOn();
}

isGyroscopeAvailable()

Checks if the gyroscope is available.
Returns:
Type
boolean
Example
// Check if gyroscope is available
if(iotsensor.isGyroscopeAvailable())
{
	iotsensor.gyroscopeOn();
}

isHumidityAvailable()

Checks if the humidity sensor is available.
Returns:
Type
boolean
Example
// Check if humidity sensor is available
if(iotsensor.isHumidityAvailable())
{
	iotsensor.humidityOn();
}

isMagnetometerAvailable()

Checks if the magnetometer is available.
Returns:
Type
boolean
Example
// Check if magnetometer is available
if(iotsensor.isMagnetometerAvailable())
{
	iotsensor.magnetometerOn();
}

isSflAvailable()

Checks if Sensor Fusion is available.
Returns:
Type
boolean
Example
// Check if sensor fusion is available
if(iotsensor.isSflAvailable())
{
	iotsensor.sflOn();
}

isTemperatureAvailable()

Checks if the temperature sensor is available.
Returns:
Type
boolean
Example
// Check if temperature sensor is available
if(iotsensor.isTemperatureAvailable())
{
	iotsensor.temperatureOn();
}

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)
Parameters:
Name Type Description
callbackFun function Callback called with magnetometer data: callbackFun(data).
Example
iotsensor.magnetometerCallback(
	function(data)
	{
		console.log('Magnetometer data: ' 
					+ data.x + 'µT '
					+ data.y + 'µT '
					+ data.z + 'µT');
	}
);

magnetometerOff()

RAW and SFL
Turn off magnetometer notification.
Example
iotsensor.magnetometerOff();

magnetometerOn()

RAW and SFL
Turn on magnetometer notification.
Make sure the callback function is set before turning on the sensor
Example
iotsensor.magnetometerOn();

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)
Parameters:
Name Type Description
callbackFun function Callback called with sensor fusion data: callbackFun(data).
Example
iotsensor.sflCallback(
	function(data)
	{
		console.log('Sensor fusion data: ' 
					+ data.w + ' '
					+ data.x + ' '
					+ data.y + ' '
					+ data.z);
	}
);

sflOff()

SFL only
Turn off sensor fusion notification.
Example
iotsensor.sflOff();

sflOn()

SFL only
Turn on sensor fusion notification.
Make sure the callback function is set before turning on sensor fusion
Example
iotsensor.sflOn();

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);
Parameters:
Name Type Description
statusFun function Callback called with status: statusFun(status);

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)
Parameters:
Name Type Description
callbackFun function Callback called with temperature data: callbackFun(data).
Example
iotsensor.temperatureCallback(
	function(data)
	{
		console.log('Temperature data: ' + data + '°C');
	}
);

temperatureOff()

RAW and SFL
Turn off temperature notification.
Example
iotsensor.temperatureOff();

temperatureOn()

RAW and SFL
Turn on temperature notification.
Make sure the callback function is set before turning on the sensor
Example
iotsensor.temperatureOn();