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?
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.