HowTo: Raspberry Pi – Send FM signals via GPIO pin

The RaspberryPi can also be used to send audio files and even entire texts via FM signal thanks to a technical trick and suitable script – without additional hardware (apart from a piece of wire). This will turn your RaspberryPi into a small radio station.

How to do that and what you have to keep in mind is described in this article

Hints for our lovely english readers: Basically, many of the articles on Nerdiy.de are translations from the original german articles. Therefore, it may happen here and there that some illustrations are not available in english and that some translations are weird/strange/full of mistakes or generally totaly wrong. So if you find some obvious (or also not obvious) mistakes don't hesitate to leave us a hint about that in the comment section. 
Also please don't get confused, that instead of a "dot" often a "comma" is used as decimal separator. 🙂


Safety instructions

I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/sicherheitshinweise/

Affiliate links / advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂


Requirements

Helpful Articles:
Before you start with this article, you should have prepared the RaspberryPi so far that it can be reached via the network and controlled by SSH.

The following three articles describe what to do to prepare the RaspberryPi:
RaspberryPi – Setting up for Nerdiys!
RaspberryPi – The first configuration
RaspberryPi – Controlling the RaspberryPi via SSH

Required tools:
-none-

Required material:

In the following list you will find all the parts you need to implement this article.


Important words in advance

Sending FM signals (and many others) over unauthorized radio transmitters is not legal in Germany and in many other countries. The method shown below allows you to do just that. Please use it responsibly. Above all, make sure that you do not disturb regular radio stations. The method shown is comparatively powerful and radiates to even in other frequency range. That means that you can easily attract the displeasure of your neighbors and thus of the Federal Network Agency/ies.


Connecting/Preparing the antenna

As an antenna you can basically use any wire you have available. Important is only the length. The wire must be about 20cm long.

In the example below I have taken a rigid wire (so no flexible wire) and then crimped it on a Dupont connector. In principle, you can also use any other “simple” dupont cable.

The required parts: 20cm long wire, RaspberryPi and (optional) Dupont connector
Close-up of the Dupont plug.
This (Dupont plug) is crimped on the wire …
… and then plugged in GPIO4 of the RaspberryPi.
Close-up of the plugged-in wire on the GPIO bar of the Raspberry Pi.

Log in via SSH on the RaspberryPi

To get started, you first need to log in to RasPi with SSH on Putty. How to do it is described in the article

After entering your username and password you can start to enter the first commands.

Update package management

The package management in Linux is a "central point" over which various software packages can be installed. For this to work reliably, the lists and sources of package management should be updated before installing any new packages.

To start the package management update you have to enter the following command.
sudo apt-get update && sudo apt-get upgrade
Depending on how long your last update of the package management is, this process can take some time. First, the lists are updated in which the individual repositories are referenced.
Then the packages themselves are updated. As this additional memory is occupied, you will again asked for your consent. You have to confirm this with a "J"(in German) or a "Y" and "Enter".
When the update is complete, you will see a small summary of the duration and scope of the update.

Install required packages

To be able to send FM signals via the RaspberryPi, you also need to install some software. Since you have to compile the source code of the FM transmitter yourself, it is necessary to first install a suitable compiler. This is done with the following command.

sudo apt-get install make gcc g++

Copy and compile software from the GIT repository

Once you’ve installed the compiler, it’s time to download the actual program code.

First create a folder where you can save downloaded source code files. Enter the following command.
mkdir fmTransmitter
Then change to the created folder with the following command.
cd fmTransmitter
Now you can start the download of the source code files with the following command.
git clone https://github.com/markondej/fm_transmitter.git

If for some reason the GitHub repository mentioned above is no longer available you can also use the “backup” in the Nerdiy GitHub. You can find it here: https://github.com/Nerdiyde/fm_transmitter

The downloaded files are included in another folder by default. Switch to this folder with the following command.
cd fm_transmitter
After you have changed into the folder you can start the compilation process by executing the command “make”.
make
The compilation process takes a few seconds depending on the computing power.

Command to send the FM signal

The program for sending FM signals is thus ready.

With the following command you can now play over the set frequency a .wav file.

sudo ./fm_transmitter [-f frequency] [-r] filename

You have to replace “frequency” with the desired frequency and filename with the filename of your .wav file.

For example, the following command sends the file “test.wav” to 102.0 Mhz.

sudo ./fm_transmitter -f 102.0  -r test.wav

Send endless loop of a music file

If you are in the folder of the copied GIT repository, you can play the supplied melody with the following command and receive it over 102.0 Mhz.

sox acoustic_guitar_duet.wav -r 22050 -c 1 -b 16 -t wav - | sudo ./fm_transmitter -f 102.0 -

Send text inputs via FM signal

The following article also describes how you can send a given text via FM signal in the ether.

RaspberryPi – output voice output via FM signal


Additional Information

https://github.com/markondej/fm_transmitter
https://github.com/Nerdiyde/fm_transmitter


I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂

Fab

P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂

Buy Me a Coffee at ko-fi.com

Leave a Reply

Your email address will not be published. Required fields are marked *