This question has been asked in a few ways but there has been no conclusive answer to it.
I am trying to find out the maximum range of the accelerometer on Android phones. Some forums claim +-2Gs and some +-3.5Gs.
The accelerometer hardware (of the LSM330 which is on the s4) has a higher range, up to 16Gs. http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/DM00059856.pdf
I wrote an application to practically find this range and loaded it onto an S4. The following picture shows the readings. Clearly, the maximum range in each direction is 2Gs.
- Is there a way to increase this range and if so, how?
- Has anyone found a larger default range on other Android phones?
For those interested, here is the nb part of my code:
public class MainActivity extends Activity implements SensorEventListener{
Sensor accelerometer;
SensorManager sm;
TextView maxValue;
TextView realTimeValues;
TextView realTimeResultant;
TextView maxValues;
TextView maxResultant;
float x = 0;
float y = 0;
float z = 0;
float res = 0;
float xMax = 0;
float yMax = 0;
float zMax = 0;
float resMax = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sm = (SensorManager)getSystemService(SENSOR_SERVICE);
accelerometer = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
sm.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_FASTEST);
maxValue = (TextView)findViewById(R.id.MaxValue);
realTimeValues = (TextView)findViewById(R.id.RealTimeValues);
realTimeResultant = (TextView)findViewById(R.id.RealTimeResultant);
maxValues = (TextView)findViewById(R.id.maxValues);
maxResultant = (TextView)findViewById(R.id.maxResultant);
float max = accelerometer.getMaximumRange();
maxValue.setText("Max range: "+ max);
}
@Override
public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER)
return;
x = event.values[0];
y = event.values[1];
z = event.values[2];
res = (float) Math.sqrt( x*x + y*y + z*z);
realTimeValues.setText("X: " + x + "\nY: " + y + "\nZ: " + z);
realTimeResultant.setText(res + " m/s^2");
if (Math.abs(x) > Math.abs(xMax))
xMax = x;
if (Math.abs(y) > Math.abs(yMax))
yMax = y;
if (Math.abs(z) > Math.abs(zMax))
zMax = z;
if (res > resMax)
resMax = res;
maxValues.setText("X: " + xMax + "\nY: " + yMax + "\nZ: " + zMax);
maxResultant.setText(resMax + " m/s^2");
}
}