The math is easy! You just need to figure out what the circumference of your hamster wheel is. One way to do this would be to measure the diameter (or radius & multiply by 2!) of the wheel, and multiply by pi. Another way would be to take a string and put it around the wheel as accurately as you can, then lay it out and measure it. Maybe there are other ways you can think of to get the circumference of the wheel?

After you have that distance, then speed is simply distance / time. In this case, youâ€™ll measure how many revolutions (using the magnetometer) you get in some sampling period (say, 1 minute), then multiply that number by the distance of each revolution:

speed = ( circumference * revs ) / 1 min.

You can then use unit conversions to get into a more conventional unit, like MPH or km/h.