I'm able to capture signals from a RTL-SDR by using the following:
from rtlsdr import *
i = 0
signals = []
sdr = RtlSdr()
sdr.sample_rate = 2.8e6
sdr.center_freq = 434.42e6
sdr.gain = 25
while True:
samples = sdr.read_samples(1024*1024)
decibel = 10*log10(var(samples))
if decibel >= -10:
signals.append(samples)
i += 1
if i == 2:
break
If I plot the signals using Matplotlib and Seaborn, they look something like this:
Now, what I would need is to get the coordinates of all peaks above a certain power level, e.g., -20.
I found a rather promising listing of the various Python options. However, all those examples use a simple Numpy array which the different algorithms can easily work with.
This was the best attempt (because my guess is that I get a complex signal from the RTL-SDR and have to "transform" it to an array with real values?):
import numpy as np
import peakutils.peak
real_sig = np.real(signals[0])
indexes = peakutils.peak.indexes(real_sig, thres=-20.0/max(real_sig), min_dist=1)
print("Peaks are: %s" % (indexes))
With these few lines added to the script above I do get some output, but, first, there are way too many values for the just five peaks above power level -20. And, second, the values don't make much sense in the given context.
So, what do I need to change to get meaningful results like "Peak 1 is at 433.22 MHz"?
Ideally, I should get coordinates like Peak 1: X = 433.22, Y = -18.0
, but I guess I can figure that out myself once I know how to get the correct X-values.