Is there anything the Raspberry Pi can’t do?
I came across a project that lets you turn your trusty Raspberry Pi into an honest-to-goodness FM broadcasting device that will transmit up to a hundred meters, with the only modification being the addition of a single wire to a GPIO pin as an antenna.
As a caveat, let me tell you that I have not yet made a functioning radio transmitter, but I’ll be building this as I write this blog post up, so, in a way, we’ll be doing this together.(Update: It works!)
(The funny thing is, the biggest problem I have with this is the lack of a radio receiver to test with. I’m on vacation as I write this, literally in the jungles of Costa Rica. I have my iPad and keyboard, my little Bluetooth speaker and of course my RasPi, but no radio. I’ll try to track one down.)
I’ll be doing all of this on a Raspberry Pi (3 in my case, but that probably doesn’t matter much,) using Raspbian Linux, though that, too, probably doesn’t matter, as long as you have Python and some GPIO pins.
(Edit: It turns out that the Pi 3 does not work with the original software, but I’ve found an alternate that does, so I’ll leave what I wrote below, but strike it out.)
Ok, the first thing we do is open up a terminal and get the software we need. In your terminal, type:
sudo apt-get install -y wget (Just making sure you have ‘wget’ to grab files from the Internet. It will probably tell you that you already have the latest version)
Ok, that’s set, let’s create a place for our project.
cd #change to your home directory mkdir projects cd projects mkdir pirateradio #get it? Pi-rate Radio? cd pirateradio wget http://omattos.com/pifm.tar.gz tar -zxvf pi fm.tar.gz # uncompress the archive
So it turns out there’s a hardware difference between the Pi3 and earlier hardware, so the software package we found initially won’t work, but there’s an alternative.
Open a terminal and go to your projects directory:
(If you get a ‘not found’ error, create it with “mkdir ~/projects” and then cd into it.)
Let’s go get the source code for the project from Github, using the ‘git’ command in the terminal:
git clone https://github.com/markondej/fm_transmitter.git cd fm_transmitter
Now we’ll make sure we have the programs we need to build the project:
sudo apt-get install make gcc g++
That will run for a bit as it installs. Finally, we run “make” to build everything:
Check the output of ‘make’for errors. There shouldn’t be any, hopefully. If it looks good, it’s time to test it out.
We’ll need an antenna. Ideally, it should be about 27 inches, but one of about 8 inches will do as well. Connect it to GPIO 4 on your breadboard, which should be the 4th pin down from the top, on the left side, if you are using a ‘Pi Cobbler’ and ribbon cable to connect your breadboard. The other end of the wire doesn’t get connected to anything, though you might want to pinit up, or drape it over something, to give it some height.
Next, go find yourself an FM radio and tune it to 97.3 FM.
(Don’t worry, you shouldn’t be hearing anything yet.)
Back in the terminal, type:
(Just to make sure you’re in the right place.)
sudo ./fm_transmitter -f 97.3 -r star_wars.wav
You should be hearing the theme to Star Wars now! You’re broadcasting!
If your radio is portable, you can now test how far your signal will reach. Let me know below how well it works!