Trampoline Bounce Counter

TL;DR – I used a Raspberry Pi to count bounces on a trampoline.

My daughter recently received a small trampoline for her birthday. Needless to say, she bounces on it endlessly. Most dads would simply watch and appreciate the energy expended from every bounce.

I wanted to kick things up a notch and quantify just how many times a day she actually bounced. I decided to use a Raspberry Pi and an ultrasonic distance sensor (HC-SR04), because I happened to have both lying/laying/lounging around.

I used the following links to help me out:

I rigged up the wiring from the sensor to the Raspberry Pi and tested it out using the initial code. The sample code linked above calculates distance using the ultrasonic sensor. The rest was making it usable as a bounce counter.

I first used the sensor to collect bounce data as fast as the python code would let me. As my daughter bounced the diaphragm of the trampoline would go up and down. The sensor could easily detect this distance with +/- 0.2cm precision at around 1000 samples/second.

The logic of the program is pretty easy. A bounce is counted if the sensor detects the diaphragm has gone down by a measurable amount. Another bounce will not be counted until the sensor detects the diaphragm has returned back to the original position. In practice this is a little more difficult to perfect. I wrote a supplemental script which hones the values pretty nicely for each specific trampoline setup and surface!

For me a command line tool and log is enough, but for the family I knew I needed a nice visual aid. I’m not at all a GUI maker, but I did create a simple page with some AJAX that dynamically updates the count without a page refresh.

At the end of the day two hours of coding and setting up a spare pi was definitely worth the entertainment. For those of you who are actually going to git clone the project. There are some nice systemd configs, logging, and calibration scripts to make your life easier.