Speed Calculation using accelerometer sensor.

Thread Starter


Joined Nov 11, 2020
I am trying to measure the speed of a moving vehicle using accelerometer sensor. here i am using trepizoidal method to integrate the discrete data from accelerometer sensor. it works bit better(with small error) for small distances. But, when i continue for long distances (with up&down slopes) it making more error. Can any body help me?????

Please help me????????


Joined Aug 27, 2009
The large errors likely from the integration of drift and noise. A band-pass filer might help (one high-pass and other low-pass) and redundant sensors.

18:40 23:40


Joined Jan 30, 2016
Yes, as AndrewMM says, you need a Kalman filter that integrates the accelerometer data with the gyro data to remove longer-term drift. There's many YouTube videos on this for improving dead-reckoning navigation on drones, autonomous vehicles and the like. Pretty standard practice these days.

Deleted member 115935

Joined Dec 31, 1969


Joined Aug 27, 2009
The Madgwick's IMU and AHRS algorithms are very good.

Here's a little PIC32MK demo (in C) of a 9-axis IMU driving a SPI graphics display showing IMU data, a tracking glyph from the sensor fusion data while outputting serial data for a Linux java cube visualization.


10ms update frequency.

Top line: SPI data output to graphics display, 4.5ms, https://www.lcd-module.com/fileadmin/eng/pdf/grafik/dogxl240-7e.pdf
Bottom line: IMU SPI data readout for all sensors, 90us

Actual processing time for IMU and graphics transformations is less than 1ms.
Last edited: