Speed from Depth/Pressure sensors I have a pressure based Depth sensor. For reference, MS5837-02BA.
All depth measurements I've been able to read are very accurate (±1cm)
I tried experimenting to find out the speed of the body by differentiating the measured depth value.
The measurements are taken at a 40ms time period. This is the time the sensor takes for each measurement. I've used this as the rate of measurement and calculated the speed but the values are not as correct i feel.
Here are the plots for both measured and calculated variables.


All the measurements are in meters.
Would like to hear what exactly I'm doing wrong, whether its the rate of measurement or something else.
Edit: accuracy  ±0.1cm to ±1cm.
I verified the depth measurements using a measuring tape and it was accurate down to the cm. I couldn't measure whilst the body was moving so that may a factor
Edit 2:
Response to Hilmar's comment:
I've gone through what you've stated and my original depth data. So i only took my raw Depth measurements this time and discarded the speed calculations my microcontroller has done. I've calculated the derivative by finding the difference between the current and previous measurement and dividing it by the sample period. $(x[i]−x[i−1])/dt$
Here are the plots again but with the sample number changed to time


As you can see the plots are similar as earlier. And about your comment on the rise at t = 2000, the rise is not instantaneous but its actually gradual over the period of 1.32s . Have a look at this pic, note that the period in question is between t=2025 and t=2058, which means its a total period of 33*0.04=1.32s .

And the change in depth is noticeable but not at a very high rate. Note that the measurement is actually in the order of 0.1m or 1 decimeter. Hence the body had moved 0.4719m in a period of 1.32s which is just 0.35 m/s which my object is capable of. Other than this i'm uncertain where exactly i've made a blunder here. Others suggest that the high frequency noise may be a cause of this but would a simple LPF solve this problem?
All depth measurements I've been able to read are very accurate (±0.1cm)

That's highly unlikely. It seems that something is quantizing your data at pretty rough interval: maybe 2cm or so plus some extra noise. There are is also a spike at t = 2000 units ?) where the depth jumps from 0.1m to about 0.5m in one sample. Your sample interval is 40 milliseconds. 0.5m in 40ms corresponds to a speed of 12.5 m/s. Can your object really move that fast ?
Overall your data looks quite bad (noisy, quantized &amp; spikey) and not like a real physical object tends to behave.

find out the speed of the body by differentiating the measured depth value

The second curve doesn't look the derivative of the first curve at all. I would expect a massive velocity peak of 12.5 m/s at t = 2000, but your velocity curve just shows a minor blip. Another big peak should be at t= 4000. I have no idea what you did there, but it doesn't appear to be differentiation.

This is a simple calculation of the &quot;velocity&quot; from the depth measurements using Excel. It seems more reasonable than the plot in the question.
Note that the data used was from Web Page Digitizer, so it won't be quite the same as the original.


In the future please label the X and Y axis of your graph with proper units. I have no idea what the unit of your velocity are supposed to be but it's unlikely to be in m/s.