How I Open Sourced My Hamsters for Science

Github | GPL-3.0 license

Last year, I brought two new Roborovski hamster pups into our home. They looked identical at the time, so I named them both Hamtaro. (Fast forward the 1.5 years I’ve owned them, and one has grown significantly tubbier than the other… So I’ve nicknamed her Hamtaro Grande.)

1_cute
Hamtaro y Hamtaro Grande

After having the Hamtaros home for about a week, one thing became extremely clear: they run all the time. At least, that’s how it feels when I’m trying to sleep through their squeaky wheel.


That’s Hamtaro on the wheel, and Grande on the ground

So back in January, curiosity led me to start researching my hamsters on The Internet. Confirming my suspicion, I read that Roborovski hamsters in particular are one of the most active hamster breeds in the world, and run “an equivalent of four human marathons each night on average”.

So this got me wondering: Could it be possible that my Roborovski hamsters are really running the hamster equivalent of four marathons a night?

…And if they are, what does that mean? I mean, what even is the “hamster equivalent” of a marathon?

Fast forward a few months, and I ran into my friend Kevin at CRASH Space. He showed me a project he was working on in an effort to encourage his lazy cat Toonces to exercise more. Kevin had modded his cat’s wheel with a little fin and a distance sensor to create a pedometer, and was uploading his cat’s daily progress to Strava.

(Needless to say, Kevin’s ungrateful cat has yet to thank him for his efforts.)

Feeling inspired by my friend’s dedication to his cat’s personal health and fitness, I thought back on the claims The Internet had made about my hamsters, and decided to put them to the test with some citizen science.

Here’s how it works:

Mod the Hamster Wheel to Allow for Safe Tracking

Luckily, I had already done the work to mod my wheel back in January. Back then, I had two goals in mind:

  1. Silencing the incessant squeaking of constant running that was keeping me up at night. (The ballbearings that are designed to play a video tape smoothly allow for relatively frictionless —and therefor nearly silent— rotation. )
  2. Provide a surface external to the cage to attach other apparatuses safely outside of hamster reach. (The VCR head has an axel that can reach through the cage bars, allowing me to mount the head itself to the outside of the cage.)

0_wheel 0_wheel1 0_wheel2

Notice that the VCR head spins on the outside when they run on the inside

You can see detailed instructions on how to mod your own hamster wheel here.

Build a Device to Record Hamster Data

The hamstrometer itself is essentially just an ethernet-connected pedometer. (If you’re following along with hopes of building your own, know that there are a million versions of these online, just in case the method I’m using doesn’t work for your needs.)


Notice the magnet stuck to the wheel, spinning past the sensor on the circuit

I’m a huge fan of open source, so I made a personal choice to opt for open source solutions in my design whenever possible.

RPi-Hall-Switch
You can download the Fritzing model for this circuit on github

Here’s my parts list:

  • Raspberry Pi
  • Raspberry Pi Periphreals (In an effort to cut down on waste, I got all of mine second-hand out of the CRASH Space junk bins): monitor, mouse, ethernet cord, hdmi cable, power cord (taken from an old modem), usb cord
  • Sticky-backed Breadboard
  • Hall Effect Sensor
  • Rare Earth Magnet
  • LED (optional: for notification and debugging)
  • Jumper Wires

The primary functionality in the circuit is happening between the rare-earth magnet and the hall effect sensor. Hall effect sensors sense the presence of a magnetic field, and are therefore capable of counting rotations once we have mounted the rare-earth magnet to the rotating portion of the VCR head on our hamster wheel.


The LED lights up whenever the magnet is near the sensor

1_cageIMG_20150708_081807
The Hamstrometer, dominating my entire dinner table

The logging of our rotation data and any additional calculation is handled by the Raspberry Pi. After observing my hamsters’ behaviour, I determined that they generally tend to wander on and off of the wheel several times within a very short timespan. Because of this, I decided to record their data in “sprints”. Whenever the sensor senses the presence of the magnet, it considers this to be the start of a new sprint. Each consecutive time it senses the magnet after that initial pass, it logs the current timestamp. It will continue to record as long as it senses the magnet. If 5 seconds go by without any activity, it terminates the sprint and logs the sprint data to a SQLite database.

Measure and Calculate Distances

The claim made by The Internet is that my hamsters run, on average, the equivalent of four marathons a night. So the in order to determine if this is true, we first have to ask ourselves: What is the “hamster equivalent” of four human marathons?

To determine this, I decided it would be fair to assume that if it takes a human X human-sized strides to run a human-sized marathon, then it must therefor take a hamster X hamster-sized strides to run a “hamster marathon”.

So in order to solve this problem, I had to answer a few other questions first:

  1. Q: How far does a hamster run in one wheel rotation?
  2. Knowing all of this, there was one last measurement to take. The hamstrometer is recording rotations of the wheel, so we need to ensure that we are converting properly between wheel rotations and feet.

    1_wheel_measure

    I measured the diameter of my hamster wheel, and it is 0.5 ft.
    0.5 ft X PI = ~1.5 ft
    A: The distance a hamster runs in one wheel rotation is 1.5 ft

  3. Q: How long is the average human stride?
  4. Luckily, this data is readily available all over the internet. I chose to go with the value of 2.2 ft, as that was quoted as being the average female human’s stride length, and my hamsters are ladies.

    A: The average female human stride length is 2.2 ft

  5. How long is the average Roborovski hamster stride?
  6. This one was a bit harder to figure out. It appears that the internet has significantly less data on the average stride of a female Roborovski hamster just lying around for the taking.

    I started crafting ideas for tests, and threw a few of them out on twitter to see if any would stick.


    The community was full of suggestions! We all chatted back and forth about the pros and cons of the various ideas, how much work they would require, how accurate they might be, and how irritated my hamsters might be by the whole ordeal.

    Then one of us came up with the perfect idea:

    Brilliant!

    This would enable us not only to see the steps the hamsters took very clearly, but is also unobtrusive to the hamsters’ normal lifestyle.

    1_measurements1_measuring
    Luckily, the bottom of my hamster cage is translucent plastic, so an extra pane of glass wasn’t necessary. With a ruler, a pen, and some tape, I graphed and labeled the
    WORLD’S
    MOST
    SOPHISTICATED
    HAMSTER STRIDE MEASUREMENT SYSTEM!

    1_measure2
    BEHOLD

    And voila! After filming them and playing the footage back in slow-mo, I was able to get several measurements of hamster strides, and take the average.

    1_best_measure

    A: The average stride length of my Roborovski hamsters is 0.166 ft.

  7. Q: How many human strides are in one mile?
  8. Q1

    A: There are 2,400 human strides in one mile.

  9. Q: How far does a hamster travel in 2,400 strides?
  10. Q2

    A: A hamster travels 400ft in one mile.

  11. Q: How long is four hamster marathons?
  12. Q3

    A: Four hamster marathons is 41,950ft long.

Upload and Tracking the Data

Screen Shot 2015-08-31 at 10.05.48 PM
I’ve been using ThingSpeak to host my data. ThingSpeak is an affordable and open source platform for hosting your IoT data. There is an api you can plug directly in to your project to upload your data, generate CSV files, and graph your data in near realtime.

The code I wrote for this project is in Python, with the exception of the database and tables, which are supported by SQLite. You can find the code I wrote for this project here on Github, available under the GPL-3.0 license.

Analyzing the Data

I tracked my hamster’s activity for one month straight, and (spoiler alert):

not one time did they make the cut.

Screen Shot 2015-09-02 at 12.46.10 PM
…wow.

Perhaps this is because my hamsters are getting old? Perhaps domesticated Roborovskis don’t perform as well as they do in the wild? Or maybe mine are just …really lazy?
OR MAYBE THE INTERNET WAS LYING ALL ALONG?!?!?!?!!?

arthur
Who knows. Whatever the reason is, it looks like it’s time to schedule some meetings about how to increase hamster engagement on the wheel platform.

1_hamster_engagement
So… What’s the low-hanging fruit here?

But really, I probably shouldn’t be so disappointed that they didn’t make the 4 marathons / day marker. I mean, these are still pretty impressive numbers for a creature that maxes out at about two inches long:


Screen Shot 2015-09-02 at 12.46.33 PM Screen Shot 2015-09-02 at 12.46.23 PM
Definitely farther than I run each day, that’s for sure.