B Z
B Z

Reputation: 3

Having trouble with rtl-sdr-v4 frequency scanner

I am attempting to make a frequency scanner that outputs an array of frequencies but I do not know how to do anything with any of these libs as I'm not an advanced Python programmer anymore, main problem is the array is outputting from -400 to 400 and even when I get it to do 0 - a positive number the positive max number is higher than the amount of samples in passing through, how is this possible?

import numpy as np
import matplotlib.pyplot as plt
from rtlsdr import RtlSdr
from scipy.signal import find_peaks
import time

SDR = RtlSdr()
StepSize = 10
Start = 1000
Stop = 1250

# CONFIGURATION
SDR.sample_rate = 1.024e6
SDR.gain = 'auto'

Frequencies = np.arange(Start, Stop, StepSize)
plt.figure(figsize=(10, 6))

for Frequency in Frequencies:
  print(Frequency)
  SDR.center_freq = Frequency
  Samples = SDR.read_samples(256*1024)
  Spectrum = np.abs(np.fft.fftshift(np.fft.fft(Samples)))
  MoreFrequencies = np.fft.fftfreq(len(Spectrum), 1/SDR.sample_rate)
  plt.plot(MoreFrequencies / Start + (Frequency / Start), Spectrum)

plt.title('Frequency Scan from 0Hz to 1KHz')
plt.xlabel('Frequency (KHz)')
plt.ylabel('Power')
plt.grid(True)
plt.show()

I tried to use numpy and matplot.

Upvotes: 0

Views: 31

Answers (0)

Related Questions