Sieradelta
Newbie
- Joined
- Nov 12, 2023
- Messages
- 2
I have raspberry pi with raspbian os. i also have Noo elec E4000 NESDR and XTR software defined radio. I have written a bash code that should scan the frequencies from 90MHz to 95MHz and note down the frequencies having transmission peaks with in a txt file that is saved on the desktop with real time update. the time of detection should also be mentioned against each detected frequencies along with its power level. the output txt file should also show that which frequency is being currently scanned by the sdr and any transmission is detected against the same or not. The script is as follows:
#!/bin/bash
# Output file on the desktop
output_file="$HOME/Desktop/frequency_scan.txt"
# Frequency range and step size
start_freq=90000000 # 90 MHz
end_freq=95000000 # 95 MHz
step_size=25000 # 25 KHz
# SDR parameters
sample_rate=0.025M
gain=0
scan_duration=5 # 60 seconds per frequency (adjust as needed)
# Create the output file (or clear it) at the beginning
echo -n > "$output_file"
# Continuously scan the frequency range
while true; do
for ((freq = start_freq; freq <= end_freq; freq += step_size)); do
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
printf "Scanning %d Hz at %s... " "$freq" "$timestamp"
# Scan frequency for the specified duration and log the result
scan_result=$(timeout "$scan_duration" rtl_power -f "$freq":"$freq" -g "$gain" -s "$sample_rate" -c 0 -q -)
# Check if power level is above a certain threshold (adjust as needed)
if [ -n "$scan_result" ]; then
power=$(echo "$scan_result" | awk '{print $2}')
if [ "$power" -ge 0 ]; then
signal_status="Signal Detected"
else
signal_status="No Signal"
fi
else
signal_status="No Signal"
fi
# Log the time, scanned frequency, power, and signal status to the output file
echo "$timestamp, $freq Hz, Power: $power dB, $signal_status" >> "$output_file"
done
done
the script is creating the ouput files with all details but not recording the peak frequencies with transmission and their power levels. every time its showing " No Signal Detected" even if the FM radio channels are working in this range of frequencies.
Can somone please help?
#!/bin/bash
# Output file on the desktop
output_file="$HOME/Desktop/frequency_scan.txt"
# Frequency range and step size
start_freq=90000000 # 90 MHz
end_freq=95000000 # 95 MHz
step_size=25000 # 25 KHz
# SDR parameters
sample_rate=0.025M
gain=0
scan_duration=5 # 60 seconds per frequency (adjust as needed)
# Create the output file (or clear it) at the beginning
echo -n > "$output_file"
# Continuously scan the frequency range
while true; do
for ((freq = start_freq; freq <= end_freq; freq += step_size)); do
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
printf "Scanning %d Hz at %s... " "$freq" "$timestamp"
# Scan frequency for the specified duration and log the result
scan_result=$(timeout "$scan_duration" rtl_power -f "$freq":"$freq" -g "$gain" -s "$sample_rate" -c 0 -q -)
# Check if power level is above a certain threshold (adjust as needed)
if [ -n "$scan_result" ]; then
power=$(echo "$scan_result" | awk '{print $2}')
if [ "$power" -ge 0 ]; then
signal_status="Signal Detected"
else
signal_status="No Signal"
fi
else
signal_status="No Signal"
fi
# Log the time, scanned frequency, power, and signal status to the output file
echo "$timestamp, $freq Hz, Power: $power dB, $signal_status" >> "$output_file"
done
done
the script is creating the ouput files with all details but not recording the peak frequencies with transmission and their power levels. every time its showing " No Signal Detected" even if the FM radio channels are working in this range of frequencies.
Can somone please help?
Last edited: