Raspberry Pi Simplex Repeater

 

The PeaterPiPyr – a simplex repeater using the Raspberry Pi

PagerPiPyr

This page describes how to use at $25-$35 Raspberry Pi single board computer, a USB sound card, some Python code, and a two-way radio to create a simplex repeater.  A simplex repeater is also known as a store-and-forward voice repeater.  Unlike a traditional duplex repeater that receives and transmits at the same time on two different frequencies, a simplex repeater first receives a voice message, stores it, and then retransmits it out.  Often this is done on a single frequency, although it can be done using different frequencies for receive and transmit.  The advantage of a simplex repeater is that it is very small and compact, since no complex tuned filter cavities are needed.  The disadvantage is that there is a delay between when a user speaks and when their message is repeated, and this can lead to confusion and “doubling” unless all operators are well-disciplined and understand how the system functions.

Overview

The Raspberry Pi is a single board computer that runs Linux.  A Python script uses PyAudio to read in audio from an attached USB sound card, which is in turn attached to the audio output of the two-way radio. When audio is detected, the script will record audio until a silence of predetermined duration is detected, and will then key up the radio (using a GPIO pin on the Raspberry Pi) and replay the audio to the radio’s microphone input.  The video below shows the system in action.

PeaterPiPyr

Getting Started

Hardware

To interface the Raspberry Pi with a two-way radio, you need to connect the audio output of the radio to the audio input of the Pi and vice versa.  You also need an interface circuit to allow one of the General Purpose I/O (GPIO) pins of the Raspberry Pi to key the push to talk (PTT) line of the radio.  Below are example schematics for interfacing the Raspberry Pi with Icom and Kenwood handheld radios.  Other radios should be similar to one of these.

PiRadioInterface

Future versions of the PeaterPiPyr will also include provisions to use the COR output of a radio to trigger recording, but for now it is audio level triggered (VOX operation).

Software

To get started using your Raspberry Pi as a simplex repeater, first follow the steps on this page to get your Pi configured and to install the necessary prerequisites.  If you follow the steps on that page you’ll end up installing a few things you don’t really need for the PeaterPiPyr, but that’s ok.

Once you have all of the prerequisites installed, you can download the source files here.  Simply and copy this tarball into a directory on your Pi and uncompress it:

tar zxf PeaterPiPyr2.tgz

There are some parameters that you’ll need to set up by editing the config.cfg file.  You can do this by using the built-in nano editor (from the command line) or Leafpad (in the XWindows GUI).  Before editing the config.cfg file, you’ll need to determine the index of the pulseaudio input and output so that you can set the input_device_index and output_device_index parameters accordingly.  You’ll also need to determine what level to set the audio_threshold parameter to.  To help with these tasks, I’ve include a LevelMeter utility.  To start it, navigate to your PeaterPiPyr directory and type:

python LevelMeter.pyc

The utility will list all of your input and output sound devices.  You want to find the input and output named pulse.  Make note of the index (number) of these, as this is what you’ll want to specify for the input_device_index and output_device_index in your config.cfg file.

Enter in the index corresponding to pulse for the input and output, and the utility will start taking audio samples and printing the audio level to the console window.  Make note of what the audio levels are with no audio input present, and also with audio present.  You’ll want to set your audio_threshold parameter to be somewhat above the levels you see with no audio present, but not so high as to be above the levels when audio is present.  You can adjust the audio of your scanner or radio using this utility as needed.  To stop the audio sampling and terminate the LevelMeter utility, hit CTRL-C.

Now that you now what the input_device_index, output_device_index, and audio_threshold parameters should be set to, you can edit the config.cfg file.  Here are the parameters in the config.cfg file and what they mean:

  • audio_threshold – Minimum level of audio signal to trigger a recording
  • trigger_time – Number of seconds that the received audio must be above the audio_threshold parameter before a recording will start
  • record_seconds  – Minimum number of seconds of audio to record after a valid trigger is found (default is zero)
  • release_time – Number of seconds that the received audio must be below the audio_threshold parameter before the recording will stop and replay will start (default is two seconds)
  • input_device_index – index of audio input device
  • output_device_index – index of audio output device

Once you have the config.cfg file set up correctly, you can start PeaterPiPyr by typing:

python PeaterPiPyr2.py

USB Audio Input Issues

The USB audio support on the Raspberry Pi still has some issues.  See this forum thread for more information.  To solve this, I had to add this line to the /boot/cmdline.txt file:

dwc_otg.speed=1

After doing this my USB mouse and keyboard stopped working, so I had to access my Pi via PuTTY using SSH.  However, this fixed my audio issues and made TwoToneDetect work well.

To Do List

  • Add provisions for playing courtesy beep at the end of the repeated transmission
  • Change audio handling to use ALSA instead of pulseaudio to simplify installation and allow the program to run as sudo so that external TX.py and RX.py files aren’t needed
  • Add handling for COR input as an option in place of VOX operation
  • Add a max record time (time out timer) parameter