Discuss on GitHub

Raspberry Pi Radio Transmitter


You want to convert your Raspberry Pi into a high-powered FM transmitter that will send a radio signal to a normal FM radio receiver (Figure 1-1).


The clever folks at Imperial College London have created some C code and a Python wrapper that allow you to do just this. The download even includes the theme from Star Wars to play as a sample.

All you need is a short length of wire attached to GPIO pin 4. A female-to-male header lead will work just fine for this. In fact, it should work with the radio right next to your Pi without any kind of antenna—such is the strength of the transmission.

Figure 1-1. Raspberry Pi as an FM transmitter

The first step is to install the pifm library using the following commands:

$ mkdir pifm
$ cd pifm
$ wget http://www.icrobotics.co.uk/wiki/images/c/c3/Pifm.tar.gz
$ tar -xzf Pifm.tar.gz

Next, find yourself an FM radio receiver and tune it to 103.0 MHz. If this frequency is already occupied by some other transmission, pick another frequency and make note of it.

Now run the following command (changing the final parameter from 103.0 to a different frequency if you had to change frequency):

sudo ./pifm sound.wav 103.0

If all is well, you should hear the stirring tones of the Star Wars theme.


You need to know that this project may not be legal in your country. The power output is higher than that of FM transmitters used with MP3 players.

You can play other .wav files, but they must be 16-bit 44.1kHz mono.

The code also includes a Python library that you can use within your own Python programs. So, you could write yourself a user interface to allow the selection and playing of tunes.

The following fragment of code illustrates the use of the Python interface:

pi@raspberrypi ~/pifm $ sudo python
Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PiFm
>>> PiFm.play_sound("sound.wav")

Were you to put a Raspberry Pi in your vehicle, this would be a great way of outputting sound through the vehicle’s audio system.

See Also

This description is based on the original post from Imperial College London.