I am making an application that is used to measure the velocity, it has an accelerometer that measures the component acceleration in the XYZ-axis. When the car is moving just straight the measurement is ok, as only linear components are involved.
My doubt came when the car is on a curve, I am not sure if the accelerometer can measure correctly in such situation or if it is necessary to apply a gyroscope to measure any missing component.
The code snippet for measure the total acceleration is shown below, I measure the acceleration in each axis and I remove the gravitational to finally calculate the velocity and the speed
float AccTotal_X = ((AcX - grav_X)*9.81);
float AccTotal_Y = ((AcY - grav_Y)*9.81);
float AccTotal_Z = ((AcZ - grav_Z)*9.81);
float Vx = vx_0 + AccTotal_X*dt;
vx_0 = Vx;
float Vy = vy_0 + AccTotal_Y*dt;
vy_0 = Vy;
float Vz = vz_0 + AccTotal_Z*dt;
vz_0 = Vz;
speed_dt = sqrt(pow(Vx,2)+pow(Vy,2)+pow(Vz,2))*3.6;