ADXL345
Wiring
- The accelerometer connection method is shown in the figure below.
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
- 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
- Execute the following commands sequentially 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 is complete.
- 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).
Some older versions of Klipper require executing ACCELEROMETER_QUERY twice to obtain accelerometer data.
Common Issue Handling
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.
- First execution fails: Some Klipper versions may have command recognition delays. If the first execution does not return data, re-execute the same command.
- 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)
- Invalid adxl345 id: If prompted
Invalid adxl345 id (got xx vs e5), immediately re-executeACCELEROMETER_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 manual soldering or repair solder joints. - 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.
- 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, ori2c_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:
- Power off and confirm the accelerometer wiring is secure
- Verify the sensor configuration and SPI in the configuration file
- Prioritize using replacement finished cables, adapter boards, or sensor modules to diagnose power/communication issues
Common Resonance Test Errors
| Error Message | Common Cause | Resolution Method |
|---|---|---|
No data received from accelerometer | Accelerometer not connected, SPI/I2C wiring sequence error, power supply anomaly | First execute ACCELEROMETER_QUERY to confirm normal communication, then retest |
Insufficient axis data for shaper calibration | Motion range too small, acceleration too low, excessive sensor reading noise | Increase test range or accel_per_hz, check if accelerometer is securely fastened |
Frequency range too narrow | Belt too loose, machine mechanical resonance frequency outside measurement range | Check belt tension, mechanical structure tightness; lower max_freq or increase accel_per_hz if necessary |
| Resonance graph is all noise, no obvious peak | Sensor not securely fastened, fan vibration interference, wiring harness movement | Power off and resecure the sensor; turn off fans during testing; route signal wires separately from motor wires |
SHAPER_CALIBRATE executes with no output or crashes | Python dependencies missing (numpy/matplotlib), insufficient memory | Reinstall 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 axes | TEST_RESONANCES specifies the Z axis along with X/Y axes simultaneously | Z axis needs separate testing, do not mix with X/Y |
Invalid POINT parameter | POINT= coordinate format error, or missing the three values for x,y,z | Fill in the format POINT=100,100,20 |
Invalid NAME parameter | Output name is empty, contains special characters, or does not match command requirements | Use English, numbers, underscores, or hyphens for naming |
No accelerometer measurements found | No valid acceleration data collected during the test | First execute ACCELEROMETER_QUERY, then check sensor fixation and communication |
Unsupported output | The OUTPUT= parameter has been filled with an unsupported type | Fill 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:
- Power off and confirm the accelerometer surface is tightly attached to the component being tested, without any cushioning material or loose double-sided tape.
- Temporarily turn off the model cooling fan, hot-end fan, and chamber fan during the test.
- Ensure no wiring harness is pulling on the sensor or being caught by moving axes during the test.
- Increase the test amplitude: In
[resonance_tester], gradually increaseaccel_per_hzfrom the default75to100–150. - 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
-
Ensure the printer has been homed.
-
Enter the following command in the console to start automatic calibration of the X and Y axes:
SHAPER_CALIBRATE -
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.
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_freqsettings, 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.