Raspberry PI : FM Radio Transmitter




Raspberry Pirate Radio


Project Steps

Make the antenna


Technically, all you need for an antenna is a piece of wire.
For an optimal antenna, you could attach a 75cm wire to pin 4, with a 75cm power cable pointed in the other direction. (That would effectively make a half-wave dipole antenna at 100MHz, near the middle of the FM band.)
We just used 40cm of 12 AWG solid wire, since things started tipping over when the wire got longer.
Cut and strip a female jumper wire. Solder it to one end of your antenna, and insulate with heat-shrink tubing.
Dab hot glue around the joint for support, and stick it on pin 4 of the GPIO pins of your Raspberry Pi.
The glue makes the antenna more rigid so it stands up better.
NOTE: If you have the Raspberry Pi Starter Kit and you're in a hurry, you can just use a male jumper wire plugged into the Cobbler breakout board! (Both are included in the kit.) It will work, but the range will be roughly half of what you'd get with 40cm of 12 AWG solid copper.

Flash the SD card and add music


Edit the config file


Start it up!


How the PiFM software works

  • From the PiFM wiki: "It uses the hardware on the Raspberry Pi that is actually meant to generate spread-spectrum clock signals on the GPIO pins to output FM radio energy. This means that all you need to do to turn the Raspberry Pi into a (ridiculously powerful) FM transmitter is to plug in a wire as the antenna (as little as 20cm will do) into GPIO pin 4 and run the code."
  • Frequency modulation "is done by adjusting the frequency using the fractional divider." For example, for a target broadcast frequency of 100MHz, the signal is fluctuated between 100.025Mhz and 99.975Mhz, which makes the audio signal.
  • The Python code defaults to 87.9 FM with shuffle and repeat turned off. It scans the SD card for music files and builds a playlist based on the options in the config file. It then passes each file along to a decoder based on the filetype. Each file is then re-encoded into a mono format the PiFM radio can handle. This lets you play more than just WAV files: use your MP3, FLAC, M4A, AAC, or WMA files too.

Going further





RASPBERRY PI FM RADIO TRANSMITTER


The FM Transmitter project uses the general clock output on a Raspberry Pi to produce frequency modulated radio communication.

The code is built in C, so it’s also a good introduction to setting up C and building a program on your Raspberry Pi. Once you’ve read the GitHub overview, the video walks you through the setup process, and shows you how to add the script to .bashrc so it runs on startup.

Click here for the FM_Transmitter RPi3 code at GitHub
Once the program is running, you can speak into a microphone and broadcast your voice, or pick audio files on your Raspberry Pi and play them.

Please keep in mind that it’s illegal to interfere with radio transmissions in some parts of the world. And you don’t want to mess up radio transmissions used the emergency services. So consider this an experimental project, and a learning exercise, rather than something to use on a regular basis.

留言

熱門文章