LinuxCommandLibrary

rtl_sdr

Receive radio signals using software defined radio

TLDR

Save RAW data from a frequency (specified in Hz) to a file

$ rtl_sdr -f [100000000] [path/to/file]
copy

Pipe data to another program
$ rtl_sdr -f [100000000] - | [aplay]
copy

Read a specified number of samples
$ rtl_sdr -f [100000000] -n [20] -
copy

Specify the sample rate in Hz (ranges 225001-300000 and 900001-3200000)
$ rtl_sdr -f [100000000] -s [2400000] -
copy

Specify the device by its index
$ rtl_sdr -f [100000000] -d [0] -
copy

Specify the gain
$ rtl_sdr -f [100000000] -g [20] -
copy

Specify the output block size
$ rtl_sdr -f [100000000] -b [9999999] -
copy

Use synchronous output
$ rtl_sdr -f [100000000] -S -
copy

SYNOPSIS

rtl_sdr [options] [filename]

PARAMETERS

-f freq
    Set center frequency in Hz. Supports common suffixes like 'M' for MHz (e.g., 100M for 100,000,000 Hz).

-s samplerate
    Set sample rate in Hz. Typical values range from 250,000 to 3,200,000 samples per second. Higher rates capture wider bandwidths.

-g gain
    Set tuner gain in dB. Use 'rtl_sdr -g' without a value to list available discrete gain settings for your device. Default is often automatic gain control (AGC).

-d index
    Select RTL-SDR device by index (e.g., 0, 1, 2...). Useful when multiple dongles are connected to the system.

-p ppm
    Set frequency correction in PPM (parts per million). Used to compensate for inaccuracies in the dongle's crystal oscillator, which can cause frequency drift.

-n samples
    Read only the specified number of samples and then exit. Useful for capturing short bursts of data or for testing.

-b bytes
    Set the USB transfer buffer length in bytes. Default is usually 262144 bytes. A smaller buffer may reduce latency but increase CPU load.

-E mode
    Enable RTL2832 test mode or specialized sampling modes. Common modes include 'direct_samp' for direct sampling of HF signals or 'offset_tuning' for baseband IQ correction.

-F
    Enable direct sampling mode (requires hardware modification or specific dongle versions). Bypasses the tuner for direct sampling of signals, typically used for HF (below 30 MHz).

-A
    Enable automatic gain control (AGC) if not already the default. This allows the device to automatically adjust gain for optimal signal reception.

-R
    Reset the RTL2832 chip. Can sometimes resolve issues with the dongle not being recognized or functioning correctly after previous use.

-T
    Enable Bias-T output. Provides DC power (typically 5V) through the antenna input to power external low-noise amplifiers (LNAs) or active antennas.

-S
    Enable read sync. Attempts to synchronize the reading process with the start of new sample buffers from the device, potentially reducing jitter.

-h
    Display a help message with available options and exit.

DESCRIPTION

The rtl_sdr command is a fundamental tool within the rtl-sdr software suite, enabling users to transform inexpensive DVB-T USB dongles based on the Realtek RTL2832U chipset into powerful Software-Defined Radio (SDR) receivers. It serves as the primary interface for configuring the dongle's parameters, such as center frequency, sample rate, and gain, and for capturing raw complex I/Q (In-phase and Quadrature) data streams. This raw data, typically in a byte-stream format, can then be processed by other SDR applications, visualized, or saved to a file for later analysis, forming the backbone of many SDR experiments and applications.

CAVEATS

Optimal performance with rtl_sdr is highly dependent on antenna quality, appropriate gain settings, and accurate frequency correction (PPM). High sample rates, especially on less powerful systems or over busy USB buses, can lead to dropped samples or buffer underruns, indicated by warnings or gaps in the received data. Ensure sufficient USB bandwidth is available.

OUTPUT FORMAT

The command outputs raw I/Q samples to standard output (stdout) or to a specified file if a filename argument is provided. The data consists of interleaved 8-bit unsigned I and Q values (e.g., I1, Q1, I2, Q2, ...), representing the complex baseband signal. This raw binary format is designed to be easily piped into other signal processing tools or saved for later analysis.

TYPICAL USAGE

rtl_sdr is frequently used as the source for a data pipeline, with its output streamed directly to other programs for demodulation, decoding, or visualization.

Example: Capture FM radio and pipe to SoX for audio playback
rtl_sdr -f 96.1M -s 2.048M -g 40 - | sox -t raw -e signed-integer -b 16 -c 2 -r 2.048M - -t raw -e signed-integer -b 16 -c 1 -r 48k - highpass 200 lowpass 3k | play -

Example: Record raw I/Q data to a file
rtl_sdr -f 433.92M -s 2.4M -g 30 out.iq

HISTORY

The rtl_sdr utility is a cornerstone of the original rtl-sdr project. Its genesis dates back to 2012 when the discovery was made that inexpensive DVB-T USB dongles, primarily those using the Realtek RTL2832U chip, could be repurposed as versatile Software-Defined Radio receivers. This breakthrough, along with the rapid development of open-source drivers and command-line tools like rtl_sdr, democratized access to SDR technology, leading to an explosion of interest and innovation in radio hobbyism, research, and various applications worldwide.

SEE ALSO

rtl_fm(1), rtl_tcp(1), gnuradio(1), sox(1)

Copied to clipboard