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



  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)



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).