Wiring a digital accelerometer to the I2C bus
Digital accelerometers usually provide a better precision, higher resolution and more sensitivity than analog accelerometers. Now, we will work with a digital 3-axis accelerometer with a full sensing range from -16g to +16g. We will use a breakout board that uses the I2C bus to allow the board to communicate with the accelerometer.
We will use the two pins labeled SDA and SCL to connect the data and clock lines of the I2C bus to the corresponding pins in the digital accelerometer breakout board. After we finish the necessary wirings, we will write Python code to measure and display the acceleration for the three axis: x, y and z. This way, we will read the result of sending commands to the accelerometer through the I2C bus, reading the responses and decoding them into the appropriate acceleration values expressed in g-force (g
).
We need a SparkFun triple axis accelerometer breakout ADXL345 to work with this example. The following URL provides detailed...