Python/Raspberry Pi: Motorcycle Lean Sensor

My “Motorcycle Lean Sensor” is one of my favourite projects, it combines my love for technology with my love for all things motorcycle-related 🙂

Put simply, the system is a handlebar mounted screen for displaying the lean angle of your motorcycle in realtime. Utilises Python for the software side.

Screen, Raspberry Pi, Pi Cobbler & Gyro Chip.

Screen, Raspberry Pi, Pi Cobbler & Gyro Chip.

Hardware:

  • 4″ Screen in waterproof case with handlebar mount
  • RCA connection from the Raspberry Pi to the screen
  • MPU6050 chip which provides the gyroscope…
  • … connected via i2c to the Raspberry Pi via the Pi Cobbler

Software:

  • PyGame providing the 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 has a switch to press to set the zero-point for the gyro – this means you don’t need to worry too much about the mounting of the system on the motorbike.

3 thoughts on “Python/Raspberry Pi: Motorcycle Lean Sensor

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s