Monday, December 12, 2016

PiFM sorta

Wanted to be able to send music to speakers outside the house say for a barbecue or whatever. Could use Blue tooth among other things, but I wanted something more secure and easier to generally implement. PiFM seemed to be an answer . With a RPi you can send an old fashion radio signal to a radio and the radio will play what is sent it. All you need is an up to date Raspian install on a Raspberry Pi with internet access. I used the original  Raspberry pi for this project. I will probably set one up with the RPi zero. (Note: check you local laws to see if this is allowed.) Also you need to have experience using you RPi remotely.

Antenna needs to be at least 7-14 inches long.


You need to log into your Rpi command line. All this can be done easily. First thing is to get some software from the software repo for doing software development. Don't worry it will not hurt too bad.

Update the system:

$ sudo apt-get update
$ sudo apt-get upgrade -y
$ sudo apt-get dist-update -y

Get the files you may need:

$ sudo apt-get install zip make gcc g++ mpg123
$ wget https://github.com/markondej/fm_transmitter/archive/master.zip
$ unzip master.zip
$ cd   fm_transmitter-master

Now let's compile the project.

$ make


Get a FM radio and tune it to the frequency you have chosen

$ sudo ./fm_transmitter [-f frequency] [-r] filename

You should hear the file play on the radio. I used a transistor radio to see where the signal  transmitted to. You can get into some fancy batch files so you can manage your music, but that is for a later time,

Untested :

    Download a few of your favorite mp3 files to the Pi, or you can scp them. Make sure to put them in the /home/pi/Music directory.
    From the command line, type in the following command. The number 88.3 is the frequency the Pi will broadcast at. sudo /usr/bin/mpg123 -4 -s -Z /home/pi/Music/* | sudo /home/pi/pifm/pifm - 88.3
    Note: If you want to stash your mp3 files in a different directory, simply change the directory path that's underlined in the command above.
    Caution: Commands and filenames are case sensitive in Linux, so make sure you duplicate the exact capitalization of the previous commands.

No comments:

Post a Comment