It came to my mind that it's possible that the chip I use can/does not update it's center frequency during operation.
So I edited the code to reinitialize the device completly for each step in the for-loop.
Here is the new loop:
for i in np.arange(50, 1000, SAMPLERATE/1e6):
sdr = RtlSdr()
# configure device
sdr.sample_rate = SAMPLERATE
sdr.center_freq = i*1e6 # Hz
sdr.freq_correction = 60 # PPM
sdr.gain = 'auto' # 4
samples = sdr.read_samples(8*1024)
sdr.close()
sdr = None
# use matplotlib to estimate and plot the PSD
power, psd_freq = mlab.psd(samples, NFFT=1024, Fs=SAMPLERATE /
1e6)
psd_freq = psd_freq + i
powe = np.concatenate((powe, np.array(power)))
freq = np.concatenate((freq, np.array(psd_freq)))
print(f"{i}/1000")
The print statement at the end is just to keep track of how long it's going to take. This bit ran for about 7 minutes, because it is very slow to reinitialize like this all the time. There has to be a better way...
I'll keep searching for that. During that time you can enjoy the new output:
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
You could try using the set_center_freq function on the sdr object.
Or possibly part of the problem could be https://github.com/roger-/pyrtlsdr/issues/84
Are you sure? yes | no