RunHedgie's setup

I've been working on RunHedgie for a while. It's an automated tweeting treadmill for my wife's African Pigmy Hedgehog called Antu. Every morning he'll tweet how much he ran, just like RunKeeper :).

Antu is quite shy, just as a normal hedgie. To feel that he interacts a little more I connected a wireless node with a magnetic switch so I could count how many laps he runs every night, and therefore the equivalent distance.

The physical setup

Here's an image of the treadmill:

And a closeup of the switch/magnet components:

Hardware side

I used a custom wireless node based on Arduino. It is basically an ATMega328p microcontroller with an RFM12B radio at 433 MHz and a LiPo battery.

The board and the software is design to support different sensors, but for this case it consists of a simple reed switch and a DS18B20 temperature sensor.

Here's a picture of the node:

The orange cables are the ones that go to the reed switch. I wanted to keep everything separated since the wheel needs to be cleaned regularly.

Software side

I have an identical node connected to a Raspberry Pi, who receives the packet through the radio link and sends through the serial port of the Pi. That node also has a humidity sensor and an ambient light sensor I'd like to integrate soon.

In the Pi, there's a python program that listens to new lines and whenever it receives one then it posts the payload to an internal server.

Each request is then sent to a Redis queue which is then emptied by a worker. The actual payload processing will be covered in another post.

Everything is saved on a PostgreSQL database, which is then queried to calculate the ran distance.

It might seem that this setup is an overkill, but I did it that way since I wanted to learn these technologies hands-on.

Have a look at the code if you're interested!

Future goals

I'm moving the backend to Go, but I'm struggling with pretty much everything there :)

I'd like to expose an API and give away API keys so that pattern analysis could be made with the data. Very little is known from hedgies activities, so it'd bee cool to have a look at that.

Thanks for reading!

comments powered by Disqus