Sunday, November 17, 2019

Creating FM Radio Station using Raspberry Pi

This tutorial is for creating your own FM Radio station using FM Transmitter code and a copper wire.

Equipments Required

  • Raspberry Pi 2/3/4
  • Micro SD Card (minimum 16 GB)
  • Standard Power supply
  • A copper wire (1 metre long)
  • Internet connectivity (Wifi/ Ethernet cable)
Before starting the tutorial, you'll need to understand Copper wire will be hooked up in GPIO pin no 4.
Below diagram will help you identifying the pin.



or you can read about it thoroughly with this link.


The wire will act as an antenna. But please note that the sound quality and frequency range will not be best. It'll work in small range like a small office or home


Starting up

  1. Update your Raspberry Pi

    sudo apt-get update

    sudo apt-get upgrade
  2. Installing package for setting up the Radio Station

    sudo apt-get install -y sox make gcc g++ git alsa-utils libmp3lame-dev
  3. Now, once this package is installed, we can clone FM Transmitter library. This uses the general clock output to produce frequency modulated radio communication. It reads mono and stereo files, data from stdin.
    To clone this, use following commands

    cd ~

    git clone https://github.com/somu1795/fm_transmitter.git
  4. Now moving to the directory and running make command

    cd ~/fm_transmitter

    make
  5. Now running this

    sox /home/pi/fm_transmitter/star-wars.wav -r 22050 -c 1 -b 16 -t wav - | sudo ./fm_transmitter -f 100.3 -

    Defining the above arguments
    -c : Defining number of channels
    -b : Bit rate of output

    You can change this frequency according to your requirement.
Adding Support for MP3 files

  1. Clone x264 support. This will be required to compile FFmpeg (command line tool will converts audio and video formats)

    cd /usr/src

    sudo git clone git://git.videolan.org/x264

    cd x264

    sudo ./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl

    sudo make

    sudo make install
  2. Once the above commands are run, we will run following commands for compiling FFmpeg

    cd /usr/src

    sudo git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg

    cd ffmpeg
  3. Version specific commands ( Please see which version of Pi you have and install the command as per your requirement )

    Raspberry Pi 3 and later

    sudo ./configure --arch=armv7-a --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --extra-cflags='-march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard'

    Raspberry Pi 2 and before

    sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree
  4. Now running below commands

    sudo make -j4

    sudo make install
  5. As FFmpeg is now compiled and setup we can now run MP3 files.

    cd ~/fm_transmitter

    sudo python ./PiStation.py -f 100.3 bahubali.mp3






Please note there are rules and regulations for broadcasting FM Frequencies. Please check the laws of your country before transmitting the signal to any frequency.


1 comment:

  1. Thanks for this tutorial! It was easy to repeat! Transmits great for about 3 seconds and cuts out. Anyone else have the same problem?

    ReplyDelete