E310 FM Receiver: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
No edit summary
No edit summary
Line 112: Line 112:
</syntaxhighlight>
</syntaxhighlight>


:This runs a remote startup script on the USRP when you press “Execute.
: This single command performs two actions back-to-back: first, it securely transfers the file you’re editing to the USRP’s temporary directory over SSH; then, once that transfer completes successfully, it opens an SSH session on the USRP and immediately invokes Python 3 to run the uploaded file from its temporary location. In other words, it bundles “copy the script over” and “execute it remotely” into one seamless operation.


=== c. Create the '''start_usrp_script.sh''' Script ===
=== c. Create the '''start_usrp_script.sh''' Script ===

Revision as of 10:46, 30 June 2025

Beginner Tutorials

Introducing GNU Radio

  1. What is GNU Radio?
  2. Installing GNU Radio
  3. Your First Flowgraph

Flowgraph Fundamentals

  1. Python Variables in GRC
  2. Variables in Flowgraphs
  3. Runtime Updating Variables
  4. Signal Data Types
  5. Converting Data Types
  6. Packing Bits
  7. Streams and Vectors
  8. Hier Blocks and Parameters

Creating and Modifying Python Blocks

  1. Creating Your First Block
  2. Python Block With Vectors
  3. Python Block Message Passing
  4. Python Block Tags

DSP Blocks

  1. Low Pass Filter Example
  2. Designing Filter Taps
  3. Sample Rate Change
  4. Frequency Shifting
  5. Reading and Writing Binary Files

SDR Hardware

  1. RTL-SDR FM Receiver
  2. B200-B205mini FM Receiver
  3. E310 FM Receiver

This tutorial describes how to receive broadcast commercial radio stations transmitting Frequency Modulated (FM) signals using the Ettus Research E310.

USRP (E310) Setup Guide

This page provides step-by-step instructions to configure a USRP E310 for:

  • Receiving signals with a Python script
  • Remote control via SSH
  • Using GNU Radio on a host machine

1. Hardware Connection

  • Plug the antenna into the RX2-A port on the USRP. The RX2-A port is dedicated to receive (RX) operations.
  • Turn on the USRP and ensure it has a stable power supply.

2. Determine the USRP’s IP Address

On your host machine (connected to the same network):

sudo snap install nmap    # Install nmap if not already present
nmap -sn 10.0.0.0/24      # Scan the local subnet
This finds the DHCP‑assigned IP of the USRP (e.g., 10.0.0.100).

3. Assign a Static IP Address

To simplify SSH access, give the USRP a fixed IP.

a. Create the static_ip.sh Script

SSH into the USRP (using the DHCP IP) and run:

nano static_ip.sh

Paste the following:

#!/bin/sh

# 1. Flush existing IP addresses
ip addr flush dev eth0

# 2. Assign static IP and netmask
ip addr add 10.0.0.200/24 dev eth0

# 3. Bring the interface up
ip link set eth0 up

# 4. Add default gateway
ip route add default via 10.0.0.1
Each step configures the Ethernet interface (eth0) for static addressing.

b. Run the Script

bash static_ip.sh
The IP remains active until the next reboot.

4. SSH Connection

On the host:

ssh root@10.0.0.200
You now have remote shell access to the USRP.

5. Mount USRP Filesystem via SSHFS

To edit USRP files locally:

sshfs root@10.0.0.200:/ ~/remote_usrp
Mounts the USRP’s root directory at `~/remote_usrp` on the host.

6. Configure Geany IDE

To simplify the workflow, we will use Geany, a lightweight IDE, on the host machine to:

  • Edit files located on the USRP (via SSHFS)
  • Launch scripts remotely on the USRP (via SSH)
  • Centralize all development and execution within one interface
This allows you to work entirely from the host, avoiding the need to manually SSH into the USRP or use a separate editor.


a. Open Build Commands

In Geany, go to Build → Set Build Commands.

b. Update the Build Commands

In "Set Independent Commands", to the right of "Run Remote", add:

scp "%f" root@10.67.44.142:/tmp/ && ssh root@10.67.44.142 'python3 /tmp/"%f"'
This single command performs two actions back-to-back: first, it securely transfers the file you’re editing to the USRP’s temporary directory over SSH; then, once that transfer completes successfully, it opens an SSH session on the USRP and immediately invokes Python 3 to run the uploaded file from its temporary location. In other words, it bundles “copy the script over” and “execute it remotely” into one seamless operation.

c. Create the start_usrp_script.sh Script

On the USRP:

nano /home/root/start_usrp_script.sh

Paste:

#!/bin/sh

# Cleanup function on interrupt
cleanup() {
    echo "[INFO] Stop requested"
    pkill -f usrp_fm_receiver.py
    exit 0
}

# Trap INT and TERM signals
trap cleanup INT TERM

# Launch the main Python script
python3 /home/root/usrp_fm_receiver.py
Ensures the Python process is cleanly terminated on exit.

7. Running the Flow

  1. In Geany, open `~/remote_usrp/home/root/usrp_fm_receiver.py`.
  2. Press “Execute” to start the script on the USRP.
  3. On your host, launch GNU Radio Companion and run `fm_receiver_host_udp.py` to receive the UDP stream.
The USRP script streams FM over UDP; GNU Radio handles it on the host side.

Additional Notes

  • To make the IP configuration persistent, consider adding `static_ip.sh` to `/etc/rc.local` or creating a `systemd` service.
  • Verify compatibility of Python and GNU Radio versions between the USRP and host.
  • IP addresses have been anonymized, but this obviously needs to be adapted to the use case.

Last updated: 30 June 2025