ADXL345 3-Axis Accelerometer
Overview
ADXL345 3-axis accelerometer sensor. It has high resolution up to ±16g. It is suitable for measuring static acceleration such as tilt sensing as well as dynamic acceleration for detecting movement or shock. Uses I2C or SPI interface.

Specifications
- Operating Voltage: 4V to 6V
- I/O Voltage Range: 1.7V to 3.6V
- Communication: SPI and I2C
- Operating Temperature: -40⁰C to 85⁰C
Supported GPIO
- Raspberry Pi 0~4
- Raspberry Pi 5
- BeagleBone Black/Green
- Jetson Nano
- FT232H, FT2232H, FT4232H
- MCP2221
Commands
[SET_DATARATE]
Sets the data rate (number of data samples per second).
Item | Type | Description |
---|---|---|
Data rate (Hz) | WRITE | Select the data rate (number of data samples per second). (0.10Hz,0.20Hz,0.39Hz,0.78Hz,1.56Hz,3.13Hz,6.25Hz,12.5Hz, 25Hz,50Hz,100Hz,200Hz,400Hz, 800Hz,1600Hz,3200Hz) |
[SET_RANGE]
Sets the data range (measurement range).
Item | Type | Description |
---|---|---|
Data range(g) | WRITE | Select the data range (measurement range). (±2g,±4g,±8g,±16g) |
[GET_DATARATE]
Reads the configured data rate.
Item | Type | Description |
---|---|---|
Data rate (Hz) | READ | Reads the configured data rate (number of data samples per second). |
[GET_RANGE]
Reads the configured data range.
Item | Type | Description |
---|---|---|
Data range(g) | READ | Reads the configured data range (measurement range). |
[READ_ACCEL]
Reads X, Y, Z 3-axis acceleration.
Item | Type | Description |
---|---|---|
X-axis (m/s²) | READ | X-axis acceleration. |
Y-axis (m/s²) | READ | Y-axis acceleration. |
Z-axis (m/s²) | READ | Z-axis acceleration. |
Example
Objective
Display ADXL345’s X, Y, Z axis acceleration values on the dashboard widget.
Parts
Part | Quantity |
---|---|
Raspberry Pi 4 * | 1 |
ADXL345 | 1 |
* Other hardware can also be used. Refer to Supported GPIO.
Wiring (I2C)
Connect each component to the corresponding connection as listed in each row below.
ADXL345 | GPIO |
---|---|
VIN | 3.3V |
GND | GND |
CS | 3.3V |
SDA | 2 (I2C1 SDA) |
SCL | 3 (I2C1 SCL) |
SDO * | No connection |
* If not connected, I2C address is 0x53, if connected to 3.3V it is 0x1D. (May vary depending on module manufacturer.)

Wiring (SPI)
Connect each component to the corresponding connection as listed in each row below.
ADXL345 | GPIO |
---|---|
VIN | 3.3V |
GND | GND |
CS | 8 (SPI0 CE0) |
SDO | 9 (SPI0 MISO) |
SDA | 10 (SPI0 MOSI) |
SCL | 11 (SPI0 SCLK) |

Project Link