Labs / Electronic modules

GraftSense - ADXL345-Based 3-Axis Acceleration Module (Open Version)

Author: Li Zisheng · Source: FreakStudio open documentation, v1.1 · License: CC BY 4.0

Contents
ADXL345 3.3V 2g 16g 13 3.9mg/LSB 32
ADXL345 U1 C1 C7 R1 R4 U2 LED1

I. Module Introduction

Triaxial acceleration module based on ADXL345, adopting the ADXL345 chip solution, supports two digital communication interfaces: I²C / SPI. It can measure triaxial acceleration in the range of ±2g to ±16g, with a 13-bit effective resolution corresponding to an accuracy of 3.9mg/ LSB. Built with a 32-level FIFO and low-power circuit, it is equipped with a 3.3V LDO voltage regulator and power filter circuit. The device address can be configured via the ADDR pin, and it is compatible with 3.3V level MCU, making it suitable for scenarios such as motion detection, attitude recognition, inertial navigation, and portable devices.

II. Introduction to Main Chips

ADXL345 is a Analog Devices -developed 13-bit 3-axis digital accelerometer that supports a selectable measurement range from ±2g to ±16g, features a built-in 32-stage FIFO and low-power characteristics, is compatible with I²C / SPI interfaces, and enables high-precision motion and attitude detection.

2.1 Chip Overview

ADXL345

ADXL345 features ultra-low power consumption (as low as 23μA in measurement mode and 0.1μA in standby mode), 13-bit high precision (3.9mg/ LSB), selectable measurement ranges from ±2g to ±16g, built-in 32-level FIFO, I²C / SPI dual interfaces, as well as special functions such as tap detection, free-fall detection and activity monitoring. It also specifies a wide 2.0V~3.6V power supply range and a compact package, making it suitable for mobile devices, inertial detection and low-power scenarios.

2.2 Pin Definition

ADXL345 INT1 INT2

The pinout and function table of the ADXL345 clearly specify the power supply pins (VDD_IO / V_S), ground pins, I²C / SPI dual-interface communication pins, interrupt output pins (INT1 / INT2) and address select pin (ALT ADDRESS) in terms of their functions and types, providing accurate pin definition reference for hardware design and driver development.

2.3 Functional Block Diagram

ADXL345 3 13 32 INT1 INT2

ADXL345 internally uses a three-axis MEMS sensor to perceive X / Y / Z axis acceleration signals, which are converted into 13-bit digital values by the sensing circuit and ADC, then stored in a 32-level FIFO buffer after digital filtering. Meanwhile, the control and interrupt logic module processes special detection events such as tap and free fall, and finally outputs acceleration data and interrupt status through the I²C / SPI serial interface, providing the system with high-precision and low-power motion and attitude detection capabilities.

2.4 Performance Parameters

ADXL345 0g 2.0V 3.6V 40 85
ADXL345 2g 100Hz 0.1 3200Hz 0.20 2.10 0.30g 3.40g 2.0
ADXL345 40 85 30mg

ADXL345 electrical characteristic parameters, covering **±2g to ±16g measurement ranges**, 13-bit high precision (3.9mg/ LSB), 0.1μA standby current, 0.1~3200Hz output data rate, 2.0V~3.6V power supply range and -40℃~+ 85℃ operating temperature. It also includes key indicators such as noise, offset, sensitivity and power consumption, providing accurate parameter basis for hardware design and performance evaluation.

ADXL345 10 000g 0.3V 3.9V

ADXL345 Absolute Maximum Ratings specify the ultimate tolerance parameters of the device: including 10,000g shock resistance, voltage margin for 2.0V~3.6V power supply, -40℃~+ 105℃ operating/storage temperature range, and warn that exceeding the ratings will cause permanent damage, providing a key reference for safety protection and reliability evaluation in hardware design.

2.5 Reference Circuit

None.

2.6 Chip Configuration

None.

ADXL345 40 41

ADXL345 I²C interface, introduces the I²C mode configuration (CS pin tied to high level), address selection (0x3A / 0x3D, etc.), single-byte/multi-byte read and write timings, as well as the I²C electrical parameters and communication rate limit (max 400kHz). It also provides a typical connection circuit and address addressing format, offering a clear protocol flow reference for stably implementing I²C communication and register operations.

ADXL345

ADXL345 's I²C interface timing parameter table and waveform diagram define in detail the clock cycle, high/low level duration, start/stop condition timing, data setup/hold time at a maximum communication rate of 400kHz, as well as the rise/fall time of SCL / SDA and the bus capacitive load limit, providing precise timing constraints for the stable and reliable implementation of I²C communication.

2.8 PCB Routing Notes

None.

III. Circuit Engineering

3.1 Circuit Source Engineering

To obtain the circuit source project, please follow the official account [Freak Embedded].

3.2 Module Usage Instructions

The schematic diagram of this module is shown below:

SCH_3-Axis Accelerometer Module Based on ADXL345-V1.0.0_2026-03-27.pdf 2.6 MB

ADXL345 3-Axis V1.0.0 U1 C1 C7 R1 R4 LED1 400kHz

This module provides an I²C communication interface: it supports a maximum communication rate of 400kHz, and the device address can be flexibly configured via the ADDR dip switch (e. g., 0x1D, 0x53). It is compatible with 3.3V level, and can stably implement three-axis acceleration data reading, register configuration, and interrupt status acquisition for special functions (tap / free fall). It is suitable for scenarios such as motion detection, attitude recognition, and low-power portable devices, providing the system with high-precision inertial detection and interaction capabilities.

3.3 Application Experiment

Here, we use the GraftPort-RP2040 development board for testing, and the ADXL345-based three-axis acceleration module uses the I2C interface to communicate with the main controller.

Here, we first use the HY2.0-4P connection cable to connect the module to the GraftPort-RP2040 development board's I2C0 interface:

The module connections are shown in the following table:

Development Board Pins

Module Pins

Description

Pin 4

SDA

I2C data transmission line, corresponding to I2C0 's SDA

Pin 5

SCL

I2C clock signal line, corresponding to the I2C0 SCL

Here, we need to search for the relevant driver packages on uPyPI: https://upypi.net/zh/

106

Enter adxl345_driver to search, and the following will be displayed:

adxl345_driver 1.0.1

Click to copy the local installation command:

adxl345_driver adxl345 1.0.1 2024 03 10

Import the module driver library code via the mip tool. Below are the usage commands for the mpremote tool:

mpremote mip install https://upypi.net/pkgs/adxl345_driver/1.0.0

Import the ADXL345-based three-axis acceleration module - MicroPython driver code, then copy the following main.py code into our project:

# Python env   : MicroPython v1.23.0
# -*- coding: utf-8 -*-
# @Time    : 2026/3/14 PM 2:30
# @Author  : fanday
# @File    : main.py
# @Description : ADXL345 three-axis accelerometer test. Initializes, scans I2C, and reads XYZ axis acceleration data
# ======================================== Import Modules =========================================

# Import the Pin class from the machine module, used to control GPIO pins
from machine import Pin

# Import the I2C class from the machine module, used for I2C communication
from machine import I2C

# Import the time module, used for delay operations
import time

# Import the ustruct module, used to parse binary data
import ustruct

# Import the adxl345 class from the adxl345 module, which is the driver class for the ADXL345 sensor
from adxl345 import adxl345

# ======================================== Global Variables ============================================

# I2C bus number (use bus 0)
I2C_BUS_NUM = 0
# ADXL345 SCL pin is connected to GP5
I2C_SCL_PIN = 5
# ADXL345 SDA pin is connected to GP4
I2C_SDA_PIN = 4
# I2C communication frequency is set to 400KHz
I2C_FREQ = 400000
# List of I2C addresses supported by the ADXL345 (default address 0x53, or 0x1D if the SDO pin is pulled high)
TARGET_SENSOR_ADDRS = [0x53, 0x1D]
# Initialize the sensor object to None; assign it after a successful scan
snsr = None
# Create the ADXL345 chip-select pin object and set it to output mode (the chip-select pin must be set to output in I2C mode)
cs = Pin(22, Pin.OUT)

# ======================================== Functions ============================================

# ======================================== Custom Classes ============================================

# ======================================== Initialization configuration ===========================================

# Delay 3 seconds to wait for the system to stabilize
time.sleep(3)
# Output initialization start message (short English sentence only)
print("FreakStudio: Starting I2C scanner for ADXL345")
# Initialize the I2C bus for scanning devices (sensor initialization still uses the original parameter format)
i2c_bus = I2C(I2C_BUS_NUM, scl=Pin(I2C_SCL_PIN), sda=Pin(I2C_SDA_PIN), freq=I2C_FREQ)
# Scan all device addresses on the I2C bus and return the address list
devices_list: list[int] = i2c_bus.scan()
# Print scan start message
print("START I2C SCANNER")
# Check whether any device was found
if len(devices_list) == 0:
    # Print a message when no device is found
    print("No i2c device !")
    # Raise an exception and exit the program
    raise SystemExit("I2C scan found no devices, program exited")
else:
    # Output the number of devices found
    print("i2c devices found:", len(devices_list))
    # Initialize the target address variable
    target_addr = None
    # Iterate over all scanned device addresses
    for device in devices_list:
        # If the current address is in the target sensor address list
        if device in TARGET_SENSOR_ADDRS:
            # Record the target address
            target_addr = device
            # Print the target address in hexadecimal format
            print("I2c hexadecimal address:", hex(device))
            try:
                # Pass parameters as required by the adxl345 class: bus number, SCL pin, SDA pin, chip-select pin
                snsr = adxl345(bus=I2C_BUS_NUM, scl=I2C_SCL_PIN, sda=I2C_SDA_PIN, cs=cs)
                # Sensor initialization success message
                print("Target sensor initialization successful")
                # Break out of the loop
                break
            except Exception as e:
                # Print exception information when initialization fails
                print(f"Sensor Initialization failed: {e}")
                # Continue trying the next address
                continue
    # If the sensor object is still None (initialization did not succeed)
    if snsr is None:
        # Raise a clear exception prompting to check wiring or address
        raise Exception("No ADXL345 found, please check wiring or address (0x53/0x1D)!")

# ========================================  Main Program  ============================================

# Read sensor data in an infinite loop
while True:
    # Read three-axis acceleration data; return value unit is mg
    x, y, z = snsr.readXYZ()
    # Print X, Y, Z axis data (unit: mg)
    print("x:", x, "y:", y, "z:", z, "unit:mg")
    # Delay 0.5 seconds
    time.sleep(0.5)

Burn the code, open the terminal, and the output is as follows:

I2C 0x53 adxl345 ADXL345

It can be seen that the three-axis acceleration values can be printed cyclically.

IV. Drivers

adxl345_driver-1.0.1.zip 11 KB

None.

6. Revision History

Document Version

Date of Revision

Modifier

Modified Content

v1.0

2026-03-27

Ling Gaoxing

Initialize the document

v1.0.1

2026-04-05

Li Zisheng

The homepage photo has not been taken, the production files have not been exported yet, and all other items have been sorted out completely.

v1.0.2

2026-04-14

Li Zisheng

Modified main.py.

v1.0.3

2026-04-21

Li Zisheng

The production documents have not been exported yet, while all the others have been sorted out completely.

v1.1

2026-04-23

Xin Ruili

Create an open version of the document based on the internal document version v1.0.3.

VII. Relevant Materials

7.1 Chip Datasheet

ADXL345.pdf 887 KB

7.2 Unique Icons for PCB Silk Screen

ADXL345 7.2