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.
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
sample_rate=2_048_000, # 2.048 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 5 seconds
print("Collecting IQ data for 5 seconds...")
iq_data = client.read_samples_timeout(5.0)
# 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
print("Computing spectrogram and PSD...")
spectrogram, mean_psd, freq_axis, time_axis = sdr.plot(
data=iq_data,
sample_rate=config.sample_rate,
fft_size=1024
)
print("Analysis complete!")
print(f"Spectrogram shape: {spectrogram.shape}")
print(f"Frequency range: {freq_axis[0]:.2f} to {freq_axis[-1]:.2f} MHz")
print(f"Time range: 0 to {time_axis[-1]:.2f} seconds")
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
sample_rate=2_400_000, # 2.4 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
- Use Frequency Offset: Avoid DC spikes by offsetting from your target frequency
- Choose Appropriate Sample Rate: Balance between bandwidth and data size
- Monitor Connection: Use context managers or proper exception handling
- Data Format: Use uint8 for bandwidth efficiency, complex64 for precision
API Reference
SpyServerClient
connect(): Connect to SpyServerdisconnect(): Disconnect from SpyServerset_frequency(freq): Set center frequency in Hzset_sample_rate(rate): Set sample rate in Hzset_gain(gain): Set gain (None for auto)start_streaming(): Start IQ streamingstop_streaming(): Stop IQ streamingread_samples(n): Read n samplesread_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sdrconnect-0.1.0.tar.gz.
File metadata
- Download URL: sdrconnect-0.1.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5d5689a4d08ecb3a9070b744607ca2b2d6d4e7cb90b91ffe6d7b09001918152
|
|
| MD5 |
5ade7f439b5d61b3f217951bf34b7595
|
|
| BLAKE2b-256 |
4ac01b114efb4b9f588b493b11c15ee40954c0f23647172355e4d8dc729c9b36
|
Provenance
The following attestation bundles were made for sdrconnect-0.1.0.tar.gz:
Publisher:
pypi.yml on isakruas/sdrconnect
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sdrconnect-0.1.0.tar.gz -
Subject digest:
c5d5689a4d08ecb3a9070b744607ca2b2d6d4e7cb90b91ffe6d7b09001918152 - Sigstore transparency entry: 363365528
- Sigstore integration time:
-
Permalink:
isakruas/sdrconnect@e7ceefbc6f2a9f6649639d4a09d4c2d07b491cc5 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/isakruas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@e7ceefbc6f2a9f6649639d4a09d4c2d07b491cc5 -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file sdrconnect-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sdrconnect-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c70fd27d13f69d457dc803b409c25bfd22a5f0640e5d3043f670163e4c1665c
|
|
| MD5 |
429786f023bc67d2d4ee8f5d672231e3
|
|
| BLAKE2b-256 |
c295b03d788515d8df2a7c28c41a46135bf1d0cfc55a1e7f673d06fc863d1b11
|
Provenance
The following attestation bundles were made for sdrconnect-0.1.0-py3-none-any.whl:
Publisher:
pypi.yml on isakruas/sdrconnect
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sdrconnect-0.1.0-py3-none-any.whl -
Subject digest:
5c70fd27d13f69d457dc803b409c25bfd22a5f0640e5d3043f670163e4c1665c - Sigstore transparency entry: 363365540
- Sigstore integration time:
-
Permalink:
isakruas/sdrconnect@e7ceefbc6f2a9f6649639d4a09d4c2d07b491cc5 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/isakruas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@e7ceefbc6f2a9f6649639d4a09d4c2d07b491cc5 -
Trigger Event:
pull_request
-
Statement type: