This page looks best with JavaScript enabled

Turn our Rasp into an FM radio station

 ·  🎃 kr0m

The Raspberry Pi is becoming the toy of many computer enthusiasts, and as a result, some really interesting projects are emerging. A good example is this project in which we use pin n7 of the Rasp to broadcast on FM. This program only reads wav files, but through ffmpeg we can broadcast mp3 files.

The first thing to do is to connect a cable to pin n7 of the Rasp, which will act as an antenna:


Now we download the necessary software:

wget http://omattos.com/pifm.tar.gz
tar xvzf pifm.tar.gz

NOTE: Here is the same compressed file hosted on my server in case the original link breaks or closes ;)

We can play the test file to check that it works correctly:

./pifm left_right.wav 103.3 22050 stereo

Now we simply tune in to the frequency 103.3Mhz on the radio and we will be listening to the thoughts of our Rasp, amazing!!

NOTE: Through pin7 we can broadcast in the frequency range of 1Mhz to 250Mhz, we just have to modify the frequency in the previous command.

If we want to be able to broadcast mp3, we must install ffmpeg. In my case, I will remove all uses related to the graphical aspect:

vi /etc/portage/package.use/ffmpeg

media-video/ffmpeg -3dnow -3dnowext -X aac aacplus alsa altivec -amr -amrenc armv5te armv6 armv6t2 armvfp avx avx2 -bindist -bluray bzip2 cdio celt cpudetection debug dirac doc encode examples faac fdk -flite fma3 fma4 fontconfig frei0r gme gnutls gsm hardcoded-tables iconv iec61883 -ieee1394 jack -jpeg2k ladspa libass libcaca libsoxr -libv4l mips32r2 mipsdspr1 mipsdspr2 mipsfpu mmx mmxext modplug mp3 neon network -openal -opengl openssl opus oss pic pulseaudio quvi rtmp schroedinger sdl speex sse sse2 sse3 sse4 sse4_2 ssh ssse3 static-libs test theora threads truetype twolame -v4l vaapi vdpau vis vorbis vpx wavpack webp -x264 x265 -xvid zlib zvbi
echo “>=media-plugins/alsa-plugins-1.0.27-r1 pulseaudio” > /etc/portage/package.use/alsa-plugins
mkdir /etc/portage/package.license/
echo “=media-libs/fdk-aac-0.1.1 FraunhoferFDK” > /etc/portage/package.license/fdk-aac
emerge -av ffmpeg
ffmpeg -i input.mp3 -f s16le -ar 22.05k -ac 1 - | ./pifm -

If we want to broadcast our own radio station, we just need to plug a USB microphone into our Raspberry Pi:

emerge -av media-sound/alsa-utils
arecord -d0 -c2 -f S16_LE -r 22050 -twav -D copy | ./pifm -

If you liked the article, you can treat me to a RedBull here