logo elektroda
logo elektroda
X
logo elektroda

Internet radio and audio file player on ESP32-S3

MAJSTER XXL 100725 1227
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #451 21405639
    robgold
    Level 20  
    This radio-player switching add-on is a matter of 5 minutes with one encoder. I guess there is a hidden function in every Evo3 that can switch something when you hold down encoder 2 for 4 seconds. Currently it switches the VUmeter mode from dashes to bars for testing.
  • ADVERTISEMENT
  • #452 21405641
    DJCheester
    Level 26  
    I was wondering if it would be possible to connect the USB somewhere (even from the front) so that the USB stick can be connected to the MP3? Then the card would be left on the banks and the USB to the MP3 and that's it?

    Best regards...

    Added after 4 [hours] 54 [minutes]: .

    Gentlemen this remote control will be suitable ?

    https://allegro.pl/oferta/zestwa-pilot-ir-odbiornik-vs1838b-arduino-itp-5748001648

    In the pictures in the description are given codes I saw that the author did it with such a remote control ?

    I am still thinking to upload a ready compiled soft in case I can't manage with compilation ?

    Greetings ...
  • #453 21406280
    hevet
    Level 16  
    @robgold I used a different remote a bit and now with the operation is much better. Codes assigned, works decently.
    Instead I noticed another bug, at least with me. When changing the bank with the encoder and selecting any station from the bank, the title information (as long as the station is broadcasting it), the VU meter and the stream format appear, but this information is missing when I change the bank and select the station via the remote. The station plays, but there is no VU meter, stream format or title. After restarting the radio the information returns.

    The second thing is that after start-up, the first station from the bank is always switched on, i.e. it remembers the bank, but no longer the station.
  • #454 21406407
    robgold
    Level 20  
    @hevet,
    thanks for catching the bug. I've started wrapping some repetitive stuff in functions and overwrote the station_nr variable.
    I'll fix it tonight and upload the new file to GitHub. The bug is in the "fetchStationfromServer()" function, which is now also responsible for displaying station fetch information.
    I've caught a few more bugs. All the power of independent testing in you my dears.

    @DJCheester
    The remote you suggested will be ok and should work. I have it and it too works standard on address 00 and NEC protocol.
    I would however strongly urge you to go for the RC-406 that I have shown. I know that it is no longer 6zł but 20zł from Ali or Allegro but the quality of work, the number of buttons speaks in favour of the latter.
  • #455 21406909
    MAJSTER XXL
    Level 29  
    @robgold I copied the necessary parts to myself and I have to admit that the operation from the remote control has now become a pure pleasure, I did a little bit more in my own way, i.e. I created more flags to set the use of the corresponding buttons of the remote control and inserted this in a separate function with a view to use in the file player. I don't know if this is the best way to go, as I have this player to rework anyway, I need to do subfolder playback and take a slightly different approach to selecting files to play. You asked the other day about playing large size flac files from a card, with me it runs normally such an almost 130MB one, but I can see on the serial that the bitrate is somehow undersized at only 516b/s - the Audio library author has something wrong with it.
    I'm still boxing myself in with this idea, as I've been trying to do an on-the-fly recording of the internet radio I'm listening to straight onto an SD card, but only the ones that stream mp3s, so far I've only managed to create a Recorded folder on the card and a file that has the name of the station I'm listening to in the name plus a note of the start time of the recording and I'm stuck. The question is whether this ESP32 module can still handle such on-the-fly recording to a high-speed SD card of the broadcast/song being listened to?

    Below is a screen shot of Mike Oldfield's flac being played:


    Screenshot showing serial port monitor output in Arduino IDE, displaying playback of a FLAC file. .

    Display showing information about the song Tubular Bells (Part One) by Mike Oldfield.
  • #456 21407091
    robgold
    Level 20  
    @MAJSTER XXL

    I am very pleased. So we have one additional function - remote control - out of the way. As for the operation, it is precisely because of the planned addition of a pushbutton keyboard to the conversion of already existing FM tuners that I "dressed up" individual things in functions like volumeUp() or bankMenuDisplay(). I think that whether you do it with flags or functions, it's all the same. Ultimately, the event has to be handled somewhere anyway.

    Regarding the FLAC files, when I tested your software while still testing the remote, I tried to play a FLAC I have on my card and it doesn't even start. I write its name and it just sort of flies out of the handling function. The file is 140MB. The display will stay as it is in the picture and to paraphrase... "it doesn't care about anything else".

    I think that ESP itself is a huge potential, the question is whether the way it is handled by Arduino doesn't "castrate" it too much. Theoretically if you peek into the audio library it can work on the second core. I would be tempted to make an MSC (MassStorageClass) and access the contents of the card via USB.

    Debug console with information about FLAC file Nothing Else Matters.flac. .
    FLAC player display showing track information for Nothing Else Matters. .

    Update 3.14 with fixes on GitHub Link
  • #457 21407700
    gangliu2018
    Level 7  
    @robgold
    I have a question, can the station name and URL be stored in the ESP32S itself, so that an SD card is not needed?
  • #458 21407824
    DJCheester
    Level 26  
    Gentlemen I have been wggling in turn
    Arduono 2.11 - the last one that works with Win7 64b - so I read
    For this I installed ESP-IDF
    And the ESP-S3 3.11 board in the Arduino board manager

    After trying to compile the latest version 3.14 I get this log


    C:UsersHDDocumentsArduinolibrariesSDsrc_diskio.cpp: In function 'bool sdcard_mount(uint8_t, const char*, uint8_t, bool)':

    416 | #define FM_ANY 0x07
    | ^~~~
    | |
    | int
    C:C:C:C:C:C:C:C:C:C:793:31: note: in expansion of macro 'FM_ANY'
    793 | res = f_mkfs(drv, FM_ANY, 0, work, sizeof(work));
    | ^~~~~~
    C:³³³³³³³³.cpp:793:42: error: invalid conversion from 'BYTE*' {aka 'unsigned char*'} to 'UINT' {aka 'unsigned int'} [-fpermissive].
    793 | res = f_mkfs(drv, FM_ANY, 0, work, sizeof(work));
    | ^~~~
    | |
    | BYTE* {aka unsigned char*}
    C:| C:C:C:C:C:793:25: error: too many arguments to function 'FRESULT f_mkfs(const TCHAR*, const MKFS_PARM*, void*, UINT)'.
    793 | res = f_mkfs(drv, FM_ANY, 0, work, sizeof(work));
    | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    C:³³³³AppDataLocalArduino15-arduino-libs-release_v5.3-cfea4f7c-v1-libs-release_v5.3-cfea4f7c-v1-libs-release_v5.3/include/fatfs/src/ff.h:339:9: note: declared here
    339 | FRESULT f_mkfs (const TCHAR* path, const MKFS_PARM* opt, void* work, UINT len); /* Create a FAT volume */.
    | ^~~~~~
    Found multiple libraries in "HTTPClient.h"
    Used: C:³³³³³³³³{Arduino}HTTPClient
    Unused: C:UsersHDAppDataLocalArduino15packages3.1.1librariesHTTPClient
    Multiple libraries found in "FS.h"
    Used:
    Unused: C:UsersHDAppDataLocalArduino15packages3.1.1librariesFS.
    Multiple libraries found in "Ticker.h"
    Used:
    Unused: C:UsersHDAppDataLocalArduino15packages3.1.1librariesTicker
    Multiple libraries found in "SD.h"
    Used:
    Unused: C:UsersHDAppDataLocalArduino15packages3.1.1librariesSD.
    Multiple libraries found in "SPI.h"
    Used:
    Unused: C:UsersHDAppDataLocalArduino15packages3.1.1librariesSPI
    exit status 1

    Compilation error: exit status 1

    Something I probably have uninstalled - I uploaded the libraries to the Aruino Libraries document catacog

    Please help me to compile.

    I do not have a computer with a newer system

    Greetings ...
  • #459 21407867
    hevet
    Level 16  
    Remove the SD and SPI library from the Arduino/libraries.
  • ADVERTISEMENT
  • #460 21407887
    DJCheester
    Level 26  
    Ok, now it's done, take a look at the screenshot to see if I'm doing it right or what to do, because the sketch doesn't seem to fit


    Screenshot of Arduino IDE showing code and compilation error.

    Thanks
  • ADVERTISEMENT
  • #462 21407929
    DJCheester
    Level 26  
    Actually wrong settings ;) .

    Compiled without errors

    I will now upload


    Screenshot of Arduino IDE showing code for ESP32. .

    Thanks to

    Added after 7 [minutes]:

    Ok compiled

    However, the settings


    Screenshot of Arduino IDE with code for ESP32.

    How do I now install the ESP in the computer I plugged in the USBC it on the right and flashes the RGB LED in successive colours ???
    This is the new ESP windows calls driver in the folder Espressif not found ??

    Greetings ...

    Added after 36 [seconds]: .

    Ok compiled

    However, the settings


    Screenshot of Arduino IDE with code for ESP32.

    How do I now install the ESP in the computer I plugged in the USBC it on the right and flashes the RGB LED in successive colours ???
    This is the new ESP windows calls driver in the folder Espressif not found ??

    Greetings ...
  • ADVERTISEMENT
  • #463 21407945
    hevet
    Level 16  
    And what is the ESP specifically? The drivers should install themselves.
  • #464 21407954
    DJCheester
    Level 26  
    This is win7 64bit may not have ESP such


    ESP32 module with a glowing green LED. .

    N16R8

    Greetings...

    Added after 1 [minute]:

    Unless it's not the USB I've plugged in but I've seen on the net that it's the one on the right

    Greetings ...

    Added after 2 [minutes]:

    This is what my computer found


    Screenshot of Windows 7 device manager with USB Single Serial device highlighted.

    USB single serial
  • #466 21408020
    DJCheester
    Level 26  
    Thanks, it worked, I uploaded Ch341

    Ok Now it has compiled and uploaded here is the status

    zkic is using 1729648 bytes (54%) of program memory. The maximum is 3145728 bytes.
    Global variables use 57772 bytes (17%) of dynamic memory, leaving 269908 bytes for local variables. The maximum is 327680 bytes.
    esptool.py v4.8.1
    Serial port COM9
    Connecting....
    Chip is ESP32-S3 (QFN56) (revision v0.2)
    Features: WiFi, BLE, Embedded PSRAM 8MB (AP_3v3)
    Crystal is 40MHz
    MAC: 24:58:7c:e1:f1:e8
    Uploading stub...
    Running stub...
    Stub running...
    Changing baud rate to 921600
    Changed.
    Configuring flash size...
    Flash will be erased from 0x000000 to 0x00004fff...
    Flash will be erased from 0x00008000 to 0x00008fff...
    Flash will be erased from 0x0000e000 to 0x0000ffff...
    Flash will be erased from 0x00010000 to 0x001b6fff...
    Compressed 20160 bytes to 12989...
    Writing at 0x000000... (100 %)
    Wrote 20160 bytes (12989 compressed) at 0x000000 in 0.4 seconds (effective 401.2 kbit/s)...
    Hash of data verified.
    Compressed 3072 bytes to 137...
    Writing at 0x00008000... (100 %)
    Wrote 3072 bytes (137 compressed) at 0x00008000 in 0.0 seconds (effective 512.0 kbit/s)...
    Hash of data verified.
    Compressed 8192 bytes to 47...
    Writing at 0x0000e000... (100 %)
    Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 829.5 kbit/s)...
    Hash of data verified.
    Compressed 1729760 bytes to 1137672...
    Writing at 0x00010000... (1 %)
    Writing at 0x0001a7df... (2 %)
    Writing at 0x00028498... (4 %)
    Writing at 0x00031987... (5 %)
    Writing at 0x00036104... (7 %)
    Writing at 0x0003bf94... (8 %)
    Writing at 0x00040f57... (10 %)
    Writing at 0x00049126... (11 %)
    Writing at 0x0004dccb... (12 %)
    Writing at 0x00051c8a... (14 %)
    Writing at 0x00055f25... (15 %)
    Writing at 0x0005c034... (17 %)
    Writing at 0x000642d0... (18 %)
    Writing at 0x0006c64c... (20 %)
    Writing at 0x0007e6eb... (21 %)
    Writing at 0x00084df1... (22 %)
    Writing at 0x0008ac30... (24 %)
    Writing at 0x000903bf... (25 %)
    Writing at 0x00095951... (27 %)
    Writing at 0x0009ae72... (28 %)
    Writing at 0x000a0927... (30 %)
    Writing at 0x000a63f3... (31 %)
    Writing at 0x000ab892... (32 %)
    Writing at 0x000b0ecf... (34 %)
    Writing at 0x000b7201... (35 %)
    Writing at 0x000bc69e... (37 %)
    Writing at 0x000c1651... (38 %)
    Writing at 0x000c6c38... (40 %)
    Writing at 0x000cbcf2... (41 %)
    Writing at 0x000d168c... (42 %)
    Writing at 0x000d795a... (44 %)
    Writing at 0x000df3d8... (45 %)
    Writing at 0x000e549a... (47 %)
    Writing at 0x000eb4c8... (48 %)
    Writing at 0x000f0f66... (50 %)
    Writing at 0x000f689a... (51 %)
    Writing at 0x000fc4f4... (52 %)
    Writing at 0x0010206b... (54 %)
    Writing at 0x001074f9... (55 %)
    Writing at 0x0010c769... (57 %)
    Writing at 0x00111c76... (58 %)
    Writing at 0x001171e7... (60 %)
    Writing at 0x0011c870... (61 %)
    Writing at 0x00121d87... (62 %)
    Writing at 0x00126f80... (64 %)
    Writing at 0x0012c37f... (65 %)
    Writing at 0x00131376... (67 %)
    Writing at 0x00136b42... (68 %)
    Writing at 0x0013bc1d... (70 %)
    Writing at 0x0014129e... (71 %)
    Writing at 0x00146f89... (72 %)
    Writing at 0x0014c6b0... (74 %)
    Writing at 0x00151a27... (75 %)
    Writing at 0x00156bcc... (77 %)
    Writing at 0x0015bab7... (78 %)
    Writing at 0x00160c76... (80 %)
    Writing at 0x00165be2... (81 %)
    Writing at 0x0016b009... (82 %)
    Writing at 0x0017036a... (84 %)
    Writing at 0x00175986... (85 %)
    Writing at 0x0017b72c... (87 %)
    Writing at 0x00180f20... (88 %)
    Writing at 0x0018647f... (90 %)
    Writing at 0x001900c9... (91 %)
    Writing at 0x001975c9 ... (92 %)
    Writing at 0x0019cfe7 ... (94 %)
    Writing at 0x001a204a... (95 %)
    Writing at 0x001a7bc0... (97 %)
    Writing at 0x001ad8b3... (98 %)
    Writing at 0x001b388a... (100 %)
    Wrote 1729760 bytes (1137672 compressed) at 0x00010000 in 15.8 seconds (effective 875.2 kbit/s)...
    Hash of data verified.

    Leaving...
    Hard resetting via RTS pin...


    Does anything else need to be done on this ESP now - reset or can it be unplugged from the computer ??

    Greetings ...
  • #467 21408022
    hevet
    Level 16  
    It can be unplugged, the reset did itself. And does it show anything on the display?
  • #468 21408033
    DJCheester
    Level 26  
    I don't know but this rgb glows greenish-yellow no longer flashes

    Today I wanted to go through the compilation process I don't have the display plugged in yet - I programmed the ESP myself

    Tomorrow I will try to do a test on the contactor, i.e. OLED ESP and card, because this is probably the minimum ??
    Do I need to load anything onto the card or is it just an empty FAT32?

    Thanks for today because I have to go to work for the night (I did not sleep during the day it can be a drama around 3 hours ;) .

    Greetings ...
  • #469 21408039
    hevet
    Level 16  
    Card any capacity, you don't upload anything.
  • #470 21409650
    hevet
    Level 16  
    Sometimes when switching stations, bushes appear on the display. When I switch to another station and back to the one that was the problem, the bushes disappear. This happens on any station, randomly. The bushes also disappear by themselves when the information broadcast by the station changes, e.g. the artist.
    Car radio display showing strange symbols and the song title Kenny Masters - SOS, Fire In My Heart. .
  • #471 21409947
    MAJSTER XXL
    Level 29  
    @hevet I have this sometimes too, I don't know what causes it, you may need to enable some sort of subsequent refresh of the displayed data after some short time.
    I did quite a bit of work on the SD card file player today, I managed to make the screen scroll in a loop using the directional up - down buttons on the remote control for both radio stations / folders / files with the selection being confirmed by the middle button on the remote control. It needs a bit of fine-tuning so that when alternating between encoders / remote control it always selects exactly what is selected from the list. Sometimes there will be a -1 shift in the selected file index - I need to track this down. If I use only the remote control to select files / folders it is rather always OK, if I insert something from the encoder then somewhere the index is shifted just by 1. @robgold can you help to trace this? I also need to make the highlight set to the last selection each time.
    I'm thinking of moving the handling of the whole file player to a separate file so it's easier to control visually.
    I uploaded the current file to myself on github: https://github.com/sarunia/ESP32_radio_player_v2

    Below is a description of the remote control buttons:

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

    and a screen shot of the selection of audio files from the current folder being played:

    Display showing a list of audio files with the file Anticappella - Baby 2 Day.mp3 highlighted. .


    @robgold I think it's ok now with this file index numbering at my place, I've changed the file search approach anew, which has made it quicker to start playing any file in the scrolling list or selecting the previous one, now all selections are pulled from the files[] array.
  • #472 21410689
    robgold
    Level 20  
    @MAJSTER XXL

    Were the indexes splitting or was the encoder going crazy ? I'm assuming that with both the encoder and the remote you are changing the value of the same variable. I have a player at my place with 5 iterations of your software backwards. I haven't even implemented alphabetical sorting yet :( I'll download your file and play with it to test.

    @hevet, @MAJSTER XXL
    Regarding the display and the subject of so called "ghosting", I've spent quite a bit of time to severely limit this but they still appear from time to time. Interestingly most often on stations without streamtitle and with AAC codec i.e. e.g.: all Polish Radio programmes, 1,2,3,4. Looks like it's related to the setColor() function. See that always then something from the bottom line will do in the negative. Today I made an extra refresh of the screen after 200ms. I think this solves the problem because the "ghosts disappear". A bit of a prosthesis but oh well.

    Have you noticed a symptom such that if you start to change stations very often on a "monkey test" basis encoding the stream in AAC then ESP "dumps" with an AAC codec error ?

    @MAJSTER XXL
    I found another bug. Sometimes when entering the bank menu or station selection the system threw us back to the main screen much faster than after 6 sec.
    The culprit for this turns out to be the function void audio_showstreamtitle() . With stations that fly from autopilot at night, e.g.: RMF Classic a counter is included in the streamtitle to help watch on the RMF side that the stream is working and broadcasting correctly. This causes it to go into the aforementioned function every 1sec and this function calls displayRadio().
    The solution is to make a condition so that when in any sub-menu the displayRadio function is not called:

    if ((volumeSet == false) && (bankMenuEnable == false) && (listedStations == false))
        {
        displayRadio();
        }
    .

    I made an additional display mode for my needs this week. It's probably of little use to anyone, so I didn't even post it on GitHub.
    The idea is that you can use the remote control to turn on the clock mode and then the station name and scroller go to the bottom line. We turn off the info about frequency, stream type and only display the minimum with the minimum (I assume we know what we are listening to). In addition, on the SSD1322 it is possible to dim the display by reducing the pixel current from 160uA to 80uA so that it does not flare up at night.

    Other changes:
    - in the bank menu by pressing the numeric keys you can quickly select a bank from 1-10 ( under 0 is the number 10)
    - under the RED button (red handset in my case) in the bank menu, it is possible to enable a flag for downloading a given bank from the network (GitHub server)
    - under the ATT button, a mute function is added, in place of the VU indicators the information "MUTED !" appears.

    Distorted electronic display with graphic errors and music playback information.
    LED display showing the time 13:26 and information about the playing music. .
    OLED display showing information for bank 1 and network update enabled.
  • #474 21410911
    DJCheester
    Level 26  
    A cool byline, something like this is what I wanted, it could be.

    I have a question for MAJSTRA XXL how do you switch on this radio? I.e. does it switch on by itself when power is applied or do you have to press/hold the encoder or simply use the remote control?

    I think that ESP does not consume much power, so if the option would introduce standby even from the remote control or possibly add a switch and the system would turn off the OLED radio and the whole ESP would work 24 hours a day, it could also be.

    If you want to be more economical, you could add a button to disconnect power from the whole system.

    What do you think?

    The question of the clock itself, when the radio is on, as you have shown, it would be good, optionally, when it is off, not 24 hours a day but, for example, after pressing the remote control or encoder, to show the time and date, the day of the week.

    And if there was an option with esp32 switched on all the time, it would also be possible to implement an alarm clock in the code, i.e. at the set time the station would switch on or, if the radio was for some reason offline, an MP3 player with preloaded sound on the card or just MP3 tracks.

    These are my suggestions. What do you think?

    I am currently working on the board, but when there is more time, I will certainly etch it and start the radio.

    I have already programmed the ESP thanks to my colleague hevet, I hope we will see it on startup.

    Tell me, if I wanted to hardwire a PCB for the switch, would it be standard in this ESP to use a pushbutton to ground like in Arduino, with a 5V supply pulled up through a resistor e.g. 4.7k?

    And the LED from the pin directly through only a resistor to ground as I did on the Arduino.

    Maybe I'm asking stupid questions but this is the first time I'm using ESP ?

    What voltage level is on the ESP pin 3.3V I think ?

    Regards and thanks for your help so far.

    For the time being the PCB will look like this.


    PCB with ESP32 module and electronic components. .

    Greetings...
  • #475 21411089
    robgold
    Level 20  
    @DJCheester ,
    Have to admit that today's PCB visualisations look nice. Have you checked yourself this SD reader ? Because I got nicked on it it doesn't have a card "ejector". It's a kind of "connector".
    I'd suggest you, throw away the connectors in front of the ESP antenna and move the module/antenna out of the PCB area completely.
    What are you drawing in ?
  • #476 21411102
    DJCheester
    Level 26  
    Heyka the PCB is not yet final I am thinking about your suggestions what you wrote me i.e. SMD capacitors directly under the sockets etc.

    I as I wrote am retired from electronics, I am using the first visualization software that came out.

    The design is in Eagle and the render is using Eagle3D script and Povray

    As I've been designing this way for 11 years now, I learned how to write model macros in povray from scratch.

    Greetings...
  • #477 21411121
    tytka
    Level 22  
    @DJCheester On your board design I see a module with PAM8403, so I'll ask. Have you listened to it? Does it correspond to you?
    I once bought myself such a module out of curiosity. Unfortunately I got rid of it immediately after the test. I couldn't manage to listen to it, because my ears actually hurt. I don't know if I got such a bad module or if they are just like that.
  • #478 21411139
    DJCheester
    Level 26  
    At my place it goes with a BT receiver and 3W speakers.

    The quality is not HiFi, but it can be used as a kitchen radio to drive small speakers. You can always connect another amplifier to the Chinch.

    I think you bought the wrong one, regards....
  • #479 21411155
    robgold
    Level 20  
    @DJCheester, you can give those capacitors from the encoders at the encoders themselves. That would be best. Any pins should be "whisked away" at the source to avoid stretching them across the circuit with wires.

    I added a calendar to the clock screen.
    The mute information is displayed in the negative


    Digital display of time and date with additional radio information. .
    Display screen showing the currently playing song on the radio. .
    Printed circuit board design with capacitor and encoder elements. .
  • #480 21411159
    DJCheester
    Level 26  
    Elements such as resistors capacitors are to be changed on the PCB this version is only an overview now I will improve it to make it the best it can be.

    Greetings....

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