element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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 8599 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
  • liranwinter
    liranwinter over 8 years ago

    Hi Tim,

    After reading the whole post, I must say, your help and dedication here, that's just amazing.

    I have lots of problems running the tea5767 on the rpi-3. I tried an old code from an old post using rpi B+ , and it worked, but not for rpi-3, and the code is unsupported anymore.

    I searched through a lot of places on how to run Fm radio using rpi, you acctually the only one who really studied everything to the bone... =D

    I'm speachless, running step by step everything that is written here, it actually worked, even if sometimes there were some issues, they all fixed later in the next comments, which I followed and apply...

     

    damn man... i bow!

    FM radio is up and running like a charm, and I finally actually learned how to use the bus and i2c .... u should get a medal!

     

    couldn't just use the code... I had to registering to this forum just to write u "Thanks" .

    =)

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

    Any luck?

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

    Hi Tim,

    Thanks for the feedback...

    Wow.. seems like you've invested a good amount of time in to theses ...

     

    As for the amp, I had connected it to  one of the USB ports on Pi itself.

     

    For ground well, I had connected the TEA & Amp to Pi's ground so nothing special so to speak.

    Next time i'll just connect the 3.5 mm female to the TEA output, the only problem I see is that the volume was extremely low when I had tried that setup (during the first try when I was getting only static).

     

    But I guess it will be a good way to check if AMP was the culprit or not.

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

    Rohan,

     

    I enjoyed working with these boards.  I managed to acquire: TEA5767, Si4703, Si4707, RDA5807SP, and the Si4735.  The first four were acquired from Amazon, the Si4735 from eBay.  The easiest to work with was the TEA5767 (and RDA5807 in TEA5767 mode).  The Si4703 was also fun in that it has RDS capability (though I need to put more time in on the RDS decoder).  I've managed to control the TEA5767 to a Raspberry Pi and a Cubietruck.  I'm trying to work out how to connect it to a NodeMCU so that I can control it via Wi-Fi (and not tie up a RPi or the Cubietruck).  I've connected all of them to an old Squeezebox without issue.

     

      Keeping in mind that the receiver boards are designed to drive cheap headphones, there's a couple possibilities (I'm guessing here):

     

    1) Static electricity (from handling or even through the antenna)

     

    About the only countermeasure is care in handling. 

     

    2) Issues with the connection to the amplifier

     

    I'm thing that there might be sufficient impedance mismatch that the receiver is stressed enough that it stops working after awhile.  If it happens to your third board, this is a likely concern.  When it was working, was the receiver chip warm? 

     

    There may also be some sort of voltage feedback.  If you're using two separate power supplies, you might have a floating ground issue.

     

    I'm hoping that you have better luck with your effort.  For your next one, I'd recommend running the reciever, without the amplifier, for a few days.

     

    - Tim

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • rohanxtreme
    rohanxtreme over 8 years ago in reply to shabaz

    Hi Shabaz,

    I was finally able to put some time in this.

     

    I used a new TEA and rewired everything and it worked on the first go.

    Even the Amp worked without any distance issues, but then I ran in to some issues (after 20-30 min. of playing).

     

    I've detailed the same  in the reply in the same thread.

    Hopefully 3rd time will be a charm for me [;)]

    • 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 © 2025 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.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube