close-circle
Close
0%
0%

Arduino Radio with RDS

I came across a RDA5807FP chip in an old alarm clock and made it into a fully functioning radio with RDS functionality

Similar projects worth following
close
The RDA5807FP radio chip is controlled by the Arduino over I2C. An LCD and keypad shield is used for the display and radio controls.

Currently the radio has the following features:
* Searching up or down the FM band for a channel by pressing the left or right button.
* Changing volume with the up and down buttons.
* Show the current frequency and signal strength.
* Decode RDS to show the name of the current channel.
* Save the last tuned channel and volume setting into Arduino EEPROM and restore it when the Arduino is powered on.

Still needs a little amp so it does not require external speakers.

A few days ago I was cleaning out a small storage room in my house. I found an alarm clock that I had put in there a few years ago because its display was much too bright. My initial intention with it was to dim the display and put it back into use, but that never happened, it got replaced by a simple cheap alarm clock and it ended up in a closet. So I decided to tear it apart to see if there was anything interesting in there and to maybe harvest some components.

Apart from some components I could harvest I noticed a small PCB dangling off the main board marked 'Radio'. It had a single RDA5807FP chip on it and a few additional components. I googled the part number and found a datasheet for the device. Turns out it's an FM radio in a chip! And it's a quite capable one, controllable over I2C!

It turned into a little surprise project! I got one of my Arduinos out and connected the board and some cheap external speakers with a built-in amp. The datasheet of the 5807 nicely describes the functions of the chip's registers. It still took me quite a while to figure out how to get some sound out of the thing. I wanted it to be a learning experience so I didn't look into any code that may already be available to control the 5807. After lots of trial and error and just random pops from the speaker I finally got it to produce some sweet whit noise!

In the process I blew up the 3.3v regulator on the little board by hooking up the ground to the 5V supply on the Arduino, but luckily the 5807 was unharmed. Hence the jumper that I soldered onto the board :)


Switching on the radio and tuning

The sequence to switch the radio on turned out to be:

  • R2: Enable the radio, Enable soft reset
  • R3: Set up the correct band and channel spacing (EU FM band and 100KHz spacing in this case)
  • R5: Setting the correct antenna port, Signal to noise ratio and a volume
  • The other registers are cleared

Now the radio can be switched on by

  • R2: Disabling soft reset, disabling mute and enabling audio output
  • R3: Enable tuning

Once this is done the rest is quite straight forward. Tuning the radio to a frequency is easy by taking into account the current band and channel spacing setting. In my case frequency to tune to = (frequency - 87) / 0.1. I can reverse this formula to get the frequency display on screen when I read the current frequency form the 5807.

The Arduino is constantly communicating with the 5807 by reading its 6 status registers. With this I can update the current frequency, signal strength, RDS etc.

Decoding the channel name

The 5807 also supports RDS which turned out to be a whole new experience to get working. I had no prior knowledge of RDS so finding out how it works was interesting. I found some good documentation about the different RDS messages here: http://www.g.laroche.free.fr/english/rds/groupes/listeGroupesRDS.htm. The 5807 will set a flag when new RDS data is available. Through some more trial and error I found out that when handling an RDS message you best toggle the RDS enable of the 5807 to reset this data flag, otherwise you may be dealing with an old message which can be problematic...

the four RDS blocks are each stored in a separate register C through F. The 5807 only detects errors on block A and B, not on blocks C and D, which contain the actual data! So to read the channel name I first look if there is any new RDS data and if there is that the error bits of block A and B are all 0. Now I can look for the so called group number in block B. If I detect a group A0 or B0 we're receiving channel tuning data that also contains part of the channel name.

The channel name is 8 characters long and transmitted 2 characters at a time in block D. The last two bits of block B tell the offset of the characters in the channel name. Now since the 5807 doesn't tell me anything about the quality of the data I only accept a part of the channel name if I receive the same characters at the same position twice in a row.

ArduinoRadio_v1.1.zip

Updated version of the Arduino sketch with much better RDS support

Zip Archive - 5.88 kB - 09/18/2016 at 20:50

download-circle
Download

radio_module.png

Schematic of the radio module. Requires an external amplifier to give a good volume.

Portable Network Graphics (PNG) - 87.44 kB - 07/18/2016 at 20:36

eye
Preview
download-circle
Download

  • 1 × Arduino Uno
  • 1 × LCD Keypad Shield
  • 1 × RDA5807FP board Comes with a 32KHz crystal and small 10uF cap on the back of the board
  • 1 × Jack plug socket

  • Added better RDS support

    Maarten Janssen09/18/2016 at 20:54 0 comments

    I updated the Arduino sketch to improve RDS support. The following has changed:

    • If the radio received an RDS message during the last update it will poll the radio again to see if there is still more RDS data to process
    • If there is no RDS data then only read registers A and B. Registers C through F are only read when there is new RDS data
    • Don't reset the RDS enable bit when a new message is received
    • Process individual data bytes of the station name instead of pairs of bytes
    • Removed the delay in the program's main loop

    Added the new sketch to the project page: ArduinoRadio_v1.1

View project log

Enjoy this project?

Share

Discussions

Victor Makarov wrote 03/28/2017 at 09:56 point

Your project is really cool. Source code is clear and helps a lot in understanding how the chip works. In function tuneTo I found a bug. R3_CHANNEL bits are not cleared before writing a channel number. You should add the line:

regs[RADIO_REG_3] &= (~R3_CHANNEL);
before writing.

  Are you sure? yes | no

Brown wrote 03/01/2017 at 19:26 point

Ok , i figured out the lcd connections , and started to modify the code to use digital pins , but it wont work, code compiles fine , which resistor values did you use for analog input?

  Are you sure? yes | no

Brown wrote 02/26/2017 at 13:42 point

Hey , i'd like to build your radio , but from scratch , can you tell me which atmega pins the switches go , and which pins connected with the lcd which pins , vcc gnd and contrst i know where to connect but the rest not. 

  Are you sure? yes | no

volvo4 wrote 01/14/2017 at 08:23 point

Hello guys, I have a problem during compilation a program. I downloaded program from this site, and trying to get on my arduino but first of all im getting errors on compilation. Or in another project i have errors that i dont have library. Im using the latest version of arduino 1.8.1 and also i installed uptated library radio. Looking for your help and replay. :)



  Are you sure? yes | no

volvo4 wrote 01/14/2017 at 13:34 point

Ok i solved it by downloading older version of IDE, but still have problem with compilation...


  Are you sure? yes | no

Brown wrote 03/01/2017 at 19:28 point

Did you copy the .c and . h files to arduino directory? if its not there , it cant use it to call the commands in the .ino file the ino is the sketch only , the other 2 files contain the data the ino file calls. You need to copy it.

  Are you sure? yes | no

Atalay Kutlay wrote 07/17/2016 at 08:57 point

Hey, thanks for this great project! Is it possible to do it without i2c ? I have RDA5807M chip. I understand the code but I don't know much about i2c. So I couldn't get how to make it work with my chip. I would be very happy if you could help me a little :)

  Are you sure? yes | no

Maarten Janssen wrote 07/17/2016 at 12:46 point

It shouldn't be too hard to get it working with your chip. As far as I know the only difference between my FP chip and your M chip is that mine has some additional GPIO pins, that I'm not using anyway. The chip only supports i2c, so you'll just have to deal with that :). At first glance looking at both chips' datasheets the radio commands look identical. So I think it should be just a matter of hooking up the right pins. I have a schematic of this project on an old harddrive that should show you how to hookup the chip. I'll look it up and add it here tomorrow. Cheers!

  Are you sure? yes | no

Atalay Kutlay wrote 07/18/2016 at 08:47 point

I think I can handle it if you send me the schematic :) Thank you very much !

  Are you sure? yes | no

Maarten Janssen wrote 07/18/2016 at 20:31 point

I added the radio module's schematic. Probably a bit more elaborate than you actually need and it requires and external amplifier. Hope it works for you!

  Are you sure? yes | no

Atalay Kutlay wrote 07/20/2016 at 12:28 point

Man ! Thank you very much. The only problem I have now is I can't get the station name, but I'm working on it.

  Are you sure? yes | no

Maarten Janssen wrote 07/20/2016 at 19:48 point

Glad to hear that it's working so far :). Getting the station name isn't always working for me as well. It depends a lot on the station... For some it just works, for others it takes a really long time and some just give garbage. That's why I only update the station name if I receive the same byte twice in a row. Just as a fail safe (maybe too safe in some cases)

  Are you sure? yes | no

Atalay Kutlay wrote 07/23/2016 at 11:13 point

Yeah, it's so annoying. My old Nokia E52 phone reads the RDS very well with the same station. I watched some russian videos and their chips work very well. I thought it's about the station, but i tried many other stations. I will update if I can solve the problem :)

  Are you sure? yes | no

Maarten Janssen wrote 09/18/2016 at 21:00 point

Hi, I updated the radio code quite a bit. RDS is now working much better :). The chip requires a good signal though. Check it out if you're still interested.

  Are you sure? yes | no

lightcalamar wrote 01/30/2016 at 11:36 point

Thank you for your kind reply!  Finally resolve this code;

// ================================================

// Code read analog pin for value resistors

#include
#include


#define I2C_ADDR    0x3F // <<----- Add your address here.  Find it from I2C Scanner
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

int a=0;
 
void setup()
{
    lcd.begin (16,2); //  <<----- My LCD was 16x2
    lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
    lcd.setBacklight(HIGH);
    lcd.begin(20, 4);
    // pinMode(A5, INPUT_PULLUP);
}
 
void loop()
{
  a = analogRead(1);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("  analogRead() ");
  lcd.setCursor(0,1);
  lcd.print("  value is :");
  lcd.print(a);
  delay(250);
}

// End

Give me exact code for operated, after change work fine you code.  I have one LCD 20x4 and I2C want to modify your code more content for example " lcd.createChar(1, CHR_STRENGTH[7]); " horizontal bars. .. and more 

I try some codes RDA5807 and very hard working example:http://www.mathertel.de/Arduino/RadioLibrary.aspx , malfunctions, problems with memory and be slow.  I will inform you of my progress. Thanks again. Thomas.

  Are you sure? yes | no

lightcalamar wrote 01/29/2016 at 08:27 point

Nice project!

I have one problem.  Not running or not work my keys manual contruction. This not definition on sketch?

Press any key not work. Help me?

Best Regards! Thanks.

  Are you sure? yes | no

Maarten Janssen wrote 01/29/2016 at 19:51 point

Hi, first off thanks for liking my project :)

So the buttons on the shield I'm using are mapped to analogue values. If you look in the handleKeys function you will find the analogue values used by the keys.

99 = up (volume +)
255 = down (volume -)
408 = left (seek down)
0 = right (seek up)

You can rewrite the switch there to use digital inputs if that's what you're after. The only thing to keep in mind is the debounce code in the if statement above the switch. A keyState of 1023 means that no buttons are pressed, so you'll have to change that to a boolean value for example to determine whether any button is pressed.

Hope this helps you!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates