What I learnt from racing hamsters

Mark Argent
3 min readJun 27, 2021

Did you know that whilst you are sleeping your hamster is running an average of 9km on their wheel ? To put that into perspective your furry friend is running a marathon (26.2 miles) every week.

Do you have a rodent friend at home ? One as a pet in a cage with a wheel, rather than one that might be lurking in your shed. My children have enjoyed caring for hamsters, but when most of the hamster’s fun seems to be occurring at night, we wanted to see if we could track their activity.

So as a STEM project we set about constructing a way to measure the distance and speed of our hamster on their wheel, track their activity every night, and plot it on a map.

The result is our ‘Rodent Racing’ Raspberry Pi project, found here.

Measure Hamster Wheel Activity — Raspberry Pi

Using the project we learnt that our brave test pilot, Milly, ran at about 4 mph/6.4 km per hour on her wheel, and that in our 6 weeks of measuring her nightly activity she’d run from London, UK to Paris, France (via the Eurotunnel). Here’s Milly in action: https://youtu.be/sC6tmCSjciU

But what did we learn about the technology ?

  1. gaiandb works incredibly well on a Raspberry Pi. The light-weight database, based on Apache Derby, has a small footprint (< 4MB). It is designed for use on IoT devices and was easy to deploy on the entry-level specification of a Pi. The technology removed the need to have a centrally hosted, always on server to collect the individual’s information and host the leaderboard. Instead the features in the distributed database configuration allows participants to form groups to share their data with those they trust — so as an example a school can create a group of its participating students to only share the data between them.
  2. rabbitmq provided a light-weight message bus for the Pi external interfaces to publish their events to, and for the microservices to consume and act upon (eg. writing the data to gaiandb, triggering the camera to take an action shot, updating the leaderboard). Event driven architecture on a Pi !.
  3. Hosting the personal information of the trainer (pet owner) in the MySQL database, and the competitors’ (hamsters’) race information for sharing (distance, avg. speed, competitorID) in the gaiandb provided an easy to implement clear separation of the data to be distributed and that to remain locally on the Pi. This introduced the concepts of GDPR to an interested (at times) set of children.
  4. php, html and python are all simple entry level languages for my 9 and 11 year old daughters to understand and become adept at writing their first code. There are lots of examples on Google for them to follow, before progressing to tackling some of the more complex elements.

Unfortunately Milly’s racing days are long past but the baton is still there in github to be picked up — hopefully a mentee at my local CoderDojo will consider it once we can meet-up once again.

https://youtu.be/LD7SEiRALsI

--

--

Mark Argent

IBM Distinguished Engineer. Experienced hands-on Chief Architect with over 20 years experience in the design of large complex systems and leading agile delivery