Question 4.9: You want to convert your Raspberry Pi into a high-powered FM......

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 4-11).

4.11
Step-by-Step
The 'Blue Check Mark' means that this solution was answered by an expert.
Learn more on how do we answer questions.

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.

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.

Discussion

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.

Related Answered Questions

Question: 4.8

Verified Answer:

Download and run Open Arena (Figure 4-10) from the...
Question: 4.7

Verified Answer:

Mojang, the original developers of Minecraft, have...
Question: 4.11

Verified Answer:

Install the VLC media player by running the follow...
Question: 4.6

Verified Answer:

There are a number of emulators around for old gam...
Question: 4.10

Verified Answer:

Download and run the GNU image manipulation progra...
Question: 4.5

Verified Answer:

Download the motion software. This will allow you ...
Question: 4.4

Verified Answer:

The Pi Store is the Raspberry Pi equivalent of App...
Question: 4.3

Verified Answer:

You can use a number of browsers on the Raspberry ...
Question: 4.2

Verified Answer:

Raspberry Pi is, after all, a Linux computer, so t...
Question: 4.1

Verified Answer:

A Raspberry Pi actually makes a pretty good media ...