This is best done with a sensor that measures water flow across the hull of the boat, such as a paddlewheel or ultrasonic speed sensor, and a sensor that measures the direction the bow of the boat is pointing in such as a magnetic compass, GPS compass, or, if the budget extends to it, a gyro compass.