Member-only story
Python Radio 13: Software Defined Radio
Python listens to the radio.
If you do an Internet search for “SDR receiver price” you will find a large number of items for sale, from about $15 to $300. For our purposes (since we want to receive low frequencies as well as those above 30 MHz) we want receivers that can reach at least as low as 100 kilohertz. I have seen one for $18 that gets as low as 10 kilohertz.
What makes these devices special is the software on your computer that controls them and decodes the signals.
Another search, “SDR radio software” gets you a large number of software packages, most of them free, with names like SDR#, HDSDR, SDR-RADIO.COM, SDR++, Linrad, GQRX, CubicSDR, and many more.
There is also a Python library called pyrtlsdr, installed by the command pip install — upgrade pyrtlsdr[lib].
Using this library, the following program will pop up a spectrum display centered around the 7032000-hertz signal from our RP2040 CW transmitter:
from pylab import *
from rtlsdr import RtlSdr
import numpy as np
import scipy.signal as signal
import peakdetect
real_center_freq = 7.032e6
offset = 200e3
margin = 10e3
sdr = RtlSdr()
sdr.set_direct_sampling(1)
sdr.sample_rate = 225001
sdr.center_freq = real_center_freq - offset
sdr.gain = ‘auto’
num_samples = sdr.sample_rate
samples =…