Tuesday, February 18, 2025
ArduinoElectronicsIoT HardwaresTutorials/DIY

Build an FM radio with Arduino to listen to FM stations

Let’s Exlore a detailed explanation of how to build an FM radio using an Arduino and an FM receiver module (like the TEA5767). This guide will cover everything from wiring to software and troubleshooting.

Overview

We will use the TEA5767 FM receiver module with Arduino to tune into an FM frequency like 93.5 MHz. The TEA5767 module communicates with Arduino via the I2C protocol. It provides an audio output that can be connected to headphones or amplified for a speaker.

Required Components

  1. Arduino Uno (or any compatible Arduino board)
  2. TEA5767 FM Receiver Module
  3. 3.5mm Audio Jack (for headphones or speaker connection)
  4. Speaker (optional, if you want louder audio)
  5. Audio Amplifier Module (optional, like PAM8403 for driving speakers)
  6. Jumper Wires
  7. Breadboard
  8. Rotary Encoder or Buttons (for station tuning, optional)
  9. Power Source (USB cable or battery)
  10. Antenna (e.g., a simple wire for better reception)

Step 1: Understand the TEA5767 Module

The TEA5767 module has the following pins:

  1. GND: Ground
  2. VCC: Power supply (3.3V or 5V)
  3. SDA: I2C Data Line
  4. SCL: I2C Clock Line
  5. Right Audio Out (R): Audio signal for the right channel
  6. Left Audio Out (L): Audio signal for the left channel
  7. ANT: Antenna connection for better FM signal reception

Step 2: Wiring Connections

Follow these steps to connect the components.

1. Connect the TEA5767 Module to Arduino:

TEA5767 Pin Arduino Pin
VCC 3.3V or 5V
GND GND
SDA A4 (on Uno)
SCL A5 (on Uno)

Note: If you’re using a different Arduino board, confirm its I2C pins:

  • Arduino Uno/Nano: SDA = A4, SCL = A5
  • Arduino Mega: SDA = 20, SCL = 21
  • Arduino Leonardo: SDA = 2, SCL = 3

2. Connect Audio Output:

  • Use jumper wires to connect the audio output pins on the TEA5767 module:
    • R (Right) to the right input of the amplifier or audio jack.
    • L (Left) to the left input of the amplifier or audio jack.
    • GND to the ground of the amplifier or audio jack.

3. Add an Antenna:

  • Connect a 20–30 cm long wire to the ANT pin for better signal reception.

4. Optional – Add a Speaker:

  • If using a speaker, connect the audio output (R and L) from the TEA5767 module to an amplifier module like PAM8403.
  • Then, connect the amplifier output to a speaker.

Step 3: Arduino Code

Here’s the full code to tune into 93.5 MHz using the TEA5767 module.

#include <Wire.h>
#include <TEA5767Radio.h>

// Create a TEA5767Radio object
TEA5767Radio radio;

void setup() {
  Serial.begin(9600);       // Initialize serial communication
  Wire.begin();             // Start I2C communication
  radio.setFrequency(93.5); // Set frequency to 93.5 MHz
  radio.setMute(false);     // Unmute the radio
  Serial.println("Radio set to 93.5 MHz. Enjoy your music!");
}

void loop() {
  // You can add controls to change frequency here
}

Explanation of the Code:

  1. Libraries: The Wire.h library handles I2C communication, and TEA5767Radio.h makes controlling the TEA5767 easier.
  2. Initialization: radio.setFrequency(93.5) tunes to 93.5 MHz.
  3. Mute/Unmute: Use radio.setMute(false) to enable audio output.

Step 4: Upload Code to Arduino

  1. Open the Arduino IDE.
  2. Install the TEA5767Radio library (via the Library Manager).
  3. Copy-paste the code into the Arduino IDE.
  4. Connect your Arduino to the computer via USB.
  5. Select the correct board and COM port in the IDE.
  6. Click Upload to load the code onto the Arduino.

Step 5: Power and Test

  1. Power the Arduino using a USB cable or a battery.
  2. Plug in headphones or connect a speaker to the TEA5767 module.
  3. Listen to 93.5 MHz!

Optional Features

1. Add Station Tuning Buttons:

You can add buttons to change stations. Connect two push buttons to Arduino pins, and modify the code to increase or decrease frequency.

#define BUTTON_UP 2   // Pin for increasing frequency
#define BUTTON_DOWN 3 // Pin for decreasing frequency
float frequency = 93.5;

void setup() {
  pinMode(BUTTON_UP, INPUT_PULLUP);
  pinMode(BUTTON_DOWN, INPUT_PULLUP);
  radio.setFrequency(frequency);
}

void loop() {
  if (digitalRead(BUTTON_UP) == LOW) {
    frequency += 0.1;
    radio.setFrequency(frequency);
    delay(300);
  }
  if (digitalRead(BUTTON_DOWN) == LOW) {
    frequency -= 0.1;
    radio.setFrequency(frequency);
    delay(300);
  }
}

Troubleshooting

  1. No Sound:
    • Check connections to the audio output.
    • Ensure the TEA5767 is not muted (radio.setMute(false)).
  2. Weak Signal:
    • Attach a longer antenna.
    • Test in an area with better FM reception.
  3. Noise or Static:
    • Add an audio amplifier for better clarity.
    • Use shielded wires for audio connections.

Extensions

  • Use an OLED display to show the current station frequency.
  • Add a rotary encoder for smoother frequency tuning.
  • Build a custom enclosure for your Arduino FM radio project.

Harshvardhan Mishra

Hi, I'm Harshvardhan Mishra. Tech enthusiast and IT professional with a B.Tech in IT, PG Diploma in IoT from CDAC, and 6 years of industry experience. Founder of HVM Smart Solutions, blending technology for real-world solutions. As a passionate technical author, I simplify complex concepts for diverse audiences. Let's connect and explore the tech world together! If you want to help support me on my journey, consider sharing my articles, or Buy me a Coffee! Thank you for reading my blog! Happy learning! Linkedin

Harshvardhan Mishra has 760 posts and counting. See all posts by Harshvardhan Mishra

Leave a Reply

Your email address will not be published. Required fields are marked *