AccelSpectra is a real-time Three axes USB Accelerometer spectrum analyzer. It reads tri-axis accelerometer samples from a serial device, processes the X/Y/Z vibration data with FFTW, and displays a live frequency spectrum in a Qt 6 desktop interface.
Use AccelSpectra for accelerometer FFT analysis, vibration measurement, motion sensor diagnostics, resonance checks, and embedded sensor development workflows where raw serial accelerometer data needs to become an interactive spectrum plot quickly.
- Real-time serial accelerometer acquisition over Qt SerialPort.
- Live X, Y, and Z axis FFT spectrum visualization with Qt Charts.
- Selectable accelerometer sampling frequency from 0.1 Hz to 3200 Hz.
- Selectable accelerometer measurement range: 2 g, 4 g, 8 g, or 16 g.
- Configurable FFT window size: 64, 128, 256, 512, 1024, 2048, or 4096 samples.
- Window functions: Blackman, Hamming, Hann, and Rectangular.
- FFT hop size controls: 25%, 50%, 75%, and 100%.
- Logarithmic magnitude axis and frequency axis scaled to Nyquist frequency.
- Per-channel visibility toggles for X, Y, and Z spectra.
- C++20 core library with unit tests for DSP, parsing, buffering, windows, spectrum data, and application control.
- C++20
- CMake 3.28 or newer
- Qt 6 Core, Widgets, SerialPort, and Charts
- FFTW3
- GoogleTest
- CTest
AccelSpectra is split into a reusable processing core and a Qt desktop executable:
src/devicehandles serial communication and USB accelerometer commands.src/datacontains signal buffers, spectrum storage, serial parsing, and circular buffer logic.src/dspcontains FFT processing and signal window implementations.src/servicescoordinates serial input, DSP configuration, FFT execution, and device commands.src/uicontains the Qt main window and live chart controls.testscontains GoogleTest-based unit tests.
The application expects newline-delimited tri-axis integer samples:
x,y,z\n
Example:
12,-4,255
13,-5,251
The serial port is opened with:
- Baud rate:
115200 - Data bits:
8 - Parity:
none - Stop bits:
1 - Flow control:
none
Parsed raw integer samples are scaled internally with 9.81 / 255.0, DC offset is removed, the selected window function is applied, and FFTW calculates the frequency-domain spectrum for each axis.
When a serial port is opened, AccelSpectra sends the current device configuration to the connected accelerometer. The application supports these command families:
FREQ 3200
FREQ 1600
FREQ 800
FREQ 400
FREQ 200
FREQ 100
FREQ 50
FREQ 25
FREQ 12.5
FREQ 6.25
FREQ 3.13
FREQ 1.56
FREQ 0.78
FREQ 0.39
FREQ 0.20
FREQ 0.10
RANGE 2
RANGE 4
RANGE 8
RANGE 16
START
STOP
Install the compiler, CMake, Qt 6, FFTW3, and GoogleTest packages:
sudo apt update
sudo apt install \
build-essential \
cmake \
pkg-config \
qt6-base-dev \
libqt6serialport6-dev \
libqt6charts6-dev \
libfftw3-dev \
libgtest-devFor serial hardware access, your user may need membership in the dialout group:
sudo usermod -aG dialout "$USER"Log out and log back in after changing group membership.
Configure and build a release binary:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -jThe application executable is created at:
build/accel_spectra
Run it with:
./build/accel_spectraBuild with tests enabled, then run CTest:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON
cmake --build build -j
ctest --test-dir build --output-on-failureYou can also run the test executable directly:
./build/accel_spectra_testsThe current test suite covers:
- Application controller configuration and state changes.
- FFT pipeline behavior.
- Signal window operations.
- Spectrum storage.
- Serial parser validation.
- SPSC vector circular buffer behavior.
- DSP window functions.
AccelSpectra exposes these project-specific CMake options:
| Option | Default | Description |
|---|---|---|
ACCEL_SPECTRA_WARNINGS_AS_ERRORS |
OFF |
Treat compiler warnings as errors. |
ACCEL_SPECTRA_ENABLE_ASAN |
OFF |
Enable AddressSanitizer. |
ACCEL_SPECTRA_ENABLE_UBSAN |
OFF |
Enable UndefinedBehaviorSanitizer. |
ACCEL_SPECTRA_ENABLE_TSAN |
OFF |
Enable ThreadSanitizer. |
Example sanitizer build:
cmake -S . -B build-asan \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_TESTING=ON \
-DACCEL_SPECTRA_ENABLE_ASAN=ON \
-DACCEL_SPECTRA_ENABLE_UBSAN=ON
cmake --build build-asan -j
ctest --test-dir build-asan --output-on-failureAddressSanitizer and ThreadSanitizer cannot be enabled together.
Prebuilt Linux AppImage packages are available from the AccelSpectra GitHub page. Use the AppImage when you want to run the application without compiling it from source.
Create a release build without tests:
cmake -S . -B build-appimage -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF
cmake --build build-appimage -jDownload linuxdeploy and the Qt plugin:
wget -O resources/linuxdeploy-x86_64.AppImage \
https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
wget -O resources/linuxdeploy-plugin-qt-x86_64.AppImage \
https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
chmod +x resources/linuxdeploy-x86_64.AppImage resources/linuxdeploy-plugin-qt-x86_64.AppImagePrepare the AppDir:
rm -rf AppDir
mkdir -p AppDir/usr/bin
mkdir -p AppDir/usr/share/applications
mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
cp build-appimage/accel_spectra AppDir/usr/bin/
cp resources/accel_spectra.desktop AppDir/usr/share/applications/accel_spectra.desktop
cp resources/accel_spectra.png AppDir/usr/share/icons/hicolor/256x256/apps/accel_spectra.pngBuild the AppImage:
QMAKE=/usr/lib/qt6/bin/qmake6 resources/linuxdeploy-x86_64.AppImage \
--appdir AppDir \
--desktop-file AppDir/usr/share/applications/accel_spectra.desktop \
--icon-file AppDir/usr/share/icons/hicolor/256x256/apps/accel_spectra.png \
--plugin qt \
--output appimage-
Connect a compatible USB accelerometer or serial device.
-
Start AccelSpectra:
./build/accel_spectra
-
Select the serial port and click
Open. -
Choose the accelerometer sampling frequency and range.
-
Select the FFT window type, window size, and hop size.
-
Use the X, Y, and Z checkboxes to show or hide individual spectrum channels.
-
Use
StartandStopto control streaming on supported firmware.
accelerometer spectrum analyzer, accelerometer FFT, vibration spectrum analyzer, real-time FFT Qt, USB accelerometer software, serial accelerometer plotter, C++ Qt FFTW, motion sensor frequency analysis, tri-axis accelerometer visualization, Linux vibration analysis tool.
AccelSpectra is licensed under the GNU General Public License v3.0. See LICENSE for details.
Copyright (C) 2026 Electromake