Raspberry Pi Home Server - Issue on air with PiFm

Now a simple article (Bah yeah it's Sunday !) and quick to set up especially if you already have an electric wire !

RadioCartoon

I offer this post for a while but between the weather station and the Arduino j’ai pris du retard 🙂

Today we are going to use the tool PiFm, Super simple to set up and use. For this you need only a wire with a length of 20 at least cm. Here is what I took home :

WP_20130817_001

Then you connect on the GPIO 4 which corresponds to the 4th pin on the inside row :

WP_20130817_005

Finally you download this little app PiFm to This address and you unpack everything in the directory of your choice.

wget http://www.icrobotics.co.uk/wiki/images/c/c3/Pifm.tar.gz tar zxvf Pifm.tar.gz

To immediately test it's easy, you have a file included with :

./pifm sound.wav 100.0

The value 100.0 corresponds to the transmitter frequency, that you need to adjust your radio. You should hear the music of a cult film !

Now if you want to make your own music, We'll have to follow the format of 22050 Hz, Mono and 16 bits. To convert your MP3, We will use a classic tool : ffmpeg.

apt - get install –y ffmpeg

Then you take an MP3 and you type the following command :

ffmpeg-i mon_fichier.mp3 - acodec pcm_s16le - ar 22050 -AC 1 mon_fichier.wav

Voilà. You can rerun PiFm with your file :

./pifm mon_fichier.wav 100.0

Have fun !

You may also like...

  • Thanks for the tip .

    the scope of this device ?

    a caution do not scramble waves of you're nearby :p

    and the frequency can go how has how many . history of broadcast on the baby monitor :p like HP deport :p

    • Hello,
      The range announced with a 20cm antenna is approximately 100 m from the author. Through walls happens to 50 m.
      For frequencies, It's going from 1 Mhz to 250 Mhz.
      For the baby he had a project with a Raspberry : http://www.raspberrypi.org/archives/tag/baby-monitor

      • Mmega

        It looks good to clarify that according to the frequency used, the size of the antenna must be different. . To find the size of the antenna should be λ/4 with λ = 300/f. f is the frequency in MHz.

        • Thanks for the info ! 🙂

        • Laurent

          Hello,

          Can you please clarify the length unit associated with the result of the λ/4 calculation ?

          Thank you !

  • Hello !!!

    Interesting as mount !! 😀

  • Excelent ! Ca pourrait etre couplé avec MPD pour diffuser de la musique dans la voiture 🙂

    Or even better, contact 2 raspberry 🙂

  • Rico.bzh

    Hello , un site tres interessant concernant les longueurs d’ondes et un petit soft permettant de calculer rapidement la taille de votre antenne 😉
    http://www.bmweb.fr/radio/mat_antennes.php

  • michael

    Hello!
    Je suis allemand, mais j’essaie d’éscrire en francais.
    J’ai installé pifm sur mon raspberry pi. peux-tu me dire, comment j’ai peux terminer pifm?
    après le broadcast, c’est silent. mais la radio station originale n’est pas là. c’est silente.

    Hi,
    i’ve installed pifm on my raspbery pi. how Can I stop my pi from broadcasting? When the track ended, or when i cancel the process, the frequency is muted - but the original broadcast is not there. how Can i delete the frequency and stop the pi from broadcasting?

    • Hello,

      Never noticed that. Did you try to remove the wire or turn off the pi to control that this will restore the original broadcast ?

  • Frankynov

    Wow, je viens de tester et ça marche nickel !!!!
    Ca donne plein d’idées…

    I saw on a forum a command to do the conversion/streaming on the fly, for example here with the web radio Addict Alternative :
    avconvr-i http://stream1.addictradio.net/addictalternative.mp3 -AC 1 -AR 22050 -b 352 k f wav - | ./pifm - 100.0
    Tested and it works, problem is that when I do CTRL-C to stop all, the frequency of origin is still used by PiFm and emits continuous silence. The solution is to run pifm on this frequency (without the conversion on the fly) and stop it, and there the frequency is available again.

  • Frankynov

    Good in fact I noticed that only also used PiFm after a CTRL + C does not release the frequency, so be careful if you use sensitive frequencies and used (It is normally illegal !)

  • Sleepyhead

    Hello.

    Would it be possible to combine PiFM and Shairport to broadcast in FM stream airport (for example from an iDevice) ?

    I could not find the information on the net.

    Thank you very much.

  • chrusse

    Jump,
    Thanks for the article, I managed to make music in wav and mp3's through avconvr .
    I'd like to read a file but I can not find the necessary commands.
    If I understood the thing, coarsely avconvr convert “in the stolen” the mp3 to wav and the “pipe” allows you to swing the result on pifm that's right ?
    Starting from la I do not see how to read a file or a playlist because I must indicate a .mp3
    Example:
    avconvr-i ' /opt/music/test.mp3’ -AC 1 -AR 22050 -b 352 k f wav - | /opt/pifm/bin/pifm - 98.3

    • Hello,
      Why not go through a shell script that will iterate through all of the files and play them one by one ?

      • Valentin

        Hello,
        Could you tell me how you would do your shell script since I started and I'm swimming in ?

        • Hello,
          A trick in the genre

          #!/bin/bash
          for fichier in /mon/repertoire/*
          do
          avconv -i ‘$fichier′ -ac 1 -ar 22050 -b 352k -f wav – | /opt/pifm/bin/pifm – 98.3
          done

  • Clement Bahar

    Hi I might know where you bought the wire because I can't find a thread with the tip to go to the GPIO .
    Thanks in advance
    Good bye .

    • Hello,
      It's female wires for electronics. Miniinthebox sells if it can help you

  • Chris

    Hi all,
    je m’intéresse de près depuis quelque temps à cet émetteur FM et il y a un point que je ne comprends vraiment pas concernant la génération de la fréquence FM autour de 100 MHz avec le PWM de manière générale. Il est dit que l’horloge utilisée tourne à 500 MHz, ce qui signifie que au maximum il y a 5 cycles d’horloge (500 / 100), et donc 5 « points » pour définir un cycle (une période) of the sine wave FM 100 MHz. It seems to me exceedingly little simulate a sine wave (analog) with only 5 samples (Digital). It must necessarily be a point that escapes me. Would someone kindly enlighten me on this point that keeps me half to sleep these days ?

    Thank you !

Handpicked links

disk Page Caching using disk: enhanced Database Caching 184/432 queries in 0.251 seconds using disk Served from: pihomeserver.fr @ 2017-10-02 08:33:24 by W3 Total Cache -->