Home » ESP32 and Si4703 FM radio example

ESP32 and Si4703 FM radio example

by shedboy71

The Si4702/03 FM radio receiver family increases the ease and attractiveness of adding FM radio reception to mobile devices through small size and board area, minimum component count, flexible programmability, and superior, proven performance.

The highly flexible functionality of these ICs caters to the subjective nature of audio preferences and variable FM broadcast environments worldwide.

Features

Worldwide FM band support (76–108 MHz)
Seek tuning
Automatic frequency control (AFC)
Automatic gain control (AGC)
Excellent overload immunity
Programmable de-emphasis (50/75 µs)
Adaptive noise suppresion

Parts List

Name Link
ESP32
Si7403 FM radio module
Connecting cables

Layout

Code

In this example sparkfun does all the hard graft here – https://github.com/sparkfun/Si4703_FM_Tuner_Evaluation_Board

This is the default example slightly modified for the micro:bit and 2 local radio stations I used for testing

 

#include <SparkFunSi4703.h>
#include <Wire.h>

int resetPin = 0;
int SDIO = 20;
int SCLK = 19;
int SCT = 2;

Si4703_Breakout radio(resetPin, SDIO, SCLK, SCT);
int channel;
int volume;
char rdsBuffer[10];

void setup()
{
  Serial.begin(9600);
  Serial.println("\n\nSi4703_Breakout Test Sketch");
  Serial.println("===========================");  
  Serial.println("a b     Favourite stations");
  Serial.println("+ -     Volume (max 15)");
  Serial.println("u d     Seek up / down");
  Serial.println("r       Listen for RDS Data (15 sec timeout)");
  Serial.println("Send me a command letter.");
  

  radio.powerOn();
  radio.setVolume(0);
}

void loop()
{
  if (Serial.available())
  {
    char ch = Serial.read();
    if (ch == 'u') 
    {
      channel = radio.seekUp();
      displayInfo();
    } 
    else if (ch == 'd') 
    {
      channel = radio.seekDown();
      displayInfo();
    } 
    else if (ch == '+') 
    {
      volume ++;
      if (volume == 16) volume = 15;
      radio.setVolume(volume);
      displayInfo();
    } 
    else if (ch == '-') 
    {
      volume --;
      if (volume < 0) volume = 0;
      radio.setVolume(volume);
      displayInfo();
    } 
    else if (ch == 'a')
    {
      channel = 1020; // Rock FM
      radio.setChannel(channel);
      displayInfo();
    }
    else if (ch == 'b')
    {
      channel = 1028; // BBC R4
      radio.setChannel(channel);
      displayInfo();
    }
    else if (ch == 'r')
    {
      Serial.println("RDS listening");
      radio.readRDS(rdsBuffer, 15000);
      Serial.print("RDS heard:");
      Serial.println(rdsBuffer);      
    }
  }
}

void displayInfo()
{
   Serial.print("Channel:"); Serial.print(channel); 
   Serial.print(" Volume:"); Serial.println(volume); 
}

 

 

Output

Open the serial monitor – this was me testing the example above

Si4703_Breakout Test Sketch
===========================
a b Favourite stations
+ – Volume (max 15)
u d Seek up / down
r Listen for RDS Data (15 sec timeout)
Send me a command letter.
Channel:1020 Volume:0
Channel:1020 Volume:1
Channel:1020 Volume:2
Channel:1020 Volume:3
Channel:1020 Volume:4
Channel:1020 Volume:5
Channel:1028 Volume:5

You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.