# Estimate smartphone accelerometer bias

I was planning to develop Android / iOS applications that enable users to measure 3D length using their smartphones.

According to this question, you need to know at least the time-varying bias that affects the accelerometer's signal. Hence, I need to estimate the bias every time a user is going to measure. How can I do that? I've seen articles about this estimation but to be honest I'm not expert in signal processing so I didn't understand them. Can you explain a method to estimate?

• This is a bit broad, but I think you can narrow things down by going through bzarg.com/p/how-a-kalman-filter-works-in-pictures . Bias estimation either happens within your model, or you add a preprocessing step that uses additional axes to estimate the direction of gravity and remove it from your instantaneous estimate. My guess is that if you're doing bias estimation, you'll inherently "blow up" your reduced 1D problem back to 3D, and could basically work 3D from the start (still do the 1D implementation first! Just without estimating a changing bias – assume the phone is held … – Marcus Müller Jun 13 '18 at 9:33
• … steadily and calibrate once before the measurement starts. As soon as 1D works, extend to 3D, and then add dynamic offset compensation.) – Marcus Müller Jun 13 '18 at 9:34
• You may want to watch Sensor Fusion on Android Devices (2010). – Rodrigo de Azevedo Jun 14 '18 at 13:37

## 1 Answer

You can model errors this way: $$a = f*a' + g + b + \eta$$ where $a$ is the actual acceleration, $f$ is a 3x3 matrix to model scaling, misalignments, cross-axis and ... errors. $a'$ is sensor's data, $g$ is gravity, $b$ is 3x1 matrix to model bias, and $\eta$ is 3x1 matrix to model noise.

You can calibrate accelerometer by reading $a'$ from sensor data when the accelerometer is in static positions. In static positions, the only force effecting accelerometer is gravity. So by minimizing this summation, $f$ and $b$ can be computed(calibration): $$(|a_0|^2 - |g|^2)^2 + (|a_1|^2 - |g|^2)^2 + ... + (|a_N|^2 - |g|^2)^2$$ where $N$ is number of static positions.