logo elektroda
logo elektroda
X
logo elektroda

Internet radio and audio file player on ESP32-S3

MAJSTER XXL 101445 1232
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #991 21488556
    robgold
    Level 20  
    @hevet, Corrected. Thank you. I have already uploaded the new files. As you can see, despite many tests, sometimes I miss something.
  • ADVERTISEMENT
  • #992 21490685
    DJCheester
    Level 26  
    robgold wrote:
    Yes, they should be on the encoder PCB. I left a place for them on my PCB just in case I use the encoder itself, but correctly they should be as close as possible to the place where the "pins" are created, i.e. at the encoder itself. If you unplug the encoder then these lines are unconnected. The only thing that may remain is a 100nF capacitor between 3.3V and GND for the encoder power supply line.
    .

    Actually this volume change on switching was due to the capacitors.

    Thanks and regards.

    I still have a question, how to control this radio via the page.

    I have a hotspot made on my phone with shared internet and I wanted to access the radio site using the computer but when the radio receives the stream it does not find the radio network in the computer ?

    How do I do this?

    Greetings ...
  • #993 21490688
    hevet
    Level 16  
    Do you also have your computer connected to this hotspot? You enter the radio's IP address via the website.
  • ADVERTISEMENT
  • #994 21490693
    DJCheester
    Level 26  
    Yes, I can also connect my computer to a hotspot.

    And the question is whether it is possible to share the net from the same phone and at the same time control the radio with the same phone?

    Regards...
  • #995 21490695
    hevet
    Level 16  
    You must have the radio and the computer hooked up to the same hotspot, otherwise the computer will not 'see' the radio's page.
  • #996 21490698
    DJCheester
    Level 26  
    Ok, but on the phone itself is it possible, for example, when the radio is taken outdoors?

    Greetings ...
  • #997 21490739
    Lechuuu
    Level 13  
    So today I poked around in colleague @robgold's code because I had a bit of a problem with a dimmer that never worked for me - I have an SH1122 display (2.08 inches). Probably the u8g2 library doesn't support display brightness for this display, this I had to use the setContrast() function. In addition, I made the switch to power-saving mode (turning off the display) which is activated after 120 seconds (you can freely change it according to your needs). Now you can sit at night and the display doesn't shine like a torch, and it will also have a positive effect on the life of the OLED.

    Simply change:

    void displayDimmerTimer()
    {
      displayDimmerTimeCounter++;
      if (displayActive == true)
      { 
        displayDimmerTimeCounter = 0;
        displayDimmer(0);
      }
      if (displayDimmerTimeCounter >= displayAutoDimmerTime)
      {
        displayDimmer(1); // wywolujemy funkcje przyciemnienia z parametrem 1 (załacz)
        displayDimmerTimeCounter = 0;
      }
    
    }
    .

    to

    void displayDimmerTimer()
    {
      displayDimmerTimeCounter++;
      if (displayActive == true)
      { 
        displayDimmerTimeCounter = 0;
        u8g2.setPowerSave(0); // wybudzamymy wyświetlacz z trybu oszczędzania energii
        u8g2.setContrast(128); // ustawiamy kontrast wyświetlacza w wartościach 0 - 255
        displayDimmer(0);
      }
    
      if (displayDimmerTimeCounter >= displayAutoDimmerTime)
      {
        displayDimmer(1); // wywolujemy funkcje przyciemnienia z parametrem 1 (załacz)
        u8g2.setContrast(30); // ustawiamy kontrast w wartościach 0 - 255.
      }
    
      if (displayDimmerTimeCounter >= 120) // po 120 sekundach wyświetlacz przełączamy w tryb oszczędzania energii (wyłączamy), wartości w przedziale 0-255.
      {
        u8g2.setPowerSave(1);
      }
    }
    .
  • #998 21490807
    robgold
    Level 20  
    @Lechuuu
    Super, very cool. The dimmer is based on the register settings in the SSD1322 itself so it won't work properly on other OLEDs. I see another very good tech use for the Power Save function. This display (3.12 inches) is incredibly 'choppy' with its inverter when powered up. I have added some filters to it but this only "masks" the problem. Unfortunately, when listening quietly to the radio in the evening, you can hear this inverter. Turning the OLED off into PowerSave mode on demand also turns off the inverter so it is silent :) .
  • #999 21490848
    wirbud
    Level 13  
    ROBGOLD - I bow low and thank you..... as if you read the minds of many music lovers ;-)

    The WEB interface is divine!

    I can say with a clear conscience that yoRadio and MiniWebRadio are getting off.
    If I had to tell you one more quiet dream about the radio....., I would like the radio to slightly turn down the station's content before the clock strikes even, regardless of the station, and to announce in a friendly voice that it will be "twelve o'clock precisely"...... (Wolle has this function in his examples for the library - and uses it in his mini-webradio).
    A wonderful thing for late-night listening at the weekend.... when one forgets and here it is just past 2 o'clock precisely.... ;-)
  • #1000 21490971
    Lechuuu
    Level 13  
    @robgold in this small display also the inverter hums a bit, especially during startup. But after that it's reasonably quiet. But on the PCM output I don't get any murmur from the inverter, audio clean.... maybe with an oscilloscope something would show, but yes it is ok. After Sunday I'll have the SSD1322 then I'll compare.
  • #1001 21490972
    hevet
    Level 16  
    @robgold in DisplayMode=1 is
    if (stationNameStream == "")          // jezeli nie ma równiez stationName
          {
            stationStringScroll = "---" ;
          }      // wstawiamy trzy kreseczki do wyswietlenia
    .
    if the station is not transmitting any information then three bars are displayed, but in mode 1, at this moment we do not know what station we are listening to, after changing to
    if (stationNameStream == "")          // jezeli nie ma równiez stationName
          {
            stationStringScroll = String(StationNrStr) + "." + stationName; //wstawiamy nr stacji + nazwę stacji
          }

    the number and name of the station from the bank will be displayed.
  • ADVERTISEMENT
  • #1002 21491012
    wirbud
    Level 13  
    After several hours of listening ... it only resets on FLACs for me.
    Jazz on 128 kbps in mp3 is unlistenable. It hurts my ears so much that I'm thinking how to set up my server with banks and get rid of these ear-crippling streams in my headphones. Is it enough to change the addresses locally stored on the SD card ?

    I close the case ;-) because there is nothing to bury anymore ;-) .

    Music player with a display showing Linn Jazz radio station. .
  • #1003 21491048
    robgold
    Level 20  
    @wirbud
    I'm glad you like it and thank you for your kind words. This is a very simple not to say primitive server and site. It was to give the possibility to control the radio from a phone or computer. Websockets and json data transfer are still missing but I will slowly add them. My case also closed since yesterday but I can already see that the LED - Power - is missing. If the display goes out completely, you can forget to switch off the radio.

    As for the stations, the Jazz ones are not the worst anyway, as often 320kbps is flying. Our Polish smoothjazz.com.pl broadcasts very decently. It's as if they were broadcasting from mp2 files. As far as I know, the creator of this radio used to work at a normal radio station, and the DynaSoft programme (Dyna Mix, Dyna Emisja) used to be the king of stations (and a lot of stations use it today, e.g. RMF). This program just used mp2 files to get better quality and date files to describe songs.
    If you don't plan to do an update of a particular bank from the web then just swap the addresses in the bank on the SD card. That's why I didn't introduce a global "update" of the banks so that you could keep e.g. Bank1 and Bank2 with your stations and update the rest from the network.

    Clock:
    Wollie's library doesn't allow you to mix audio from the stream along with telling the time. You have to turn one off and run the other. Even someone recently asked this question on GitHub -> Link . To make this cool you would have to slowly mute the audio, turn off the stream , read the time and turn on the stream. The problem is that often turning the stream back on will start playing ads. To think about.

    Casing:
    Very nicely this top case came out of that 'carbon' board. Print yourself an IR window on a plain plate and cover with a piece of car window tinting film. It won't be visible. Did you print with PLA or PETG ?


    @Lechuuu
    I have both displays because I'm just using the 2.08 inch one in my Hammond housing project. I need to connect and compare. The 3.12 is tragic in terms of EMC emissions.

    @hevet
    Actually when copying the functions I forgot that in displayMode 1 (clock) we don't have the station name and everything is in the Scroller function. The radio that just happens to be broadcasting so strangely and has nothing completed on the server side is "Radio Plus". Thank you for pointing out the error. I would, however, leave it for consistency in the form with dashes. Then we know 100% that the station is not transmitting "stationString" when we switch to it.

    Code: C / C++
    Log in, to see the code
    .

    In my case it looks like this:
    Homemade ESP32 music server displaying time and radio station. .
  • #1004 21491497
    hevet
    Level 16  
    @robgold I also did with dashes, it is ok.

    In the banks in the new mode 2, a "B" is displayed after the station name, whether on the display or in the web interface.
  • #1005 21491597
    robgold
    Level 20  
    @hevet, this mode 2 is still the "prototype" version. It's actually a copy of what Majster did originally which was to split the text into 3 lines. The assumption was to be able to display the full 26 characters of the station name in this mode instead of 23. In bank 3, station 3 there was an error in the bank file itself. Download it again it should be fine. Have you caught other stations with this error ?

    I have. The problem is thicker ;) I will fix and upload an update.
  • #1006 21491608
    hevet
    Level 16  
    @robgold in Bank 3, Station 3 is now ok but there is still a problem in all banks from 10 upwards, at every station.
  • #1007 21491740
    robgold
    Level 20  
    I have corrected it, it should be OK but it requires updating the banks from the network or manually correcting myself so that bank[x].txt on the SD card consists of 25 characters of the station name + two spaces + "Bank x" + space + "Station x" + two spaces + "Link to stream"

    In general, I'm thinking of moving away from displaying information in the station list about the bank number. That is, instead of:
    RMF Bank 1 Station 3 just display -> 3. RMF
    This would simplify things a lot. Plus changing the separator from a space to e.g. a character not used by stations e.g.: "|".
  • #1008 21491773
    DJCheester
    Level 26  
    Hello, I cannot get this web interface to work

    I have a hotspot from my phone and the radio is playing on it, I also connect with my computer under the same hotspot and type the radio page in the browser

    http://192.168.4.1/

    And I have only this, on the phone also only this and uploaded the soft yesterday

    Error message: This site is unreachable. The server 192.168.4.1 took too long to respond.

    What am I doing wrong, I would appreciate your help.
    Greetings ...
  • #1009 21491778
    hevet
    Level 16  
    You enter the IP address the radio has assigned to the hotspot.
  • #1010 21491784
    robgold
    Level 20  
    During start-up, the IP number assigned from the network, hotspot or wifi to which we are connected appears under the notes for a moment (2sec). And this is the number to be entered into the browser.

    Internet radio screen displaying IP address and treble clef. .
  • #1011 21491786
    DJCheester
    Level 26  
    So you are talking about ?

    OLED display showing the text Internet Radio with connected WiFi and IP address and software version information. .

    Oh and the icon and radio graphics files should be directly on the sd, i.e. in the root directory ?

    Greetings ...

    Added after 1 [minute]:

    Well, that's right, only now I put these files on the main directory.

    Greetings ...
  • #1012 21491788
    robgold
    Level 20  
    Yes, on the main path but if you have version 3.15 radios won't work. It's only in 3.16 that AsyncWeb is done.
  • #1013 21491794
    DJCheester
    Level 26  
    I have the new 3.16 I uploaded yesterday I just had to catch up with these two libraries. So I will check later it should work. The photo above is 3.15 but that was an old photo.

    I will let you know

    Thanks a lot.

    Regards...
  • ADVERTISEMENT
  • #1014 21491860
    wirbud
    Level 13  
    robgold wrote:
    Clock:
    Wollie's library does not allow you to mix audio from the stream along with telling the time. You have to turn one off and run the other. Even someone recently asked this question on GitHub -> Link. To make this cool you would have to slowly mute the audio, turn off the stream , read the time and turn on the stream. The problem is that often turning the stream back on will start playing ads. To think about.

    Is it possible to squeeze these lines in your code somewhere - and the clock will chatter every hour or is that not so easy for a layman?

    void loop() {
    audio.loop();
    if(sec1 < millis()){ // every second
    sec1 = millis() + 1000;
    time_s = gettime_s();
    Serial.println(time_s);
    if(time_s.endsWith("00:00")){ // time announcement every full hour
    char am_pm[5] = "am."
    int h = time_s.substring(0,2).toInt();
    if(h > 12){h -= 12; strcpy(am_pm, "pm.");}
    sprintf(chbuf, "It is now %i%s and %i minutes", h, am_pm, time_s.substring(3,5).toInt());
    Serial.println(chbuf);
    audio.connecttospeech(chbuf, "en");
    }
    }
    }
    //------------------EVENTS----------------------------------------------------------------------------------------------
    void audio_info(const char *info){
    Serial.printf("info: %sn", info);
    }


    Casing:
    Very nicely that top casing came out of that 'carbon' plate. Print yourself an IR window on a smooth plate and cover it with a piece of car window tinting film. It won't be visible. Did you print with PLA or PETG ?
    .

    This is my first print on this board. Cool effect. Super quality and inexpensive (I got 35 zł for 256x256mm (another board already jumped in for 43 zł unfortunately) Housing - window of course from PETG clear as you recommended. The casing made of PETG without the raft and it peeled off due to shrinkage and one side came out messy. I didn't have black PLA at the time and will probably print again with PLA. The top is Sunlu PLA+ (it threads a bit). Everything fitted perfectly of course.... A lot of those auxiliary lines in sketchup but that made the effect great. Thanks
  • #1015 21491869
    hevet
    Level 16  
    @robgold That's another thing, when the radio fails to connect to the stream it displays the message .... No audio stream ... , in displaymode 0 and 2 is ok, while in displaymode 1, this caption overlaps the station name, so the longer the station name the less visible, or not at all. I insert the code I used, in displaymode 1 the subtitle will then display higher.

    was

    else if ((currentOption == INTERNET_RADIO) && (timeDisplay == true) && (audio.isRunning() == false))
        {
    
          // Struktura przechowująca informacje o czasie
          struct tm timeinfo;
          if (!getLocalTime(&timeinfo, 5)) 
          {
            Serial.println("Nie udało się uzyskać czasu");
            return;  // Zakończ funkcję, gdy nie udało się uzyskać czasu
          }
          char timeString[9];  // Bufor przechowujący czas w formie tekstowej
          
          snprintf(timeString, sizeof(timeString), "%02d:%02d:%02d", timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec);
          u8g2.setFont(spleen6x12PL);
          u8g2.drawStr(0, 63, "                         ");
          
          if (millis() - lastCheckTime >= 1000)
          {
          u8g2.drawStr(0, 63, "... No audio stream ! ...");
          lastCheckTime = millis(); // Zaktualizuj czas ostatniego sprawdzenia
          }       
          u8g2.drawStr(208, 63, timeString);
    
        }
    .

    and now I have

    else if ((currentOption == INTERNET_RADIO) && (timeDisplay == true) && (audio.isRunning() == false))
        {
    
          // Struktura przechowująca informacje o czasie
          struct tm timeinfo;
          if (!getLocalTime(&timeinfo, 5)) 
          {
            Serial.println("Nie udało się uzyskać czasu");
            return;  // Zakończ funkcję, gdy nie udało się uzyskać czasu
          }
          char timeString[9];  // Bufor przechowujący czas w formie tekstowej
          
          snprintf(timeString, sizeof(timeString), "%02d:%02d:%02d", timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec);
          u8g2.setFont(spleen6x12PL);
    
          int x, y;
          if (displayMode == 0 || displayMode == 2) {
              x = 0;
              y = 63;
          } else if (displayMode == 1) {
              x = 50;
              y = 33;
          }
    
          u8g2.drawStr(x, y, "                         ");
    
          if (millis() - lastCheckTime >= 1000) {
              u8g2.drawStr(x, y, "... No audio stream ! ...");
              lastCheckTime = millis(); // Zaktualizuj czas ostatniego sprawdzenia
          }
    
          u8g2.drawStr(208, 63, timeString);
    
    
        }
  • #1016 21491922
    wirbud
    Level 13  
    A rationalisation request - could it be asked to exclude the IR remote control definition from the main program file and move it to a file such as pilot_IR.h ?
    This will save a large handful of imitators a ton of time swapping the remote control in the code for their own. Thanks to
  • #1017 21492002
    DJCheester
    Level 26  
    The web interface works, thank you for your support. Well the radio is great and has potential. The project is going from strength to strength
    Greetings...

    Added after 8 [minutes]: .

    Question mate Robgold you wrote that the software update can be done in recovery mode without compiling and uploading to ESP via Arduino IDE.

    The question is whether such an update will keep my remote control settings or yours ?

    Because if it is yours, I still have to compile at home as before.

    Regards ...
  • #1018 21492071
    wirbud
    Level 13  
    A curiosity - a different plate for 3D printing. Smooth with texture.... The light and reflections shimmer like diamonds. Also a cool effect.

    3D printing plate with a smooth surface and texture. .
  • #1019 21492077
    hevet
    Level 16  
    @DJCheester you win what robgold has compiled, i.e. his pilot settings too.
  • #1020 21492100
    robgold
    Level 20  
    @wirbud with the timer it's not that easy, will be some rainy weekend then maybe I'll sit down to it. Regarding the IR remote control. I have a slightly different plan. The configuration will be downloaded from a txt file and the ability to configure will ultimately be via a web page. This way, once configured, the remote will always work and will not be linked to the radio code.

    @hevet. Thanks. I haven't used clock mode much lately so I didn't catch that. Eventually I think I'll do it a bit differently but for now the option with raising the caption to "y33" seems good.

    @DJCheester unfortunately at the moment the remote is coded ino file so you have to compile under your remote.

Topic summary

The discussion revolves around building an internet radio and audio file player using the ESP32-S3 microcontroller. The project includes features such as an OLED display, Wi-Fi connectivity, and audio playback capabilities. Users share their experiences with hardware setup, including issues with pin configurations, library compatibility, and troubleshooting compilation errors in the Arduino IDE. Suggestions for libraries, such as ESP32-audioI2S and WiFiManager, are provided to enhance functionality. Participants also discuss the importance of proper wiring, capacitor usage for encoders, and the potential for adding features like DLNA support and a web management interface for radio station management. Several users report on their progress, share code snippets, and offer solutions to common problems encountered during development.
Summary generated by the language model.
ADVERTISEMENT