I did something similar about ten years ago for sculling using the a mobile phone gyro to detect the scull's surge with each stroke to get a stroke rate. The code was based on an algorithm described in a paper I found online, but coded from scratch. I was rather proud of that. GPS gave an approximate speed.