Skip to main content

Accelerometer Usage Tutorial

Accelerometer Usage Limitations

Due to the LITE2 series hardware design, it cannot directly connect to and drive an independent SPI/I²C accelerometer module (such as ADXL345).

If you need to use the accelerometer function on a device based on the LITE2 series, please choose one of the following two options:

OptionRecommended ProductConnection/Description
1. USB AccelerometerFLY-USB-LIS2DWLIS2DW accelerometer with USB interface, plug directly into the host's USB port without connecting to the motherboard.
2. Built-in Accelerometer on Tool BoardExpansion tool board with integrated LIS2DW or ADXL345Communicates with the motherboard via CAN or other interfaces, with the accelerometer recognized and invoked as part of the tool board.

Important Reminder: Do not attempt to connect modules such as ADXL345 directly to the pins of the C8P motherboard. To ensure compatibility and proper functionality, it is recommended to use the FLY-USB-LIS2DW USB accelerometer specially designed for external accelerometers.

Accelerometer Testing and Calibration

Dependency Package Installation

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

Installation Steps

  1. Execute the following commands in sequence 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 completes.
  3. If the device has insufficient memory (RAM), the 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 Command

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 before accelerometer data can be retrieved.

Troubleshooting Common Issues

Power Off Required

Before inspecting, reconnecting, or replacing accelerometer wiring, completely shut down the printer and disconnect the power supply. Do not plug or 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, execute the same command once more.
  2. Command not recognized: If repeated attempts still report an unknown command, the Klipper version may be too old. It is recommended to:
    • Update Klipper to the latest version
    • Or reflash the latest system image (e.g., the latest FlyOS-FAST version)
  3. Invalid adxl345 id: If the error Invalid adxl345 id (got xx vs e5) appears, first immediately re-run 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 their own soldering or repair solder joints.
  4. Invalid lis2dw / mpu / icm id: If using sensors such as 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: This usually indicates a communication issue between the host computer and the accelerometer MCU. Check the USB/CAN connection, [mcu] ID, cs_pin, spi_bus, or i2c_bus.

BatchBulkHelper / spi_transfer_response

Error message: The following appears when executing ACCELEROMETER_QUERY, TEST_RESONANCES, or SHAPER_CALIBRATE:

BatchBulkHelper start callback error
BatchBulkHelper stop callback error
Unable to obtain 'spi_transfer_response' response

Nature of the error: spi_transfer_response indicates that Klipper did not receive a response to the SPI request, but it may not be the root cause. In recent log cases, the MCU first entered shutdown due to Timer too close, and only then did the ADXL bulk collection report the inability to obtain an SPI response. In this case, address the earlier shutdown first rather than directly concluding the accelerometer is faulty.

Troubleshooting steps:

  1. In the full klippy.log, find the first BatchBulkHelper, then search upward for earlier occurrences of Timer too close, Lost communication with MCU, MCU shutdown, or Serial connection closed.
  2. If an earlier shutdown exists, first resolve the root cause according to System and Timeout Errors; the subsequent spi_transfer_response error will typically disappear once the connection is restored.
  3. If there is no earlier shutdown and executing ACCELEROMETER_QUERY immediately reports an error every time, verify the accelerometer's [mcu], cs_pin, spi_bus, and chip type.
Power Off Required

Before reconnecting or replacing the accelerometer wiring, adapter board, or module, completely shut down the printer and disconnect the power supply. Do not plug or unplug SPI/I2C wiring or touch exposed pins while powered on.

  1. After powering off, replace the finished cable, adapter board, or sensor module for cross-testing; do not let regular users perform their own soldering or fly-wiring.
  2. If the error only occurs at the beginning or end of a resonance test, temporarily disable the camera, display, and other high-load services, then retest, and retain the full logs for further analysis.

Result Evaluation

  • Normal output: If a continuous data stream is returned (as shown in the figure below), the accelerometer is working correctly and resonance compensation measurement 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 settings in the configuration file
    3. Prioritize replacing the finished cable, adapter board, or sensor module to diagnose power/communication issues
Loading...

Common Resonance Test Errors

Error MessageCommon CauseResolution
No data received from accelerometerAccelerometer not connected, SPI/I2C wiring order incorrect, power supply anomalyFirst execute ACCELEROMETER_QUERY to confirm communication is normal, then retest
Insufficient axis data for shaper calibrationMovement range too small, acceleration too low, sensor reading noise too highIncrease the test range or accel_per_hz, check that the accelerometer is firmly mounted
Frequency range too narrowBelt too loose, machine mechanical resonance frequency outside the measurement rangeCheck belt tension and mechanical structure tightness; lower max_freq or increase accel_per_hz if necessary
Resonance graph is all noise with no obvious peaksSensor not firmly mounted, fan vibration interference, wiring harness movementPower off, re-secure the sensor, turn off fans during testing, route signal wires separately from motor wires
SHAPER_CALIBRATE produces no output or exits with an errorMissing Python dependencies (numpy/matplotlib), insufficient memoryInstall dependencies as described at the beginning of this article; large resonance graph calculations may require more memory
Cannot test Z axis together with other axesTEST_RESONANCES specifies the Z axis along with X/Y axesThe Z axis must be tested separately and not mixed with X/Y
Invalid POINT parameterPOINT= coordinate format is incorrect, or missing one of the three x,y,z valuesFill in the format like POINT=100,100,20
Invalid NAME parameterOutput name is empty, contains special characters, or does not match command requirementsUse English letters, numbers, underscores, or hyphens for naming
No accelerometer measurements foundNo valid accelerometer data was collected during the testFirst execute ACCELEROMETER_QUERY, then check sensor mounting and communication
Unsupported outputThe OUTPUT= parameter is set to an unsupported typeFill in a Klipper-supported output type; resonances is commonly used

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 tested component without loose cushioning material or double-sided tape.
  2. Temporarily turn off the model cooling fan, hotend fan, and chamber fan during testing.
  3. Ensure no wiring is pulling on the sensor or being caught by moving axes during the test.
  4. Increase the test amplitude: in [resonance_tester], gradually raise accel_per_hz from the default 75 to 100–150.
  5. If using an accelerometer on a tool board (USB/CAN), confirm the communication wires are not routed near motor wires or the heated bed wires.

Accelerometer Calibration

Calibration Steps

  1. Ensure the printer has been homed.

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

    SHAPER_CALIBRATE
  3. After calibration completes, save the configuration:

    SAVE_CONFIG

Single-Axis Calibration

If only a single axis needs calibration, use:

SHAPER_CALIBRATE AXIS=X

Or replace X with Y.

Safety Notice

During calibration, the printer may vibrate violently. If the vibration becomes excessive, immediately press the emergency stop button or send the M112 command to halt.

Adjusting Vibration Intensity

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

[resonance_tester]
accel_per_hz: 50

Configuration and tuning issues: If the accelerometer hardware is normal but resonance compensation is ineffective after enabling, shaper_freq is set incorrectly, or there are conflicts between Pressure Advance and Input Shaper, please refer to Resonance Compensation and Pressure Advance Configuration Issues.

Note: The above steps apply to most Klipper-based 3D printer resonance compensation configurations. Please adjust them according to your actual hardware and system environment.

Loading...