Data Sheet

UCTRONICS Ultimate Starter Leaning Kit for Raspberry Pi #K0064
125 www.uctronics.com
8.25 Project: 25 How to use the acceleration sensor ADXL345
8.25.1 Overview
In this lesson, we will learn how to use an acceleration sensor ADXL345 to get acceleration
data.
8.25.2 Requirement
Raspberry Pi ×1
ADXL345 module ×1
Several Jumper wires
8.25.3 Principle
1. What
s ADXL345 ?
Please refer to chapter 3.1 ADXL345 Triaxial Accelerometer Sensor Module
The ADXL345 is well suited for mobile device applications. It measures the static acceleration
of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion
or shock. Its high resolution (3.9 mg/LSB) enables measurement of inclination changes less
than 1.0
°
.
Low power modes enable intelligent motion-based power management with threshold
sensing and active acceleration measurement at extremely low power dissipation.
2. Key functions
int wiringPiI2CSetup (int devId)
This initialises the I2C system with your given device identifier. The ID is the I2C number of
the device and you can use the i2cdetect program to find this out. wiringPiI2CSetup() will
work out which revision Raspberry Pi you have and open the appropriate device in /dev.
The return value is the standard Linux filehandle, or -1 if any error
in which case, you can
consult errno as usual.
int wiringPiI2CRead (int fd)
Simple device read. Some devices present data when you read them without having to do
any register transactions.