The hardware I’m using here is a Raspberry Pi Type A, described in detail here. My previous post (Part 1: Modules and Packages) configured the Raspberry Pi to use the I2C connection. The aim in this post is to connect to a SparkFun 9DOF Sensor Stick (SEN-10724) which has a 3-axis accelerometer (ADXL345), a 3-axis gyro (ITG-3200) and a 3-axis compass / magnetometer (HMC5883L) all sharing an I2C interface.
There are three separate devices on the sensor stick all hooked up to the same I2C bus. You can see the addresses listed below. The HMC5883L compass / magnetometer uses address 1e. The ADXL345 accelerometer uses address 53. The ITG-3200 gyroscope uses address 68. (The ‘UU’ at address 3b indicates an address reserved by the kernel, but I don’t know for what.)
~ $ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1e -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- 53 -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
2. Connecting to the Sensor Stick
I’m not the first to use this stick, and there is, for example, a project by Peter Bartz which uses the stick:
Attitude and Heading Reference System (AHRS). More useful, perhaps, is Rolfe Schmidt’s muCSense work with it here and here.
All three I2C devices have open source (MIT license) C++ device libraries available from I2Cdevlib:
These rely on the underlying Wire class written for the Arduino, however, so a Raspberry Pi implementation of the Wire class is necessary (and one or two other miscellaneous functions).
I am currently working on this – find the latest source here, and a discussion topic here.