A bit of a delay on this update due to a rather hectic last month 4 weeks or so. Students are back in their masses and alas the day job really eats into my hacking time. The very cheek of it! 🙂
Thankfully this isn’t a downbeat post, rather it’s the first showing of what is one of my most favourite Raspberry Pi projects to date! It’s a mashup between my two major hobbies of coding/hardware and motorbiking.
What you’re looking at is a lean sensor and display, with the intended use being to see lean angles in real time on a motorcycle. Naturally it’s using an RPi at the core of it, here’s the current features run-down:
- 4″ Screen in waterproof case with handlebar mount
- RCA connection from the RPi to the screen
- MPU6050 chip which provides the gyroscope…
- … connected via i2c to the RPi via the Pi Cobbler
- PyGame providing the simple rendering output
- Left/Right lean angles shown on top corners, with an arc showing the lean angle by a circle indicator
- The large number visible is the top lean angle value in the last 5 second window
- Detection of “spikes” of data against threshold values (per sample check for unexpectedly high degrees-of-change per second)
- When spikes are detected you simply need to pass that axis back through 0 degrees to reset it (the indicator circle on the screen will lock in place and light up yellow to indicate the issue). On a bike you just need to level back up again, nothing more. This may seem like it’ll be annoying on the road but in practise it should happen without fuss and be largely unnoticeable – and really help to ensure you aren’t seeing duff values on the screen.
Additionally to what you see in the photo, the system now has a switch to press to set the zero-point for the gyro (basically a case of “please take the current gyro scope values as if they were all 0, the default state” – this means you don’t need to worry too much about the mounting of the system on the motorbike)
The MPU6050 chip I’m using is a cracking piece of kit. For less than £5 (tip: go to eBay, ignore the like of Cool Compoments/Sparkfun etc, they are a rip-off for this) you get a gyroscope, accelerometer and temperature sensor all in one board with a simple i2c interface so it’ll work with RPi or Arduino with hopefully minimal fuss. I’m really pleased with the performance of the gyroscope, it’s not noisy at all when dealing with whole-degree increments.
I’m still at the bench-test stage for this project (The last piece of the jigsaw being deciding on exactly how to power everything on the motorbike: whether I do it directly off the battery or provide my own power system…) so I’m focusing on getting the software nice and stable for the first real-world test in the coming week or two I hope. Nothing to put up on GitHub yet, but it’s not far off. If you’re picking up the MPU6050 I suggest you look here for some great Python code to get you up and running: https://github.com/cTn-dev/PyComms
I suppose in summary I’ve developed something which is sure to encourage me to low-side my bike sometime in the not-so-distant future… d’oh!