I am now trying to create an app to monitoring the vibration. I use accelerometer to finish the job, when the recorded acceleration exceed certain threshold, I call it a trigger. When there's a trigger, I want to log the acceleration, magnetic field, light level data (from different sensors) at the trigger time to a file.
The problem now is that: I can get data from individual sensor, but couldn't figure out a way how to get the data from multiple sensors at the same time. For example: I can set a sensorlistener to monitoring the change of accelerometer, when I record the acceleration data, can I also get data from other sensors at exactly the same time?
Thanks in advance.
Multiple Sensors for Tracking Advantages The advantage of using multiple sensors for tracking is that you can use each sensor to its best advantage. Also, by combining sensors you can create a solution to meet the needs of your specific application.
You can access sensors available on the device and acquire raw sensor data by using the Android sensor framework. The sensor framework provides several classes and interfaces that help you perform a wide variety of sensor-related tasks.
What is batching? Batching refers to buffering sensor events in a sensor hub and/or hardware FIFO before reporting the events through the Sensors HAL. The location where sensor events are buffered (sensor hub and/or hardware FIFO) are referred to as "FIFO" on this page.
Sensors can be hardware- or software-based. Hardware-based sensors are physical components built into a handset or tablet device. Hardware sensors derive their data by directly measuring specific environmental properties, such as acceleration, geomagnetic field strength, or angular change.
Yes you can do this as follows:
private SensorManager manager;
private SensorEventListener listener;
manager = (SensorManager) this.getSystemService(Context.SENSOR_SERVICE);
listener = new SensorEventListener() {
@Override
public void onAccuracyChanged(Sensor arg0, int arg1) {
}
@Override
public void onSensorChanged(SensorEvent event) {
Sensor sensor = event.sensor;
if (sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
...
}
else if (sensor.getType() == Sensor.TYPE_GYROSCOPE) {
...
}
}
}
manager.registerListener(listener, manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
manager.registerListener(listener, manager.getDefaultSensor(TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With