I moved to an area where my AM news station (WBZ) comes in rather scratchy. Sure I could stream them over the internet on a mobile device, but what about the radios I currently have? Have they now become paperweights? Fortunately, WBZ streams online and I found a cool FM transmitter module that I thought “I could use this with a Raspberry Pi to put WBZ on the FM dial near my home”. The FM module is about $12 and available on Amazon and I already had a raspberry pi computer I could dedicate for the project. Why not try it?
WARNING *** WARNING *** WARNING *** WARNING
This article is for informational/educational purposes only. If you make use of any information in this article, I will not be liable for your use of this information and any action you take based on the technical discussion herein is solely at your own peril/risk! Please check local laws for this application in your country of residence! This article also deals with a solution powered by AC mains voltage. If you do not understand what you are doing, PLEASE be safe and get qualified help!
I installed Ubuntu Linux 20.04.2 server on the raspberry pi computer, and then installed a software called liquidsoap. Liquidsoap is an audio/streaming swiss army knife and is of course, open source. Normally, people use liquidsoap to capture a live audio source and then create a stream on the internet. I wanted to do the reverse, and pull in an internet stream and play it over the USB DSP that is built into the FM module. A bonus is that the FM module is also powered via the USB connection – one cable does it all. Shown here is the finished transmitter:
The FM module is quite versatile. It has an analog line-in, condenser mic, and USB audio interface all built in! Depending on what input you use, the module is smart enough to pick that input and use only that. When I hooked the module to my raspberry pi and ran:
I was able to see the USB audio interface on the FM module:
[email protected]:~$ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones] Subdevices: 8/8 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 Subdevice #7: subdevice #7 card 1: CD002 [CD002], device 0: USB Audio [USB Audio] Subdevices: 0/1 Subdevice #0: subdevice #0
The “card 1” device is the USB connection to the FM module.
All I needed to do now was install and setup liquidsoap. For that I used this guide and installed with OPAM. Once I had liquidsoap installed, I created a .liq script which had the following configuration to stream WBZ and play it on the FM module’s USB interface:
str = "http://cast.wizworks.net:8000/wbz" prog = mksafe(input.http(str)) prog = amplify(0.7,override="replay_gain",prog) output.alsa(device="plughw:CARD=CD002,DEV=0",prog)
With this .liq file saved as play.liq, I could then start it up by running:
If you want to add this as a systemd service, just follow the conventions to create the service file and install it as a service so it comes up whenever the raspberry pi is started.
FM Module Tips
The FM module as it comes, does not have an antenna on it. For best results, solder a 1 meter length of wire on the “ANT” solder pad and place the entire RPi/FM setup in a high location within your home. You should find a clear spot on your FM dial using a portable radio and set the FM module to that frequency. When properly set, you should be able to pickup the signal from your RPi/FM package at least 4 houses away before you start to hear static. This amount of range from such a small module is pretty decent and sufficient to enjoy your streamed audio source on any ordinary radio near your home. The sound quality is very good for a $12 module and sounds nice on my Tivoli and other radios.
PRO TIP FOR MORE RANGE (FOR YOU RADIO PIRATES)
Connecting the home brew transmitter to a small RF amp brings the power output up to about 10 watts. This power is then fed through an RF bandpass filter before the antenna. This helps eliminate RF harmonics that WILL get you busted in short order! DO NOT operate a device like this at any considerable power level without proper filtering, it is a guaranteed way to get busted for radiating harmonics and interfering with other signals!
The transmitter connected to the amp module (live audio is fed from an icecast stream over CAT6 cable). Note the small white WiFi smart outlet. This lets me remotely turn off the transmitter if I get wind that the FCC is taking an interest. I have the ability to remotely kill it from my smartphone from anywhere, at a moment’s notice:
The RF bandpass filter (SUPER IMPORTANT!)
Finally, the TUNED circular polarized antenna – circular polarization helps reduce multipath signal distortion for mobile listeners. This antenna is precisely tuned to the desired broadcast frequency of 95.1 using a cheap portable VNA (Vector Network Analyzer)