[其他] RDA5807做了一个DIY收音机,可以收到17个电台

[复制链接]
 楼主| gaoyang9992006 发表于 2023-10-28 11:35 | 显示全部楼层 |阅读模式
南京地区收到如下17个频道
  1. You are tuned on 88.5 MHz | RSSI: 045 dbUv | Vol: 02 | Yes
  2. You are tuned on 89.2 MHz | RSSI: 038 dbUv | Vol: 02 | Yes
  3. You are tuned on 89.7 MHz | RSSI: 047 dbUv | Vol: 02 | Yes
  4. You are tuned on 93.7 MHz | RSSI: 044 dbUv | Vol: 02 | Yes
  5. You are tuned on 95.2 MHz | RSSI: 043 dbUv | Vol: 02 | Yes
  6. You are tuned on 96.6 MHz | RSSI: 042 dbUv | Vol: 02 | Yes
  7. You are tuned on 97.5 MHz | RSSI: 059 dbUv | Vol: 02 | Yes
  8. You are tuned on 98.1 MHz | RSSI: 045 dbUv | Vol: 02 | Yes  
  9. You are tuned on  99.7 MHz | RSSI: 050 dbUv | Vol: 02 | Yes
  10. You are tuned on 100.5 MHz | RSSI: 044 dbUv | Vol: 02 | Yes
  11. You are tuned on 101.1 MHz | RSSI: 054 dbUv | Vol: 02 | Yes
  12. You are tuned on 102.4 MHz | RSSI: 045 dbUv | Vol: 02 | Yes
  13. You are tuned on 103.5 MHz | RSSI: 040 dbUv | Vol: 02 | Yes
  14. You are tuned on 104.3 MHz | RSSI: 051 dbUv | Vol: 02 | Yes
  15. You are tuned on 104.9 MHz | RSSI: 042 dbUv | Vol: 02 | Yes  
  16. You are tuned on 105.8 MHz | RSSI: 045 dbUv | Vol: 02 | Yes
  17. You are tuned on 106.9 MHz | RSSI: 041 dbUv | Vol: 02 | Yes
  1. #include <Adafruit_GFX.h>    // Core graphics library
  2. #include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
  3. #include <SPI.h>
  4. #include <RDA5807.h>
  5. #include <math.h>

  6. RDA5807 rx;

  7. #define TFT_CS         2
  8. #define TFT_RST        3
  9. #define TFT_DC         10
  10. #define TFT_SCLK       4
  11. #define TFT_MOSI       6

  12. /*     默认的SPI接口为
  13. static const uint8_t SS    = 7;
  14. static const uint8_t MOSI  = 6;---SDA
  15. static const uint8_t MISO  = 5;
  16. static const uint8_t SCK   = 4;---SCL
  17. */
  18. Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
  19. //Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

  20. // color definitions
  21. const uint16_t  Display_Color_Black        = 0x0000;
  22. const uint16_t  Display_Color_Blue         = 0x001F;
  23. const uint16_t  Display_Color_Red          = 0xF800;
  24. const uint16_t  Display_Color_Green        = 0x07E0;
  25. const uint16_t  Display_Color_Cyan         = 0x07FF;
  26. const uint16_t  Display_Color_Magenta      = 0xF81F;
  27. const uint16_t  Display_Color_Yellow       = 0xFFE0;
  28. const uint16_t  Display_Color_White        = 0xFFFF;

  29. // The colors we actually want to use
  30. uint16_t        Display_Text_Color         = Display_Color_White;
  31. uint16_t        Display_Backround_Color    = Display_Color_Black;

  32. const size_t MaxString = 32;
  33. char oldTimeString[MaxString]           = "4 14:29:30";
  34. char oldFre[6]="97.5";
  35. void displayUpTime()
  36. {
  37.     unsigned long upSeconds = millis() / 1000;
  38.     unsigned long days = upSeconds / 86400;
  39.     upSeconds = upSeconds % 86400;
  40.     unsigned long hours = upSeconds / 3600;
  41.     upSeconds = upSeconds % 3600;
  42.     unsigned long minutes = upSeconds / 60;
  43.     upSeconds = upSeconds % 60;
  44.     char newTimeString[MaxString] = { 0 };
  45.     sprintf(newTimeString,"%lu %02lu:%02lu:%02lu",days, hours, minutes, upSeconds);
  46.     if (strcmp(newTimeString,oldTimeString) != 0) {
  47.         tft.setTextSize(2);
  48.         tft.setCursor(0,0);
  49.         tft.setTextColor(Display_Backround_Color);
  50.         tft.print(oldTimeString);
  51.         tft.setCursor(0,0);
  52.         tft.setTextColor(Display_Text_Color);
  53.         tft.print(newTimeString);
  54.         strcpy(oldTimeString,newTimeString);
  55.     }
  56. }

  57. // Show current frequency
  58. void showStatus()
  59. {
  60.   char aux[80];
  61.   sprintf(aux,"\nYou are tuned on %.1f MHz | RSSI: %3.3u dbUv | Vol: %2.2u | %s ",rx.getFrequency()/100.0, rx.getRssi(), rx.getVolume(), (rx.isStereo()) ? "Yes" : "No" );
  62.   Serial.print(aux);

  63.   tft.setTextSize(1);
  64.   tft.setTextColor(Display_Backround_Color);
  65.   tft.setCursor(70, 79);
  66.   tft.print(oldFre);

  67.   tft.setTextColor(Display_Text_Color);
  68.   tft.setCursor(70, 79);
  69.   sprintf(oldFre,"%.1f",rx.getFrequency()/100.0);
  70.   tft.print(oldFre);
  71. }

  72. void showHelp()
  73. {
  74.   Serial.println(F("Type U to increase and D to decrease the frequency"));
  75.   Serial.println(F("     S or s to seek station Up or Down"));
  76.   Serial.println(F("     + or - to volume Up or Down"));
  77.   Serial.println(F("     B or b to  Bass  On or Off"));
  78.   Serial.println(F("     0 to use 87-108 MHz (US/Europe)"));
  79.   Serial.println(F("     1 to use 76-91 MHz (Japan)"));
  80.   Serial.println(F("     2 to use 76-108 MHz (world wide)"));
  81.   Serial.println(F("     3 to use 65-76 MHz (East Europe) or 50-65MHz (see bit 9 of gegister 0x06)"));
  82.   Serial.println(F("     4 to use 50-65 MHz"));
  83.   Serial.println(F("     ? to this help."));
  84.   Serial.println(F("=================================================="));
  85.   delay(1000);
  86. }



  87. void setup() {

  88.   Serial.begin(115200);
  89.   while (!Serial);
  90.   Serial.println();

  91.   Wire.begin();  // 初始化I2C总线  
  92.   rx.setup();
  93.   rx.setVolume(2);
  94.   // Select a station with RDS service in your place
  95.   Serial.print("\nEstacao 97.50MHz");
  96.   rx.setFrequency(9750); // It is the frequency you want to select in MHz multiplied by 100.
  97.   delay(250);
  98. //  rx.setLnaPortSel(3); // Trying improve sensitivity.
  99. //  rx.setLnaIcSel(0);
  100.   rx.setAFC(true);    // Sets Automatic Frequency Control
  101.   showHelp();

  102.   tft.initR(INITR_BLACKTAB);  //初始化屏幕
  103.   tft.setFont();//初始化字体
  104.   tft.fillScreen(Display_Backround_Color);
  105.   tft.setTextColor(Display_Text_Color);
  106.   tft.setTextSize(2);
  107.   Serial.println("Hello");
  108.     // a single pixel
  109.   delay(500);
  110.   for(uint8_t i=0;i<128;i++)
  111.   {
  112.     tft.drawPixel(i, 30+(sin(3.14159*i/32.0)*10), ST77XX_GREEN);
  113.   }
  114.   delay(500);
  115.   tft.fillRect( 2,45,30,10,ST77XX_GREEN);
  116.   delay(500);
  117.   tft.drawRect(40,45,30,10,ST77XX_GREEN);
  118.   delay(500);
  119.   tft.fillCircle( 90, 50, 5, ST77XX_GREEN);
  120.   tft.drawCircle(110, 50, 5, ST77XX_GREEN);
  121.   delay(500);
  122.   tft.drawFastHLine(0, 65, tft.width(), ST77XX_RED);
  123.   delay(500);
  124.   for(uint8_t x=4;x<128;x=x+12)
  125.   {
  126.     tft.drawFastVLine(x, 65, 5, ST77XX_BLUE);
  127.   }
  128.   delay(500);
  129.   tft.drawRect(2,75,tft.width()-(2*2),15,ST77XX_GREEN);
  130.   tft.drawRect(4,77,18,11,ST77XX_BLUE);
  131.   tft.drawRect(67,77,58,11,ST77XX_BLUE);
  132.   tft.setTextSize(1);
  133.   tft.setCursor(7, 77+2);
  134.   tft.print("FM");
  135.   tft.setCursor(70, 79);
  136.   tft.print(oldFre);
  137.   tft.setCursor(104, 77+2);
  138.   tft.print("MHz");
  139. }

  140. void loop() {
  141.   // put your main code here, to run repeatedly:
  142.   displayUpTime();
  143.   delay(100);
  144.     if (Serial.available() > 0)
  145.   {
  146.     char key = Serial.read();
  147.     switch (key)
  148.     {
  149.     case '+':
  150.       rx.setVolumeUp();
  151.       break;
  152.     case '-':
  153.       rx.setVolumeDown();
  154.       break;
  155.     case 'B':
  156.       rx.setBass(true);
  157.       break;
  158.     case 'b':
  159.       rx.setBass(false);
  160.       break;      
  161.     case 'U':
  162.     case 'u':
  163.       rx.setFrequencyUp();
  164.       break;
  165.     case 'D':
  166.     case 'd':
  167.       rx.setFrequencyDown();
  168.       break;
  169.     case 'S':
  170.       rx.seek(RDA_SEEK_WRAP, RDA_SEEK_UP, showStatus);
  171.       break;
  172.     case 's':
  173.       rx.seek(RDA_SEEK_WRAP, RDA_SEEK_DOWN, showStatus);
  174.       break;
  175.     case '0':  
  176.     case '1':
  177.     case '2':
  178.     case '3':
  179.       rx.setBand( key - 48 );
  180.       rx.setBand3_50_65_Mode(1); // Band 3 will work from  65 to 76 MHz;
  181.       rx.setFrequencyToBeginBand();
  182.       Serial.print(F("\n**** Switching to band: "));
  183.       Serial.print(rx.getBand());
  184.       break;
  185.     case '4':
  186.       // ATTENTION: The functions setFrequencyToBeginBand and setFrequencyToEnBand do not work for 50-65MHz setup. You have to control it by yourself.
  187.       //            Also, you must control the band limits from 50 to 65 MHz. The setFrequencyUp and setFrequencyDown do not work properly.
  188.       rx.setBand(3);
  189.       rx.setBand3_50_65_Mode(0); // Band 3 will work from  50 to 65 MHz;
  190.       rx.setFrequency(5500); // 55 Mhz; rx.setFrequencyDown and rx.setFrequencyUP, rx.setFrequencyToBeginBand() and rx.setFrequencyToEndBand() do not work properly for this setup;
  191.       Serial.print(F("\n**** Switching to band: 3 from 50 to 65 MHz) "));
  192.       break;  
  193.       break;
  194.     case '?':
  195.       showHelp();
  196.       break;
  197.     default:
  198.       break;
  199.     }
  200.     delay(200);
  201.     showStatus();
  202.   }
  203.   delay(5);

  204. }


评论

晒图地址 https://bbs.21ic.com/icview-3339954-1-1.html  发表于 2023-11-16 16:42
 楼主| gaoyang9992006 发表于 2023-10-28 11:39 | 显示全部楼层
另外可以在搜索的回调打印状态函数先判断信号强度,确定是电台再打印。
 楼主| gaoyang9992006 发表于 2023-10-28 11:40 | 显示全部楼层
又多收到一个台
You are tuned on 101.7 MHz | RSSI: 042 dbUv | Vol: 02 | Yes
 楼主| gaoyang9992006 发表于 2023-10-28 11:51 | 显示全部楼层
  1. // Show current frequency
  2. void showStatus()
  3. {
  4.   char aux[80];
  5.   if(rx.getRssi()>15)
  6.   {
  7.     sprintf(aux,"\nYou are tuned on %.1f MHz | RSSI: %3.3u dbUv | Vol: %2.2u | %s ",rx.getFrequency()/100.0, rx.getRssi(), rx.getVolume(), (rx.isStereo()) ? "Yes" : "No" );
  8.     Serial.print(aux);

  9.     tft.setTextSize(1);
  10.     tft.setTextColor(Display_Backround_Color);
  11.     tft.setCursor(70, 79);
  12.     tft.print(oldFre);

  13.     tft.setTextColor(Display_Text_Color);
  14.     tft.setCursor(70, 79);
  15.     sprintf(oldFre,"%.1f",rx.getFrequency()/100.0);
  16.     tft.print(oldFre);
  17.   }

  18. }
 楼主| gaoyang9992006 发表于 2023-10-28 11:55 | 显示全部楼层
本帖最后由 gaoyang9992006 于 2023-10-28 11:58 编辑

也可以多重条件判断再确定显示
  1. // Show current frequency
  2. void showStatus()
  3. {
  4.   char aux[80];
  5.   if(rx.isStereo()&&(rx.getRssi()>15))
  6.   {
  7.     sprintf(aux,"\nYou are tuned on %.1f MHz | RSSI: %3.3u dbUv | Vol: %2.2u | %s ",rx.getFrequency()/100.0, rx.getRssi(), rx.getVolume(), (rx.isStereo()) ? "Yes" : "No" );
  8.     Serial.print(aux);

  9.     tft.setTextSize(1);
  10.     tft.setTextColor(Display_Backround_Color);
  11.     tft.setCursor(70, 79);
  12.     tft.print(oldFre);

  13.     tft.setTextColor(Display_Text_Color);
  14.     tft.setCursor(70, 79);
  15.     sprintf(oldFre,"%.1f",rx.getFrequency()/100.0);
  16.     tft.print(oldFre);
  17.   }

  18. }
coody 发表于 2023-10-30 13:45 | 显示全部楼层
RDA5807还是不错的,几年前做过不少,其电路简单,带耳放,带音量,立体声分离度高,关键还很便宜。
还做了不少手调DSP全波段收音机也很好。最简单调幅收音机TA7642也玩过。
 楼主| gaoyang9992006 发表于 2023-10-30 19:13 | 显示全部楼层
coody 发表于 2023-10-30 13:45
RDA5807还是不错的,几年前做过不少,其电路简单,带耳放,带音量,立体声分离度高,关键还很便宜。
还做了 ...

嗯,还在优化中。
准备打个板子,现在飞线的,不方便。板子画好了,再检查一下。
另外准备用国产的BK1088做一个全波段的。芯片到手了,现在还差测试模块的PCB。过几天就可以测试了。
coody 发表于 2023-10-31 18:56 | 显示全部楼层
gaoyang9992006 发表于 2023-10-30 19:13
嗯,还在优化中。
准备打个板子,现在飞线的,不方便。板子画好了,再检查一下。
另外准备用国产的BK1088 ...

都可以做得很小,3cmx3cm就行了。
 楼主| gaoyang9992006 发表于 2023-11-1 08:46 | 显示全部楼层
coody 发表于 2023-10-31 18:56
都可以做得很小,3cmx3cm就行了。

比这还小,13mm*15.5mm
方便插面包板测试就行了。
coody 发表于 2023-11-1 14:09 | 显示全部楼层
gaoyang9992006 发表于 2023-11-1 08:46
比这还小,13mm*15.5mm
方便插面包板测试就行了。

我的带显示,还有多个按键,所以不能太小了。不带显示的则可以做这么小。
 楼主| gaoyang9992006 发表于 2023-11-1 14:30 | 显示全部楼层
coody 发表于 2023-11-1 14:09
我的带显示,还有多个按键,所以不能太小了。不带显示的则可以做这么小。 ...

挺好,晒晒看看,欣赏一下。
zhuls 发表于 2023-11-2 16:41 | 显示全部楼层
你这个有加高放吗?RSSI这么好!我做的没有加高放直接复用3.5音频线当天线,在城郊的室内,最好的才23.
 楼主| gaoyang9992006 发表于 2023-11-2 22:39 | 显示全部楼层
zhuls 发表于 2023-11-2 16:41
你这个有加高放吗?RSSI这么好!我做的没有加高放直接复用3.5音频线当天线,在城郊的室内,最好的才23.[em: ...

没直接一段电线当天线。
fangsir1996 发表于 2023-11-16 12:13 | 显示全部楼层
zhuls 发表于 2023-11-2 16:41
你这个有加高放吗?RSSI这么好!我做的没有加高放直接复用3.5音频线当天线,在城郊的室内,最好的才23.[em: ...

用耳机地线当天线的电路搞不清楚,厂家的电路太复杂,网上的电路很多不一样,不知道哪种好。
springvirus 发表于 2023-11-16 15:25 | 显示全部楼层
晒下硬件看看啊
 楼主| gaoyang9992006 发表于 2023-11-16 16:42 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:如果你觉得我的分享或者答复还可以,请给我点赞,谢谢。

2048

主题

16367

帖子

221

粉丝
快速回复 在线客服 返回列表 返回顶部