element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs Controlling the RDA5807SP FM Radio Receiver with the Raspberry Pi
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: packetgeek
  • Date Created: 19 Jan 2014 6:33 AM Date Created
  • Views 10443 views
  • Likes 3 likes
  • Comments 37 comments
  • raspberry
  • pi
  • fm
  • proof-of-concept
  • radio
Related
Recommended

Controlling the RDA5807SP FM Radio Receiver with the Raspberry Pi

packetgeek
packetgeek
19 Jan 2014

I received a handful of gift certificates for Christmas.  I used one to purchase a few breakout boards, one of them an RDS5807SP-based FM radio receiver (see Amazon.com: FM Radio Receiver Module -- Arduino Compatible: Everything Else).  Although it's designed to work with the Arduino, it is possible to get it working with the Raspberry Pi.  The very nice part is that it comes with an I2C-based control interface.

 

Before you purchase one, there's a few limitations (keep in mind I paid less than $2 for the thing).  In short, the Raspberry Pi provides power and control signals and DOES NOT receive the audio back.  Instead, the audio is output through the headphone jack. (I have "connect to USB sound card" on my to-do list.)

 

In any case, following are my notes on getting it up and running for the first time.  It only took a few hours (4?) in doing the research and

 

1) Parts list

 

  • One Raspberry Pi (with the usual power supply and network connections)
  • One Cobber interface (for connecting the GPIO header to the breadboard)
  • One breadboard (thanks to Drew Fustini!)
  • The aforementioned FM Radio Receiver Module
  • A handful of breadboard wires

 

2) Initially, I attempted to use just the I2C software (described here) that gets installed by running

 

    apt-get install i2c-tools

 

Sadly, I couldn't figure out how to control the receiver with just the i2cset and i2cget commands.  Note: If anyone else plays with this, please omit this step and tell me if installation is still needed.  (I seem to think that it is.)

 

3) Frustrated, I turned to Google.  After some reading, I noticed a few people indicating that the RDA5807xx chip is a clone of the TEA5767, so I went looking for anyone who'd hooked that to the Raspberry Pi.  This led me to Emmanuel Granatello's page on setting up the FM Radio Receiver on Raspberry Pi.   He didn't provide his code, so I kept looking.  I also ran across a number of videos showing the same thing, along with using WiringPi's gpio tool to set up the connection to the receiver.  Mixing all of that together in another search, I finally stumbled across "Raspberry Pi • View topic - I2C, wiringPi & tea5767", which does have the basic code needed to get the receiver working.  Just in case the page disappears, the working code is:

#include <wiringPi.h>

#include <wiringPiI2C.h>

#include <stdio.h>

#include <stdlib.h>

int main( int argc, char *argv[]) {

  printf ("RPi - tea5767 Philips FM Tuner v0.3 \n") ;

  unsigned char radio[5] = {0};

  int fd;

  int dID = 0x60; // i2c Channel the device is on

  unsigned char frequencyH = 0;

  unsigned char frequencyL = 0;

  unsigned int frequencyB;

  double frequency = strtod(argv[1],NULL);

  frequencyB=4*(frequency*1000000+225000)/32768; //calculating PLL word

  frequencyH=frequencyB>>8;

  frequencyL=frequencyB&0XFF;

  printf ("Frequency = "); printf("%f",frequency);

  printf("\n"); // data to be sent

  radio[0]=frequencyH; //FREQUENCY H

  radio[1]=frequencyL; //FREQUENCY L

  radio[2]=0xB0; //3 byte (0xB0): high side LO injection is on,.

  radio[3]=0x10; //4 byte (0x10) : Xtal is 32.768 kHz

  radio[4]=0x00; //5 byte0x00)

 

if((fd=wiringPiI2CSetup(dID))<0){

printf("error opening i2c channel\n\r");

}

write (fd, (unsigned int)radio, 5) ;

return 0;

}

Save the above as "radio.c" and compile it with "gcc -o radio radio.c -lwiringPi".  Credit for the above code goes to "halfluck" on the Raspberry Pi web site.

 

Note: the above code is very limited and doesn't exploit all of the controls available on the chipset.  I plan on expanding the above, once I get a better idea of what's involved.

 

4) Once you've done all of the above, the receiver is connected to the Raspberry Pi, and the Pi has booted, you can test the interface by running "i2cdetect -y 1".  The output should look something like:

  root@raspberrypi:~/work# i2cdetect -y 1
       0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
  00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
  10: 10 11 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
  20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
  30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
  40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
  50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
  60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
  70: -- -- -- -- -- -- -- --  

Note: if you see only dashes in the above, the Pi is not "seeing" the receiver.  Check your connections.  (Initially, I had the Cobbler connected to the header backwards.)

 

If you see only "21 22" in the above, it means that your cable is likely connected properly.  You'll next want to run wiringPi's gpio tool and then the radio application.  I was able to hear a local radio station by running:

 

  gpio load i2c

  gpio i2cd

  ./radio 98.7

 

Note: the first line is required as it (supposedly) renumbers the headers and causes the i2c interface to reset.  The second line is optional.  I use it to "see" when the i2c interface is "online".  When "60" shows up in the output, it's okay to run the "radio" command.  The "98.7" in the above is the frequency (in MHz) of the local radio station.

 

That's about it.  The above code is halfluck's proof-of-concept.  I plan on doing horrible things to it (adding error detection and command line defaults, adding more controls, slapping a web front end on it, etc.), once I've dug into the chip specs and have figured out what the board will and won't support.  I'll eventually get back to editing this code.  Keep an eye out here.

 

Update (26 Dec 2014): The code for the various commands is attached. Updated notes to follow (they're a bit lengthy).

  • Sign in to reply
  • e14 Contributor
    e14 Contributor over 11 years ago

    Thank you for your fast response. I'm sorry for your loss, and obviously family has priority above anything else.

    When you have time later on, i'll just put my experience here.

    What works:

    radio, mute, and unmute.

    What doens't seem to do anything:

    tune

    searchdn

    searchup

    Can it be that i did something wrong compiling these scripts. They don't give an error, but also don't change the frequence. Also no output on the screen.

    Thank you in advance for your time.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • packetgeek
    packetgeek over 11 years ago in reply to packetgeek

    Also, try running "status" after running the search command.  It'll tell the frequency to which it changed.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • packetgeek
    packetgeek over 11 years ago

    Not a problem.  Writing this code helps me practice and relearn a few things.

     

    Syntax for the search functions is just the command (they don't require arguments).  Use either command after you've already tuned to a station with "tune".  This will cause the chip set to tune to the next (adjacent) radio station.  These might not work well if background noise is a bit high.  The chip set offers the ability to select noise levels.  I'll experiment with those next.  It may take a few weeks for me to work on them.  There was a death in our family this week and my life is a bit "full" at the moment.  While you're waiting: suggest running the command multiple times.  Most often the noise will be limited to only one portion of the FM band.


    Question: did you have to install wiringPi or did the code work without it?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • e14 Contributor
    e14 Contributor over 11 years ago

    I want to thank you for this great piece of software. I just installed my radiochip, and it worked like a charm. To tune to a channel works directly, muting works. But what i can't do is use the searchup and searchdn functions. I don't know how to use them, can you please give me an example of the syntax. I have never programmed in C, and i really don't understand what arguments i need to give. Without arguments nothing seems to happen. Thank you in advance for your help.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • packetgeek
    packetgeek over 11 years ago

    Merry Christmas to you also.  I've attached my code to the original post (scroll up from here).  It's a bit klugy but it works.  It should also work for the TEA5767/TEA5768 chip sets and (possibly) other chip sets in the RDA5807 series.  I want to play with the RDA5807M next, if I can find one.  If not, I have a Si4703 that performs the same function.  It's only drawback is that it lacks the I2C interface, which means I'll have to solder connectors and learn to program a new interface (would like to become a bit more comfortable with the I2C interface first).

     

    Better organized notes on the RDA5807SP coming shortly.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
<>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube