Wednesday 24 October 2012

Raspberry PI - Interfacing with an IMU

I picked up a dirt cheap I2C capable 10-DOF "IMU" breakout board with from e-bay ( this one here ) just to see how hard it would be to get some motion sensing capability for my Raspberry Pi. I know that we've had all these sensors built into phones for years now but it's still amazing that I can now buy a 3-DOF Accelerometer, 3-DOF Gyro, 3-DOF Digital compass and have a temperature\barometric pressure sensor thrown in for €20. 

After a bit of minor soldering a quick test proved that all the parts were visible over the I2C bus but I could only find Python libraries for the pressure sensor. This was not a surprise, and frankly I wanted to have to work a bit to get sensible data and I really wanted to have a project that I could use to learn Python. 

The breakout board has these sensors:


The extremely useful AdaFruit Learning System has a basic tutorial, complete with a working interface library for the BMP085. I already had one of those working ( it's on a second Pi that I bought because my first one was taking so long, so now it's monitoring the temperature and pressure in my attic - you can see that data here: https://cosm.com/feeds/80617 ) . That sample gives me enough of a framework to try building up the necessary libraries for the other three sensors. 

I've had a couple of evenings to hack away at this and I've now got sensible, if uncalibrated, data from both the accelerometer and magnetometor via Python. AdaFruit's Raspberry Pi WebIDE has been a joy to use for this sort of learning exercise - it's clean and simple (which I need right now) and its integration with Bitbucket means I can easily point people at the code I've managed to hack together so far:
This stuff just about works and I'm sure anyone who has any sort of Python skills will find a ton of newbie errors and bad practices in there but hey, they work and I will be cleaning them all up as I learn how to do all this properly. And hopefully I'll have the L3G4200D Gyro in there over the next couple of days. 

5 comments:

Kyle Berry said...
This comment has been removed by the author.
Matt said...

The bitbucket links do not appear to be accessible. Can we have a link to the text file?

calibration said...

My cousin recommended this blog and she was totally right keep up the fantastic work!




Temperature calibration

Hacktronics India said...

Don't post unaccessible links, if you are not sharing the code. Unnecessary wasting people's time.

Hacktronics India said...
This comment has been removed by the author.