Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create function for use more one sensors in time! #3

Open
fabiorogeriosj opened this issue May 19, 2016 · 4 comments
Open

Create function for use more one sensors in time! #3

fabiorogeriosj opened this issue May 19, 2016 · 4 comments
Milestone

Comments

@fabiorogeriosj
Copy link
Owner

No description provided.

@fabiorogeriosj fabiorogeriosj added this to the 2.0.0 milestone May 19, 2016
@tmaxeny
Copy link

tmaxeny commented Nov 18, 2016

Is it possible to use both light and accelerometer sensors and how ?

@fabiobenner
Copy link

@tmaxeny in native yes! See this link.
Needs to be implemented in the plugin

@saveryanov
Copy link

It is very convenient to be able to get the values of the sensors using just one plugin. Adding the opportunity of simultaneous reading of values from different sensors will be great feature.

@alnnasr
Copy link

alnnasr commented Jan 16, 2019

hi everyone i use this trick to get all the sensors alternately, this example get PRESSURE, TEMPERATURE and HUMIDITY but you can use it to get all of them.

setTimeout(getAllSensors,1000);

function getAllSensors(){
	switch(sensorsDataToggle){
		case "pressure":
			sensors.enableSensor("PRESSURE");
			sensors.getState(getSensorValue, sensorsError);
		break;
			
		case "temperature":
			sensors.enableSensor("AMBIENT_TEMPERATURE");
			sensors.getState(getSensorValue, sensorsError);
		break;
			
		case "humidity":
			sensors.enableSensor("RELATIVE_HUMIDITY");
			sensors.getState(getSensorValue, sensorsError);
	}
	setTimeout(getAllSensors,1000);
}	
	
var sensorsDataToggle = "pressure";
function getSensorValue(value){
	if(sensorsDataToggle == "pressure"){
		var preValue = value[0];
		console.log(preValue);
		sensors.disableSensor();
		sensorsDataToggle = "temperature";
		
	}else if(sensorsDataToggle == "temperature"){
		var temValue = value[0];
		console.log(preValue);
		sensors.disableSensor();
		sensorsDataToggle = "humidity";
		
	}else if(sensorsDataToggle == "humidity"){
		var humValue = value[0];
		console.log(humValue);
		sensors.disableSensor();
		sensorsDataToggle = "pressure";
	}
}

function sensorsError(error){
        if(sensorsDataToggle == "pressure"){
		console.log("Not Supported");
		sensorsDataToggle = "temperature";
	}else if(sensorsDataToggle == "temperature"){
		console.log("Not Supported");
		sensorsDataToggle = "humidity";
	}else if(sensorsDataToggle == "humidity"){
		console.log("Not Supported");
		sensorsDataToggle = "pressure";
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants