Created
October 25, 2021 17:24
-
-
Save AndrewBarfield/d62b52ec42744cca58b63342870f216b to your computer and use it in GitHub Desktop.
Scan region of RF spectrum using rtl_power_fftw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
reset | |
# FFT bin size for a sample rate of 2,400,000 Hz: | |
# | |
# Bin Count Bin Width (Hz) Bin Width (kHz) | |
# 4 600,000.000 600.000 | |
# 8 300,000.000 300.000 | |
# 16 150,000.000 150.000 | |
# 32 75,000.000 75.000 | |
# 64 37,500.000 37.500 | |
# 128 18,750.000 18.750 | |
# 256 9,375.000 9.375 | |
# 512 4,687.500 4.688 | |
# 1,024 2,343.750 2.344 | |
# 2,048 1,171.875 1.172 | |
# 4,096 585.938 0.586 | |
# 8,192 292.969 0.293 | |
# 16,384 146.484 0.146 | |
# 32,768 73.242 0.073 | |
# 65,536 36.621 0.037 | |
# 131,072 18.311 0.018 | |
# 262,144 9.155 0.009 | |
# 524,288 4.578 0.005 | |
# 1,048,576 2.289 0.002 | |
# rtl_power_fftw parameters | |
SAMPLE_RATE=2400000 | |
FFT_SIZE=1024 | |
START_FREQ=929000000 | |
STEP=$(($SAMPLE_RATE / 2)) | |
END_FREQ=939000000 | |
INTEGRATION_TIME=86400 | |
# Working and output paths | |
BASE_PATH="/workdrive/rtl_power_fftw/plot/" | |
WORK_PATH="$BASE_PATH/$START_FREQ-$END_FREQ" | |
# Exit if base path doesn't exist | |
if [[ ! -e $BASE_PATH ]]; then | |
echo "Base path doesn't exist! Exiting." | |
exit | |
fi | |
# Create work path if needed | |
mkdir -p $WORK_PATH | |
# Show frequency hops | |
for i in `seq $START_FREQ $STEP $END_FREQ`; | |
do | |
echo "Tune to $i for $INTEGRATION_TIME seconds" | |
done | |
# Do it | |
for i in `seq $START_FREQ $STEP $END_FREQ`; | |
do | |
./rtl_power_fftw -b $FFT_SIZE -f $i -g 496 -r $SAMPLE_RATE -t $INTEGRATION_TIME | \ | |
tee "$WORK_PATH/$i.txt" | \ | |
gnuplot -e "set term pngcairo size 1600,900; \ | |
set key font ',8'; \ | |
set xtics font 'Verdana,8'; \ | |
set format x '%.3s%c'; \ | |
unset key; \ | |
set xtics 125000; \ | |
set grid x y; \ | |
show grid; \ | |
set yrange [-70:0]; \ | |
plot '-' w l" > "$WORK_PATH/$i.png" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment