Skip to content

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CLI hackrf_sweep Spectrum Analyzer

This is a real-time command line interface (CLI) spectrum analyzer for displaying the output of hackrf_sweep.

Features

  • Real-time spectrograph and waterfall display
  • Interactive keyboard controls (pause, peak hold, sensitivity adjustment)
  • Mouse support
  • Configurable power range and display settings
  • Terminal resize handling
  • Sub-pixel rendering for smooth visualization

Installation

pip install -r requirements.txt

Usage

Basic Usage

hackrf_sweep -a 1 -p1 -f 90:102 -w 50000 | ./spectrum_analyzer.py

Test Without Hardware

cat sample | ./spectrum_analyzer.py

Narrowing the Displayed Range

hackrf_sweep cannot sweep an arbitrarily narrow range. It tunes in 5 MHz steps and processes them two at a time, so the narrowest sweep it will produce is 20 MHz. Asking for -f 144:145 actually returns 144–164 MHz, and the analyzer plots everything it is given.

Use --min-freq / --max-freq (in MHz) to clip the display to the slice you actually want:

hackrf_sweep -a 1 -p1 -f 144:145 -w 50000 | ./spectrum_analyzer.py --min-freq 144 --max-freq 145

Narrowing the range also raises resolution: the same terminal width now spans 1 MHz instead of 20 MHz.

Choosing -w for a narrow slice

-w is the FFT bin width in Hz, and it decides how many real data points land in your window. hackrf_sweep splits each 5 MHz block into 5000000 / w bins, so:

-w bin spacing bins across 74 kHz
50000 50 kHz ~1.5
10000 10 kHz ~7
5000 5 kHz ~15
2445 2.445 kHz ~30

At the default -w 50000 a 74 kHz window contains only one or two bins, so most columns have no data behind them. Use a small -w when zooming in:

hackrf_sweep -a 1 -p1 -f 14:15 -w 2445 | ./spectrum_analyzer.py --min-freq 14.0 --max-freq 14.074

2445 Hz is the hardware minimum (-w accepts 2445–5000000), which caps resolution at ~30 points across 74 kHz. The display interpolates between available bins so the waterfall stays smooth, but it cannot invent detail the radio did not sample — for finer resolution than this, hackrf_sweep is the wrong tool and you want a tuned narrowband capture instead.

Command Line Options

./spectrum_analyzer.py --help
./spectrum_analyzer.py --fps 30 --min-power -90 --max-power -30
./spectrum_analyzer.py --height 10 --verbose

Available options:

  • --fps FPS - Frame rate (default: 16)
  • --min-power MIN_POWER - Minimum power in dBm (default: -100.0)
  • --max-power MAX_POWER - Maximum power in dBm (default: -20.0)
  • --height HEIGHT - Spectrograph height in lines (default: 5)
  • --min-freq MIN_FREQ - Lowest frequency to display, in MHz (default: no limit)
  • --max-freq MAX_FREQ - Highest frequency to display, in MHz (default: no limit)
  • --verbose, -v - Enable verbose debug logging
  • --log-file LOG_FILE - Debug log file path (default: debug.log)

Interactive Controls

While running, you can use these keyboard shortcuts:

  • q - Quit
  • p - Pause/Resume
  • h - Toggle help screen
  • m - Toggle peak hold mode
  • + - Increase sensitivity (narrow power range)
  • - - Decrease sensitivity (widen power range)

Mouse support is enabled for future features.

Screenshot

alt text

About

CLI Spectrum Analyzer for output from `hackrf_sweep`.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages