Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

usrp-power

rtl_power, but for a USRP.

Stepped-tune power spectrum sweeps using the UHD Python API, writing rtl_power-compatible CSV. Built for a B210 doing 900 MHz band surveys, but nothing in it is B210-specific beyond the defaults.

Two scripts, no GNU Radio flowgraph required:

  • usrp_power.py — sweeps a frequency range, Welch PSD per step, CSV out
  • plot_power.py — CSV to PNG: peak-hold trace, waterfall, band overlay
python3 usrp_power.py -f 850M:960M -g 40 -i 0.25 -c 10 -o survey.csv
python3 plot_power.py survey.csv

The output plot shades known allocations (ISM, cellular, paging) so you can tell at a glance what class of thing you're looking at, and prints a peak table with SNR.

Requirements

  • UHD with Python bindings (import uhd)
  • NumPy, Matplotlib

NumPy 2.x will break UHD's Python bindings if libpyuhd was compiled against NumPy 1.x — you'll see AttributeError: _ARRAY_API not found. Either pin numpy<2, or check for a stray user-level install shadowing your system one:

python3 -c "import numpy; print(numpy.__version__, numpy.__file__)"
pip uninstall numpy   # if it resolves to ~/.local

Matplotlib is only needed for plotting, and the two scripts communicate solely through CSV — so if you're stuck in NumPy dependency hell you can capture in a numpy<2 venv and plot with system Python.

Output format

rtl_power-compatible, so existing tooling (heatmap.py et al.) will also read it:

date, time, Hz_low, Hz_high, Hz_step, num_samples, dB, dB, dB, ...

Values are dBFS, uncalibrated — a constant offset from true power, so relative comparisons across a sweep are valid but absolute levels are not. An on-bin full-scale sinusoid reads 0.00 dBFS.

Design notes

The B210 is a direct-conversion (zero-IF) receiver, so LO leakage puts a spike at DC — dead center of every capture. Two mitigations:

  1. The LO is offset via a UHD tune request, moving the spike off center.
  2. Only the center --keep fraction (default 0.75) of each capture is retained, which discards the spike along with the analog filter rolloff at the band edges.

If you see spikes at regular intervals equal to rate x keep, that's residual LO leakage rather than signal.

Step dwell is --integrate seconds; frames are averaged (Welch) to trade time for variance. Overflows are counted and reported — if you get them, lower --rate. USB2 tops out well below USB3, check with lsusb -t.

Testing without hardware

python3 usrp_power.py -f 860M:955M --simulate -c 5 -o fake.csv
python3 plot_power.py fake.csv

Synthesizes noise plus CW tones at 868.3 / 902.5 / 915.0 / 927.0 / 947.4 MHz. If the peak table doesn't report those back at the right frequencies and amplitudes, the DSP/CSV path is broken rather than your radio.

Options

usrp_power.py
  -f, --freq       sweep range, e.g. 850M:960M
  -g, --gain       RX gain dB (B210: 0-76, typically 30-50 on a bare whip)
  -r, --rate       sample rate per step (default 5M; raise only on USB3)
  -n, --nfft       FFT size (default 1024)
  -i, --integrate  seconds of IQ averaged per step
  -c, --count      sweeps; 0 = until Ctrl-C
      --keep       fraction of each capture retained (default 0.75)
  -a, --antenna    RX2 or TX/RX
  -A, --args       UHD device args (default type=b200)
      --agc        hardware AGC instead of fixed gain
      --simulate   synthetic data, no radio

plot_power.py
  -o, --output     output PNG
      --region     us | eu | none  (which band chart to overlay)
      --top        number of peaks to label
      --min-snr    dB above floor to count as a signal
      --min-sep    MHz guard band between reported peaks

--agc makes levels non-comparable across steps, so fixed gain is the right default for survey work.

Legal note

Passive spectrum observation is broadly fine. Decoding the content of communications you aren't a party to is not, in most jurisdictions — in the US that's the Wiretap Act and 47 USC 605. Signal identification, power levels, metadata, and your own devices are the safe territory.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages