Skip to content
The Munificent Musings Of A Maniacal Mammal

I used to have hamsters as a kid. In 2020, I decided to jump back into having a hamster again. I watched tons of YouTube vids on best modern thinking on hamster care and did a cool modification of an IKEA glass display (the “Detolf”) as a nice enclosure and then got Harvey, my first of the new hamsters. Harvey was a fun and typical hamster that lived to nearly the 1.5 to 2 year average life expectancy. A few months after getting Harvey, I started messing around with ways of measuring the amount of running he did on his wheel. I found somebody who had done a project like that and attempted to mirror their approach with a Raspberry Pi based setup. In the end, I had lots of trouble getting it to be reliable. I forgot about the idea for a while, but once I got Maverick, who was the following resident in the enclosure after Harvey died, I figured I’d try something else for measuring his running. I found a different Raspberry Pi based setup somebody had done and tried setting that one up. Yet again, it had too many reliability problems. So yet again, I abandoned the idea for a little while. Unfortunately, Maverick died young about 5 months after I got him (he was probably a few months old when I got him).

Replacing Maverick was a female hamster that I named Furiosa. I have a list of potential names I’ve assembled to pick from, and given that she was a female hamster and had sand colored fur, I figured Furiosa was a good name. Little did I know how well that name would fit her, because she is an “action hamster”. She’s much more energetic than the previous two were (they were pretty average in that regard). Not only doesn’t she seem to sleep as much, being up and about more often (though still pretty much inactive during daylight hours), but what really impressed me was how much she ran. She would spend tiring hours on the wheel, going and going and going. Heck, when I first got her and placed her in the enclosure, one of the first things she checked out was the wheel. As I saw how much time she spent on the wheel, I decided to take another look around online to see if there was any others who had rigged up something for tracking wheel use.

I stumbled upon this project, which was a newer one that I hadn’t found on my previous hunts for such a thing. I read through it and thought it definitely had potential. I ordered what I needed for it and did some setup and testing. The project had some quirks and limitations I had to figure out, but it showed more potential for working than the previous ones did. Rather than using a Raspberry Pi, this one uses an ESP32 for controlling things. I found this ESP32 unit that included the pins attached and could easily be plugged into a mini breadboard. At first, I used longer jumper type wiring, but given where I mounted it and how easy it was to brush up against it, that cabling ended up being too flakey. I switched to using shorter, stiffer type jumpers, which ended up being far more reliable.

One tweak I had to make to the code from that project was that it reported in via Wi-Fi every minute. But apparently my Unifi wireless AP doesn’t like clients connecting and disconnecting every minute? I modified it to every 5 minutes, which worked great. Another thing I did was to add a condition in IFTTT so that it wouldn’t log to the Google Sheet if the value was 0. Here’s the code snipped for that condition:

let RotationValue = Number(MakerWebhooks.event.Value1);

if (RotationValue < 1) {
  GoogleSheets.appendToGoogleSpreadsheet.skip(`Value was 0, so not logging.`);

Another issue is that for whatever weird reason, IFTTT will only log up to 2,000 rows to a Google Sheet before it creates an entirely new Sheets file and starts logging to that, and so on. So, I found some Apps Script code that moves logged entries to another Sheets file. I have IFTTT logging to one file and then the Apps Script fires on a trigger when the log file has a change, then it copies anything in the first 100 rows to the archive file (it should never get anywhere near that many rows due to the trigger firing on each change) and then deletes those from the active log file. That way, the file that IFTTT is logging to never hits the 2,000 line mark. Here is the Apps Script code and a screenshot of the trigger settings, both of which should be on the source file that IFTTT is logging to. Note that you might want to manually run the function once so that the permission dialog pops up to authorize access.

function onChange(event) {

  var source = SpreadsheetApp.openById('YOUR_SOURCE_SHEET_ID');
  var archive = SpreadsheetApp.openById('YOUR_TARGET_SHEET_ID');
  var sourceSheet = source.getSheetByName('Sheet1');
  var destSheet = archive.getSheetByName('Sheet1');    
  var sourceData = sourceSheet.getRange('A1:B100').getValues();    
  sourceSheet.getRange('A1:B100').clear({contentsOnly: true}); 

The most difficult part of this project, by far, has been the sensor setup. I’m using a 3144 hall effect sensor that’s in place to pick up when a neodymium magnet that’s attached to the back of the wheel passes by. The sensitivity of it has been a huge problem to tweak for accuracy. It’s gonna be hard for me to describe the issues I had and how it’s setup and make sense doing so. The first issue is that the Silent Runner wheel stands off from the wood it’s mounted to by 3/4 of an inch the way I have it mounted. Sensitivity at that range to the sensor when it’s directly attached to the wood itself is just too unreliable, both due to range and the slight variations in angle of the wheel as it bounces slightly as it rotates from her running. At best, it was catching maybe half of the rotations. I tried a number of things. Never mind the fact that I had the wires taped to the wood with heavy vinyl tape and Furiosa somehow managed to get up to it and chew through the tape and wires completely.

One day, while trying to find a way to make it work better, I was looking around for something like a piece of plastic or wood to mount the sensor on that I could then mount to the wood to get it closer to the wheel and the magnet as it goes by. There’d still be the challenge of her somehow destroying it. Then, I saw something that made a light bulb turn on over my head. I have a small scale intended for measuring the hamsters’ weight (which I rarely ever use), which has a plastic cover that goes over it. I suddenly realized that I could tape the sensor INSIDE that cover and mount that to the wood, which would not only get the sensor close to the wheel, but would also put the sensor and wires behind the plastic so that she couldn’t get at it and chew through it.

Sensor accuracy got pretty much perfect at that point. But then, a few days later, it became clear that my plastic cover did TOO good of a job of getting the sensor close to the wheel, as a loud “clunk” noise would happen on every wheel rotation as the magnet hit/rubbed against the plastic as it went around. The angle of the wheel varies ever so slightly based on how she’s running on it and other factors. So, I stopped at Home Depot and got a metal spacer that was 1 inch in length and replaced the 3/4 inch one to push the wheel 1/4 inch away from the plastic cover. Annoyingly, just that much distance increase caused the sensor to not pick up each rotation accurately, though it did fix the clunking noise, having gotten enough separation. I did some searching about that, thinking maybe there was a better sensor or such. What I did discover was a suggestion to tape some metal behind the sensor so that the magnetic field would be focused more at the sensor as the magnet goes past. So, I pulled the plastic cover out and taped a couple metal washers behind the sensor and mounted the cover back in place. FINALLY, all of that seems to have ironed out the issues.

Side note: Mounting the sensor off center from the wheel works well so that the magnet can’t get stuck next to the sensor and cause false extra sensor trips. The magnet is heavy enough to make the wheel rotate so that the magnet goes to the bottom when it’s at any point in the rotation other than straight up at the top. So, if the sensor is off center, the magnet can’t come to a stop in the same position as the sensor.

As of this writing, after having collected a month or so of data, a few things are clear. Furiosa runs a LOT. Like, even more than I was expecting. And my expectations were already high, given how much I saw her running all the time. Impressively, the stats have proven that she NEVER runs during daylight hours. Not a single rotation of the wheel has happened during true sunlight hours, as of more than a month of logging. The stats have also clocked her running as fast as 2.15 mph (with her tiny little legs). As of this writing, the most running that has been logged for a single night is just under 10 miles (!!!). That’s a few 5K runs worth (or a bit more than a third of a marathon), by a freaking hamster in a single night.

One of my favorite things about finally getting this project working is that I was able to rig up a 10″ Fire tablet (got a cheap refurb deal) over her enclosure which automatically turns on when it senses motion (it is set to not turn on when the room is dark) and refreshes the fun Google Looker stat report, which pulls live stats from the Google Sheets archive log file. So when I walk near it, the tablet turns on and refreshes the stats. That tablet is using Fully Kiosk browser, which is an excellent app that has a lot of nice controls (some of which require a plus license, which is worth getting for only like a $5 one-time license fee, or something like that). Oh, and I tweaked the stats so that days begin at 12PM rather than 12AM. That way, a “day” of stats includes a single night of her running from sundown to sunup.

Overall, after a couple total fails at making this project work, and after putting a lot of effort into making this current version work reliably, I’m very proud of the end result and I’m quite happy with it. It’s very cool and fun, and it’s sobering to find out just how insane Furiosa is with her ridiculous amount of running. Given how high the stats were, I was dubious about the accuracy. But I’ve spot checked it a fair number of times by sitting and watching her run for a couple 5-minute periods at a time and did my best to visually count the rotations, and they all seem to match what’s logged to the spreadsheet. So, despite how insanely high her stats are, I’m forced to believe them to be pretty accurate.

Feel free to check in on her stats from time to time. It should be up to date whenever you look at them. One tip is that there’s a set of up/down arrows on the top right of the daily chart where you can step up and down from daily to monthly to yearly views. You can also click elements and have the other things on the page drilled down to what you clicked on. If you do, click it again and it should toggle it back. If not, look in the 3-dot menu next to those arrows and use the reset option.

Click here to open the stat report in a new tab

Back To Top