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
- Arduino Uno (or any compatible Arduino board)
- TEA5767 FM Receiver Module
- 3.5mm Audio Jack (for headphones or speaker connection)
- Speaker (optional, if you want louder audio)
- Audio Amplifier Module (optional, like PAM8403 for driving speakers)
- Jumper Wires
- Breadboard
- Rotary Encoder or Buttons (for station tuning, optional)
- Power Source (USB cable or battery)
- Antenna (e.g., a simple wire for better reception)
Step 1: Understand the TEA5767 Module
The TEA5767 module has the following pins:
- GND: Ground
- VCC: Power supply (3.3V or 5V)
- SDA: I2C Data Line
- SCL: I2C Clock Line
- Right Audio Out (R): Audio signal for the right channel
- Left Audio Out (L): Audio signal for the left channel
- 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:
- Libraries: The
Wire.h
library handles I2C communication, andTEA5767Radio.h
makes controlling the TEA5767 easier. - Initialization:
radio.setFrequency(93.5)
tunes to 93.5 MHz. - Mute/Unmute: Use
radio.setMute(false)
to enable audio output.
Step 4: Upload Code to Arduino
- Open the Arduino IDE.
- Install the TEA5767Radio library (via the Library Manager).
- Copy-paste the code into the Arduino IDE.
- Connect your Arduino to the computer via USB.
- Select the correct board and COM port in the IDE.
- Click Upload to load the code onto the Arduino.
Step 5: Power and Test
- Power the Arduino using a USB cable or a battery.
- Plug in headphones or connect a speaker to the TEA5767 module.
- 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
- No Sound:
- Check connections to the audio output.
- Ensure the TEA5767 is not muted (
radio.setMute(false)
).
- Weak Signal:
- Attach a longer antenna.
- Test in an area with better FM reception.
- 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.