Skip to main content

Modern Python library for SDR connectivity and data collection

Project description

SDRConnect

Modern Python library for SDR connectivity and data collection. Focused exclusively on connecting to SDR devices and collecting raw IQ data.

Latest Version

Features

  • SpyServer Support: Connect to SpyServer instances for remote SDR access
  • Modern Python: Built with Python 3.8+ and modern packaging standards
  • Simple API: Clean, intuitive interface for SDR data collection
  • Type Hints: Full type annotation support
  • Extensible: Easy to add new SDR backends

Installation

pip install sdrconnect

Quick Start

SpyServer Example

import sdrconnect as sdr
import numpy as np

# Create configuration for SpyServer
config = sdr.SDRConfig(
    host="localhost",  # Change to your SpyServer host
    port=5555,         # Change to your SpyServer port
    frequency=100_000_000,  # 100 MHz
    timeout=5.0
)

try:
    # Create and connect to SpyServer
    print("Connecting to SpyServer...")
    client = sdr.SpyServerClient(config)
    
    with client:
        # Set up the SDR
        client.set_frequency(config.frequency)
        client.set_sample_rate(config.sample_rate)
        client.set_gain(None)  # Auto gain
        
        # Start streaming
        print("Starting streaming...")
        client.start_streaming()
        
        # Collect data for duration_seconds seconds
        duration_seconds = 5.0
        print(f"Collecting IQ data for {duration_seconds} seconds...")
        iq_data = client.read_samples_timeout(duration_seconds)

        # Save data for later processing
        np.save("iq_data.npy", iq_data)
        
        print(f"Collected {len(iq_data)} IQ samples")
        print(f"Sample rate: {config.sample_rate} Hz")
        print(f"Center frequency: {config.frequency / 1e6:.1f} MHz")
        
        # Analyze the data
        spectrogram, mean_psd, freq_axis, time_axis, _ = sdr.analyze_signal(
            data=iq_data,
            sample_rate=config.sample_rate,
            fft_size=1024
        )
        
        print("Analysis complete!") 
        
except sdr.SDRConnectError as e:
    print(f"Connection error: {e}")
except Exception as e:
    print(f"Unexpected error: {e}")

Configuration

SDRConnect uses configuration objects for easy management:

# Create config
config = sdr.SDRConfig(
    host="localhost",
    port=5555,
    frequency=433_920_000,  # 433.92 MHz
    gain=20,                # Manual gain
    iq_format="complex64",  # or "uint8"
    timeout=30.0
)

# Save config
config.save("my_sdr_config.json")

# Load config
config = sdr.SDRConfig.load("my_sdr_config.json")

Supported SDR Devices

  • SpyServer: Remote SDR access via SpyServer protocol
  • RTL-SDR: Coming soon

Data Collection Best Practices

  1. Use Frequency Offset: Avoid DC spikes by offsetting from your target frequency
  2. Choose Appropriate Sample Rate: Balance between bandwidth and data size
  3. Monitor Connection: Use context managers or proper exception handling
  4. Data Format: Use uint8 for bandwidth efficiency, complex64 for precision

API Reference

SpyServerClient

  • connect(): Connect to SpyServer
  • disconnect(): Disconnect from SpyServer
  • set_frequency(freq): Set center frequency in Hz
  • set_sample_rate(rate): Set sample rate in Hz
  • set_gain(gain): Set gain (None for auto)
  • start_streaming(): Start IQ streaming
  • stop_streaming(): Stop IQ streaming
  • read_samples(n): Read n samples
  • read_samples_timeout(duration): Read for duration seconds

SDRConfig

Configuration class with validation and JSON serialization support.

Author

Isak Ruas - isakruas@gmail.com

License

Apache License 2.0 - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sdrconnect-0.1.1.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sdrconnect-0.1.1-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file sdrconnect-0.1.1.tar.gz.

File metadata

  • Download URL: sdrconnect-0.1.1.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sdrconnect-0.1.1.tar.gz
Algorithm Hash digest
SHA256 73d7ae36fbec365fd6e5c2c82fc6d574c2711cd2bb8309ba6c4fbef5f2be387d
MD5 9046a0480e150a3e95128e9a580837cc
BLAKE2b-256 ec3a4753f309af0a3612daea9d9defeb61e3c3c89ca137fd8d238c59cd97c5e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdrconnect-0.1.1.tar.gz:

Publisher: pypi.yml on isakruas/sdrconnect

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sdrconnect-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sdrconnect-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sdrconnect-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eb7867e32d265ec3a4b154b29cb18a884d580a9f8dad503a6b5d3a70c1819ac1
MD5 0e1ecb9f4efe18b613e615a47f8577f3
BLAKE2b-256 65de5688300ae68d017296d18aa291d911082e61070c2d2db6ba0f4c69a4e7c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdrconnect-0.1.1-py3-none-any.whl:

Publisher: pypi.yml on isakruas/sdrconnect

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page