FM Radio with Arduino Uno/Nano and TEA5767 radio module

In this post we will build a FM radio using Arduino Uno (Arduino Nano also ok) with a radio module TEA5756. The C code is taken from Csongor Varga’s github (https://github.com/nygma2004/tea5657_station_selector). The libraries used are written by  Marcos R. Oliveira (https://github.com/mroger/TEA5767). You can also check out Csongor youtube page (https://www.youtube.com/watch?v=yp0HVGjakMs).

You have to download the zip file for TEA5767N libraries from the above github and add the zip file to your Arduino library. See pic below.

This project is a great learning experience for C code, Arduino controller and a little electronics. And it’s a very practical project. I am definitely making this project permanent. Just like the ESP8266 weather report project. A short video of the FM radio.

Below is the C code from Csongor Varga’s github. I will include the step by step explanation of the C code later on.

#include <Wire.h>
#include <TEA5767N.h>


//Constants:
TEA5767N Radio = TEA5767N(); // Using standard I2C pins A4 and A5

#define MUTEPIN    2         // D2 pin
#define STATIONPIN 3         // D3 pin

//Variables:
int flag=0;
double stations[] = {95.0, 98.7, 93.3}; // Your station presets
int currentstation = 0;
int maxstation = 2; // Last item in the stations array (zero indexed)
bool mutestate = 0;





void setup() {
  // put your setup code here, to run once:
  //Init
  Serial.begin(9600);
  Serial.println("Arduino FM radio example");

  pinMode(MUTEPIN, INPUT); 
  pinMode(STATIONPIN, INPUT); 
  
  Radio.selectFrequency(stations[currentstation]); //power on with the first station
  delay(250); // Added this delay to ensure tuning stats read from the module are correct - module has time to tune properly

}

void loop() {
  // put your main code here, to run repeatedly:
  if (digitalRead(MUTEPIN)==LOW) {
    mutestate = !mutestate;
    if (mutestate) {
      Serial.println("Muting radio");
      Radio.mute();
    } else {
      Serial.println("Unmuting radio");
      Radio.turnTheSoundBackOn();
    }
  }

  if (digitalRead(STATIONPIN)==LOW) {
    Serial.println("Tuning to next station");
    currentstation++;
    if (currentstation>maxstation) {
      currentstation = 0;
    }
    Radio.selectFrequency(stations[currentstation]); 
    flag = 0; // Flag to fetch stats and display over serial
    delay(250); // Added this delay to ensure tuning stats read from the module are correct - module has time to tune properly  
  }

  if (flag == 0) {
    Serial.print("Current freq: ");
    Serial.print(Radio.readFrequencyInMHz());
    Serial.print("MHz Signal: ");
    Serial.print(Radio.isStereo() ? "STEREO" : "MONO");
    Serial.print(" ");
    Serial.print(Radio.getSignalLevel());
    Serial.println("/15");
    flag=1;
  }
   
  delay(100); // General delay

}