GNU Radio Embedded Python Block for RaspberryPi4 GPIO


Fig.1 GNU Radio Embedded Python Block to RPi4 GPIO

In many previous posts I have examined the use of the RTL-SDR with GNU Radio and on RaspberryPi4 (Ref.1/5). The combination makes an inexpensive, simple and rugged platform for the reception of a variety of signals. Figure 1 shows a typical implementation. The RTL-SDR is used to receive a Marine Weather signal at 162.4MHz on GNU Radio. An embedded Python Block can be designed to interface the GNU Radio schematic to communicate with the RPi GPIO. This is extremely useful and can be applied in many ways. A typical example would be to have a threshold circuit to trigger a LED when a signal of a given power or more is received.

GNU Radio Schematic Marine VHF Rx Threshold Detector

Fig.2 Marine VHF Receiver with Threshold Detector
Fig.3 Rx Spectrum & Threshold Opt & RMS Opt “Off” Frequency
Fig.4 Rx Spectrum & Threshold Opt & RMS Opt “On” Frequency

Figure 2 shows a GNU Radio schematic for the reception of Marine VHF weather on 162.4MHz. After the LPF, an RMS block evaluates the overall signal amplitude. A Threshold block is setup so that when tuned off frequency say at 160.4MHz, the output is “0” as in Figure 3. When tuned on frequency of 162.4MHz the output is “1” as in Figure 4. This logical block can then be used to feed the embedded Python to GPIO block.

Embedded Python Block

Fig.5 Python Code for Writing to RPi4 GPIO

In order for GNU Radio to communicate with the RPi GPIO, we have to write an embedded Python Block. Ref.6 is an excellent overview on how to do this by Wylie Standage-Beir. Ref.7 is from the GNU Radio Wiki for creating your first block. Basically I used the standard code written in the default GNU Radio Embedded Block and made some simple changes. The standard block multiplies the input by a constant. I removed the constant, removed the output, set the input to float32 and used the RPI.GPIO library.

Fig.6 YouTube Video GNU Radio Embedded Python Block for RaspberryPi4 GPIO

GNURadio Companion Basics Course:

Please send your comments, questions and suggestions to:

YouTube Channel
YouTube Channel


#1. – “RTL-SDR for Marine GMDSS/DSC on RaspberryPi4”

#2. – “RTL-SDR for RF Signal Capture in GNU Radio”

#3. – “RTL-SDR for VHF Air Band AM on GNU Radio”

#4. – “RTL-SDR for SSB on GNU Radio”

#5. – “RTL-SDR for AM on GNU Radio”

#6. – “Writing GNU Radio Blocks”

#7. – “Creating Your First Block”

By Jeremy Clark

Jeremy Clark is a Senior Telecommunications Engineer and Advanced Amateur Radio Operator VE3PKC. He is the author of E-Books on Telecommunications, Navigation & Electronics.