Accelerometer Usage Tutorial
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:
| Option | Recommended Product | Connection/Description |
|---|---|---|
| 1. USB Accelerometer | FLY-USB-LIS2DW | LIS2DW accelerometer with USB interface, plug directly into the host's USB port without connecting to the motherboard. |
| 2. Built-in Accelerometer on Tool Board | Expansion tool board with integrated LIS2DW or ADXL345 | Communicates 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
- 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
- Execute the following commands in sequence to install the dependency packages.
- Installation time depends on CPU performance and network conditions, typically taking 10–20 minutes. Please wait patiently until the installation completes.
- 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).
Some older versions of Klipper require executing ACCELEROMETER_QUERY twice before accelerometer data can be retrieved.
Troubleshooting Common Issues
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.
- 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.
- 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)
- Invalid adxl345 id: If the error
Invalid adxl345 id (got xx vs e5)appears, first immediately re-runACCELEROMETER_QUERYonce; 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. - 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.
- 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, ori2c_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:
- In the full
klippy.log, find the firstBatchBulkHelper, then search upward for earlier occurrences ofTimer too close,Lost communication with MCU,MCU shutdown, orSerial connection closed. - If an earlier shutdown exists, first resolve the root cause according to System and Timeout Errors; the subsequent
spi_transfer_responseerror will typically disappear once the connection is restored. - If there is no earlier shutdown and executing
ACCELEROMETER_QUERYimmediately reports an error every time, verify the accelerometer's[mcu],cs_pin,spi_bus, and chip type.
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.
- 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.
- 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:
- Power off and confirm the accelerometer wiring is secure
- Verify the sensor configuration and SPI settings in the configuration file
- Prioritize replacing the finished cable, adapter board, or sensor module to diagnose power/communication issues
Common Resonance Test Errors
| Error Message | Common Cause | Resolution |
|---|---|---|
No data received from accelerometer | Accelerometer not connected, SPI/I2C wiring order incorrect, power supply anomaly | First execute ACCELEROMETER_QUERY to confirm communication is normal, then retest |
Insufficient axis data for shaper calibration | Movement range too small, acceleration too low, sensor reading noise too high | Increase the test range or accel_per_hz, check that the accelerometer is firmly mounted |
Frequency range too narrow | Belt too loose, machine mechanical resonance frequency outside the measurement range | Check belt tension and mechanical structure tightness; lower max_freq or increase accel_per_hz if necessary |
| Resonance graph is all noise with no obvious peaks | Sensor not firmly mounted, fan vibration interference, wiring harness movement | Power 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 error | Missing Python dependencies (numpy/matplotlib), insufficient memory | Install dependencies as described at the beginning of this article; large resonance graph calculations may require more memory |
Cannot test Z axis together with other axes | TEST_RESONANCES specifies the Z axis along with X/Y axes | The Z axis must be tested separately and not mixed with X/Y |
Invalid POINT parameter | POINT= coordinate format is incorrect, or missing one of the three x,y,z values | Fill in the format like POINT=100,100,20 |
Invalid NAME parameter | Output name is empty, contains special characters, or does not match command requirements | Use English letters, numbers, underscores, or hyphens for naming |
No accelerometer measurements found | No valid accelerometer data was collected during the test | First execute ACCELEROMETER_QUERY, then check sensor mounting and communication |
Unsupported output | The OUTPUT= parameter is set to an unsupported type | Fill 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:
- Power off and confirm the accelerometer surface is tightly attached to the tested component without loose cushioning material or double-sided tape.
- Temporarily turn off the model cooling fan, hotend fan, and chamber fan during testing.
- Ensure no wiring is pulling on the sensor or being caught by moving axes during the test.
- Increase the test amplitude: in
[resonance_tester], gradually raiseaccel_per_hzfrom the default75to100–150. - 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
-
Ensure the printer has been homed.
-
Enter the following command in the console to begin automatic calibration of the X and Y axes:
SHAPER_CALIBRATE -
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.
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_freqis 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.