Skip to main content

ADXL345

Wiring

  • The accelerometer connection method is shown in the figure below.
Loading...

Reference Configuration

[adxl345]
cs_pin: PB12
spi_bus: spi2 # Hard SPI, choose between hard SPI and soft SPI. Default is hard SPI.
# spi_software_mosi_pin: PB15 # Soft SPI, choose between hard SPI and soft SPI. Default is hard SPI.
# spi_software_miso_pin: PB14
# spi_software_sclk_pin: PB13

[resonance_tester]
accel_chip: adxl345
#accel_chip_y: adxl345 bed
probe_points:
100, 100, 20 # Typically the center of the heatbed. Modify according to your machine's actual situation.

Tutorial

Accelerometer Testing and Calibration

Dependency Package Installation

Notes
  • If the device is running the FlyOS-FAST system, the required dependencies are pre-installed. This step can be skipped.
  • If using a non-FLY host computer, please ensure you complete the following installation steps.
  • It is recommended to use SSH tools like MobaXterm or PuTTY to connect before proceeding.
  • This tutorial is based on the Raspberry Pi; other platforms are for reference only.

Installation Steps

  1. Execute the following commands sequentially to install the dependency packages.
  2. Installation time depends on CPU performance and network conditions, typically taking 10–20 minutes. Please wait patiently until the installation is complete.
  3. If the device's RAM is too small, installation may fail.

Step 1: Install system dependency packages

sudo apt install python3-numpy python3-matplotlib libatlas-base-dev

Step 2: Install Klipper virtual environment dependency packages

~/klippy-env/bin/pip install matplotlib numpy

Accelerometer Testing

Prerequisites

  • The printer has performed the Homing operation.
  • Ensure the accelerometer is correctly enabled in the Klipper configuration file.

Test Commands

Enter the following command in the Klipper console:

ACCELEROMETER_QUERY

If multiple accelerometers are connected, you can specify the chip for testing:

ACCELEROMETER_QUERY CHIP=<ADXL chip name>

Replace <ADXL chip name> with the actual accelerometer identifier (e.g., adxl345).

Tip

Some older versions of Klipper require executing ACCELEROMETER_QUERY twice to obtain accelerometer data.

Common Issue Handling

Power Off Operation

Before inspecting, re-plugging, or replacing the accelerometer wiring, completely shut down the printer and disconnect the power supply. Do not plug/unplug ADXL/LIS2DW/MPU/ICM modules or touch exposed pins while powered on.

  1. First execution fails: Some Klipper versions may have command recognition delays. If the first execution does not return data, re-execute the same command.
  2. Command not recognized: If repeated executions still prompt an unknown command, the Klipper version might be too low. It is recommended to:
    • Update Klipper to the latest version
    • Or re-flash the latest system version (e.g., the latest FlyOS-FAST)
  3. Invalid adxl345 id: If prompted Invalid adxl345 id (got xx vs e5), immediately re-execute ACCELEROMETER_QUERY once. If the error persists, prioritize replacing the finished accelerometer cable, adapter board, or sensor module for cross-testing. It is not recommended for users to perform manual soldering or repair solder joints.
  4. Invalid lis2dw / mpu / icm id: If using sensors like LIS2DW, MPU9250, or ICM20948, confirm that the configuration section name, communication bus, and chip model match the actual hardware.
  5. Unable to obtain response / timeout: Usually indicates a communication anomaly between the host computer and the accelerometer MCU. Please check the USB/CAN connection, [mcu] ID, cs_pin, spi_bus, or i2c_bus.

Result Interpretation

  • Normal Output: If a continuous data stream is returned (as shown in the figure below), the accelerometer is working correctly, and resonance compensation measurements can proceed.
  • Error Output: If a timeout, no data, or communication error is reported, check the following in order:
    1. Power off and confirm the accelerometer wiring is secure
    2. Verify the sensor configuration and SPI in the configuration file
    3. Prioritize using replacement finished cables, adapter boards, or sensor modules to diagnose power/communication issues
Loading...

Common Resonance Test Errors

Error MessageCommon CauseResolution Method
No data received from accelerometerAccelerometer not connected, SPI/I2C wiring sequence error, power supply anomalyFirst execute ACCELEROMETER_QUERY to confirm normal communication, then retest
Insufficient axis data for shaper calibrationMotion range too small, acceleration too low, excessive sensor reading noiseIncrease test range or accel_per_hz, check if accelerometer is securely fastened
Frequency range too narrowBelt too loose, machine mechanical resonance frequency outside measurement rangeCheck belt tension, mechanical structure tightness; lower max_freq or increase accel_per_hz if necessary
Resonance graph is all noise, no obvious peakSensor not securely fastened, fan vibration interference, wiring harness movementPower off and resecure the sensor; turn off fans during testing; route signal wires separately from motor wires
SHAPER_CALIBRATE executes with no output or crashesPython dependencies missing (numpy/matplotlib), insufficient memoryReinstall dependencies as per the installation steps at the beginning of this article; calculating large resonance graphs may require more memory
Cannot test Z axis together with other axesTEST_RESONANCES specifies the Z axis along with X/Y axes simultaneouslyZ axis needs separate testing, do not mix with X/Y
Invalid POINT parameterPOINT= coordinate format error, or missing the three values for x,y,zFill in the format POINT=100,100,20
Invalid NAME parameterOutput name is empty, contains special characters, or does not match command requirementsUse English, numbers, underscores, or hyphens for naming
No accelerometer measurements foundNo valid acceleration data collected during the testFirst execute ACCELEROMETER_QUERY, then check sensor fixation and communication
Unsupported outputThe OUTPUT= parameter has been filled with an unsupported typeFill in according to Klipper's supported output types, commonly resonances

If ACCELEROMETER_QUERY works normally but the resonance test consistently fails, prioritize troubleshooting in the following order:

  1. Power off and confirm the accelerometer surface is tightly attached to the component being tested, without any cushioning material or loose double-sided tape.
  2. Temporarily turn off the model cooling fan, hot-end fan, and chamber fan during the test.
  3. Ensure no wiring harness is pulling on the sensor or being caught by moving axes during the test.
  4. Increase the test amplitude: In [resonance_tester], gradually increase accel_per_hz from the default 75 to 100–150.
  5. If using an accelerometer on a toolhead board (USB/CAN), ensure the communication wires are not placed near motor wires or heated bed wires.

Accelerometer Calibration

Calibration Steps

  1. Ensure the printer has been homed.

  2. Enter the following command in the console to start automatic calibration of the X and Y axes:

    SHAPER_CALIBRATE
  3. After calibration is complete, save the configuration:

    SAVE_CONFIG

Single Axis Calibration

If you only need to calibrate a single axis, use:

SHAPER_CALIBRATE AXIS=X

Or replace X with Y.

Safety Notice

The printer may generate intense vibrations during calibration. If the vibration is too severe, immediately press the emergency stop button or send the M112 command for an emergency stop.

Adjusting Vibration Intensity

If the vibration is too strong during testing, you can appropriately lower the accel_per_hz parameter value (default 75):

[resonance_tester]
accel_per_hz: 50

Configuration and Tuning Issues: For problems such as poor results after enabling resonance compensation despite normal accelerometer hardware, improper shaper_freq settings, or conflicts between Pressure Advance and Input Shaper, please refer to Resonance Compensation and Pressure Advance Configuration Issues.

Explanation: The steps above are applicable for resonance compensation configuration on most Klipper-based 3D printers. Please adjust according to your actual hardware and system environment.

Loading...