Saturday, 1 November 2014

Using PiFM to transmit audio on any frequency up to 250 MHz

The first "hack" which allowed experimenters to use the Raspberry Pi's clock pin (GPIO 4) to transmit audio directly from the Raspberry Pi came from the Imperial College Robotics Society . Their "PiFM" module has since been modified and improved and is now capable of transmitting in 16 Bit Stereo on any frequency from about 1 MHz up to 250 MHz.

It sounds too good to be true.... so I decided to try it out for myself!

WARNING - DO NOT connect your Raspberry Pi's clock pin (GPIO 4) to any kind of antenna (even a short length of wire) when performing any of these tests!

Full details of the "PiFM"  module may be found here, and you can download it as a ".tar.gz" archive here. Once you have downloaded the archive to your Raspberry Pi, extract the files, open a terminal window on your Raspberry Pi and go to the folder containing the extracted files (in my case the Downloads folder). The folder should contain the flollowing six files:

left_right.wav           - sample stereo ".wav" file
sound.wav               - sample music ".wav" file (Star Wars theme)
pifm.c                       - pifm "c" source code
pifm                          - compiled pifm module
PiFm.pyc                 - Python bytecode for pifm                   - Python script for pifm

Position a VHF portable radio close to your Raspberry Pi and tune it to a frequency where there is no transmission (in my case 100.0 MHz). Type the following at the command line prompt in the terminal window (but enter whatever frequency you want to use) and press Enter:

pi@raspberrypi ~/Downloads $ sudo ./pifm sound.wav 100.0_

Almost immediately you should hear the Star Wars theme playing on your portable radio. You can stop playback by pressing "Ctrl+C" or you can let the music play right to the end of the ".wav" file. However.....PLEASE NOTE that in either case your Raspberry Pi will continue to transmit a carrier on the frequency you have chosen until it is rebooted or turned off, so please DO NOT leave your Raspberry Pi transmitting a carrier after you have finished experimenting!

I decided to have a look at the spectrum of the transmitted RF signal, however my spectrum analyzer only covers up to 60MHz so I set the Raspberry Pi to generate a 30MHz signal. The spectrum is shown below:

You can see the "fundamental" signal at 30 MHz, but there are multiple strong subharmonic and harmonic spikes all over the RF spectrum. I also noted that if I tuned my receiver to any multiple of 30 MHz (e.g. 60MHz, 90MHz, 120MHz etc) I could clearly hear the transmitted signal, sometimes very strongly.

Therefore please DO NOT connect your Raspberry Pi's clock pin (GPIO 4) to any kind of antenna when performing any of these tests, because you will generate unwanted and potentially dangerous RF energy right across the electromagnetic spectrum.

Whilst it is very easy to use the Raspberry Pi's clock pin (GPIO 4) to generate an RF signal, and even transmit audio, the usefulness of this hack is severely limited by the huge amount of harmonic and subharmonic distortion in the signal (because it is basically a square wave). I've read many articles which suggest the Raspberry Pi may be a used as a low power transmitter for the amateur radio bands simply by using a low pass filter on the output, but I'd say even this is insufficient (due to the subharmonic distortion in the generated signal). To make any practical use of any RF signal generated by the Raspberry Pi in this way would require very good band pass filtering.


  1. A hard disk media player that still has a cult reputation

  2. * On *my* system (Pentium 120) the following parameters:
    * 1000 1000 20000 20000 60 60
    * produce a sweeping tone on FM 87.5 MHz.
    * Berke Durak
    * 18081999


    typedef unsigned char u8;

    #define BUF_SIZE (1<<18)

    void tempest_cpu_pattern (int count, volatile int *buf, int a, int b)
    int i, j;
    int x1, x2, x3, x4;

    x1 = 0; x2 = 0; x3 = 0; x4 = 0;
    i = 0;

    while (count --) {
    for (j = 0; j> 4, b += (b2 - b1) >>4) {
    tempest_cpu_pattern (count1, c, a, b);

    return 0;

  3. Hi,

    I was just curious what you mean by "potentially dangerous". Is that dangerous to the Pi itself, other electronic devices, human health, etc? I was going to build one of these and use it around the house on a regular basis but after reading your post I'm a little wary now.


    1. Dangerous for legal reasons. Harmonic splatter causes the radio waves to emit all over the electromagnetic bands in which case potentially interfering with police, air traffic, ems, schools, busses, etc. if u do interfere, the fcc will most likely be at ur door in like... less than an hour.

  4. Wow, I have been surfing the internet for the past few hours and I have not come across such an interesting site with great content and a unique design. I have gain a lot from posted article and I have increased my general knowledge and I am very grateful that I landed on this site and found this great content. Access our site for affordable but Professional Editing Service.

  5. تعمل شركة اللمسه في مكافحة الحشرات مثل النمل والصراصير وجميع انواع الحشرات بأبها الان ، وتعتبر شركة اللمسه من اشهر شركات مكافحة الحشرات في السعودية , لدينا عمالة مدربة ومتخصصة المواد المستخدمة فى مكافحة الحشرات غير ضارة على الانسان وليس لها روائح نعمل بدون مغادرة المنزل نعمل على راحة عملائنا .
    شركة مكافحة النمل الابيض بنجران
    شركة رش مبيدات بالخرج
    شركة مكافحة حشرات بالخرج
    شركة مكافحة النمل الابيض بالخرج
    شركة رش مبيدات بأبها
    شركة مكافحة حشرات بأبها
    شركة مكافحة النمل الابيض بأبها
    شركة رش مبيدات بنجران
    شركة مكافحة حشرات بنجران
    شركة رش مبيدات بالعينه

  6. هل تبحث عن شركة متخصصة فى خدمات التنظيف بالطائف بافضل المعدات والسوائل وثقة تمة فى العمل ودقة فى النتائج كل هذه المميزت توفرها شركة الخليج الشركة الافضل والامثل فى الخدمات المنزلية بالطائف وبما اننا الشركة الافضل والامثل بدون منافس سوف نسعى لتوفر افضل الخدمات باقل تكلفة وبقدر كبير من الاهتمام والدقة عزيزى اينما كنت فى اى منطقة ا وحى تابع لمدينة الطائف اتصل بنا وسوف نصلك فى الحال شركة الخليج للخدمات المنزلية شركة تنظيف منازل بالطائف
    شركة تنظيف فلل بالطائف
    شركة تنظيف خزانات بالطائف
    شركة تسليك مجارى بالطائف
    شركة رش مبيدات بالطائف
    شركة مكافحة نمل ابيض بالطائف
    شركة مكافحة حشرات بالطائف
    شركة عزل اسطح بالطائف
    شركة عزل خزانات بالطائف

  7. شركة السالم لخدمات التنظيف ومكافحة الحشرات ونقل العفش مع الفك والتركيب بالطائف يتم العمل لدينا من خلال فريق وعماله فنيه مدربه في غاية الاتقان ومن خلال احدث المعدات والاداوات مع شركة السالم فانت دائما في راحة تامه وامن مستمر
    شركة تنظيف بالطائف
    شركة تنظيف مجالس بالطائف
    شركة تنظيف خزانات بالطائف
    شركة مكافحة حشرات بالطائف
    شركة رش مبيدات بالطائف
    شركة عزل اسطح بالطائف
    شركة تسليك مجاري بالطائف
    شركة نقل اثاث بالطائف

  8. شرکت تلکا هاست در تلاش است تا در خدمات خود بهترین باشد و در زمینه خرید هاست ارزان همواره کمک به وبمستران عزیز بکند.همچنین تلکا هاست در هاست فوق ارزان و خرید هاست دانلود ارزان نیز فعالیت دارد و هاست پرسرعت ارزان هم دارد.

  9. Online biology essay services have come up with Biology Essay Writing Services for biology research paper writing service students in order for them to score straight A’s in their custom biology research paper services.

  10. To seek the best Healthcare Assignment Writing Services for those studying healthcare coursework writing services, it is important to hire an award winning healthcare essay writing service company.