• First Steps
  • General
  • Projects
Facebook Twitter YouTube
Tutorials for Raspberry Pi Tutorials for Raspberry Pi
  • Hardware & GPIO
  • Sensors & Components
  • Scale
  • Cases
  • Fingerprint
  • Gas Sensor
  • Heartbeat
  • German
  • French
Tutorials for Raspberry Pi Tutorials for Raspberry Pi
Home»Projects»How to build a Raspberry Pi Radio Transmitter

How to build a Raspberry Pi Radio Transmitter

Facebook Twitter LinkedIn Tumblr Email Reddit
Raspberry Pi Radio Station
Share
Facebook Twitter LinkedIn Email Tumblr Reddit Telegram WhatsApp

The Raspberry Pi can be used pretty much for any conceivable application – as well as a radio transmitter. Frequencies from 1Mhz to 250Mhz can be used, including the usual radio frequencies between 88 and 108Mhz.
Depending on the position and antenna, the signal can be transmitted up to 100 meters.

In this tutorial, I will show what you need for it and how to set up the radio station on the Raspberry Pi.

 

Required Hardware Parts

I have used the following hardware parts:

  • Raspberry Pi 3
  • USB sound card
  • Jumper cable (possibly a stronger antenna, depending on the application)

 

Software

The basis is the library piFM. With this, it is possible to “misuse” GPIO 4 (pin 7) of the Raspberry as a transmitter. An antenna (either a real antenna or a simple wire) must be connected to it.

Firstly we load the software and compile it.

git clone https://github.com/rm-hull/pifm && cd pifm
make

Now that you’ve connected the antenna to pin 7 (the 4th pin from the top of the inner side), you’re ready to go. To do this, piFM must be started as root and a file specified (.wav format) to be played. In addition, the transmission frequency can be specified optimally (standard 103.3Mhz) and the audio sampling rate (in Hz).

An example call would be the following:

sudo ./pifm sounds/star-wars.wav 103.3 22050 stereo

Now, if you are looking for this frequency on your radio, you should hear the Star Wars melody and the previous noise should stop. At the end of the song, it will be played again from the beginning.

In addition, the library can be easily integrated into Python:

Python
1
2
import PiFM
PiFm.play_sound("path/sound.wav")

 

Live speaking

More interesting than just playing music is probably the opportunity to speak live. This is relatively easily possible with arecord. All you need to do is connect a microphone via the USB sound card.

Here we start a recording and pass it directly as input for piFM via pipeline:

arecord -f S16_LE -r 22050 -twav -D plughw:0,0 - | sudo ./pifm -

These arecord parameters worked best for me. If you are getting only bad sound, you would have to adjust the parameters if necessary. Instead of plughw:0,0 it can also be plughw:1,0. That’s why it’s the best to call

amixer

The connected audio devices should be displayed.

During testing, I have noticed that no signal was sent after I wanted to listen to my recording via aplay. The same thing can happen if the default audio settings have been changed (/etc/modprobe.d/alsa-base.conf). In this case, the settings should be reset (if changed) and restarted. If the problem persists sudo apt-get update && sudo apt-get upgrade or a new Raspbian image will help. But as I said, usually just a reboot is enough.

LastFM piFM Radio Radiostation
Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
Previous ArticleInstall Windows 10 IoT on the Raspberry Pi
Next Article Remote Raspberry Pi Spotify Player im Smart Home einrichten

Related Posts

Control all GPIOs with the Raspberry Pi REST API via Python

Using TensorFlow Lite with Google Coral TPU on Raspberry Pi 4

Raspberry Pi Samba Server: Share Files in the Local Network

Build Live Text Recognition with the Raspberry Pi (OCR)

7 Comments

  1. Vignesh Kumaresan on 13. July 2018 12:44

    Can I use this on Pinterest zero w?

    Reply
  2. Bruce B on 30. May 2019 18:17

    Is there an AM version of this ? I really need a way to transmit a signal amplitude modulated for antique radio servicing.
    It should be a lot simpler to do, but I don’t have the skills necessary to write the program .

    Reply
    • user on 25. September 2019 23:50

      Since the signal is FM, you only have to modulate the frequency (0 to 1 state of the gpio ) according to the audio file, for AM modulation the frequency is fixed but the amplitude is modulated by the audio, this is far more complex to achieve with the GPIO because the voltage must vary according to the audio. FM is more digital friendly

      Reply
  3. Jay on 13. August 2019 14:50

    I tried this on my new Pi 4 and could not get it to work.
    I back down and tried it on my Pi 3 and it worked easily.

    I know that they made some changes to the GPIO pins for the Pi 4 and I assume this is the reason it does not work on the new hardware.

    Reply
  4. Stef on 14. October 2019 22:10

    Is it possible to stream live audio and speak simultaneously with the above configuration? I want to give comments on the music when it plays or broadcast a news column in between songs.

    Reply
  5. Martin Rizzo on 15. November 2019 13:22

    Dear Sir,

    I am trying to build an fm transmitter on RPi 4 using GPIO4 but I can’t get it to work for some reason. Honestly I managed to make it work on a RPi 3 (same software and setup) without any hitches.

    Would appreciate any feedback please if possible.

    Many thanks in anticipation.

    Martin

    Reply
  6. Robert on 14. November 2024 0:39

    is it possible to receive on the same or different pi

    Reply

Leave A Reply Cancel Reply

ESP8266 Access Point: Build a Cheap Wi-Fi Repeater Yourself

PiCar-X: Build a smart, self-driving robot car with the Raspberry Pi

How to setup a Raspberry Pi Security Camera Livestream

Top 12 Advanced Robot Kits For Adults – Full Overview

Top 21 OS for the Raspberry Pi for your Project – Overview

How to use a Raspberry Pi Fingerprint Sensor for Authentication

Subscribe to Blog
Subscribe to Raspberry Pi Tutorials and don't miss any new Tutorial!
Subscribe

Thank you!

We will contact you soon.

Tutorials for Raspberry Pi
Facebook Twitter YouTube
  • Contact & Disclaimer

Type above and press Enter to search. Press Esc to cancel.