logo elektroda
logo elektroda
X
logo elektroda

Internet radio and audio file player on ESP32-S3

MAJSTER XXL 104499 1246
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #241 21350398
    gangliu2018
    Level 7  
    I cannot connect to the weather server. The following message appears.

    Brak polaczenia z serwerem pogody

    String url = "http://api.openweathermap.org/data/2.5/weather?q=Piła,pl&appid=your_own_API_key";

    my_own_API_key Is it a number like this? How many digits are there in total? 32-digit string?

    8cbafe2b83baa120236464326e1b6dfe

    thanks!

    Hinzugefügt nach 3 [Minuten]:

    String url = "http://api.openweathermap.org/data/2.5/weather?q=Piła,pl&appid=8cbafe2b83baa120236464326e1b6dfe";

    Is the modified format like this? APIkey 8cbafe2b83baa120236464326e1b6dfe is sample

    Hinzugefügt nach 4 [Minuten]:

    The modified link address can be opened with a browser. In the browser page, you get three lines of text similar to the following:

    "coord":{"lon":8.2647,"lat":32.6},"weather":[{"id":843,"main":"Clouds","description":"broken clouds","icon":"04d"}],"base":"stations","main":{"temp":283.18,"feels_like":282.51,"temp_min":283.16,"temp_max":283.18,"pressure":1026,"humidity":87,"sea


    However, after programming, it prompts that the weather server cannot be found.

    Hinzugefügt nach 49 [Minuten]:

    Could you please add the date and day of the week display?
    Such a beautiful screen should be fully utilized.

    In the future, could you add the timer off and timer on function, it would be even more perfect.
  • ADVERTISEMENT
  • #242 21350673
    gulson
    System Administrator
    The API seems to have changed to version 3.0:
    https://openweathermap.org/api
    The service has become more restrictive and there is a fee.
    But I guess you can set it to pay nothing (after adding a credit card).
  • ADVERTISEMENT
  • #243 21350687
    Andrzej Ch.
    Level 33  
    The API has 32 characters. I for my own use have generated three keys as I use 3 SmallTV-Ultra devices (https://github.com/GeekMagicClock/smalltv-ultra) the keys are free but there is limited functionality and number of refreshes, maybe colleague @MAJSTER XXL refreshes the data too often directly from the service instead of downloading it, storing it in the device, alternate display but refresh from the server e.g. every 10 min.
  • #244 21350844
    simw
    Level 27  
    gulson wrote:
    The service has become more restrictive and there is a charge.

    Perhaps you should switch to another provider.
    Domoticz has one called "Meteorologisk Norway"
    https://www.met.no/en/free-meteorological-data
    The plugin works, if I'm not mistaken, even without an API key, unfortunately I don't know how to use it in this project.
  • #245 21351075
    MAJSTER XXL
    Level 29  
    I set up an account on openwathermap.org a couple of days ago just for the purpose of adding the weathervane to the bottom line on the radio, if the link is correct then you should see the json data in your browser as in the screengrab below. I refresh the data every 60 seconds for now. The syntax of the link under API 2.5 should be like this:

    https://api.openweathermap.org/data/2.5/weather?q={city_name}&appid={API_key}

    I entered my city and API key and it works normally.

    Screenshot displaying weather data in JSON format for London from OpenWeatherMap API. .
  • #246 21351703
    gangliu2018
    Level 7  
    Thanks for your reply. I used the source code of the author MAJSTER XXL and added my 32-bit API_key to try again.
  • ADVERTISEMENT
  • #247 21353061
    gangliu2018
    Level 7  
    https://api.openweathermap.org/data/2.5/weather?q={city_name}&appid={API_key}
    I tried it yesterday, but it still gave an error.
    There is no problem with the format. After the modification, the URL can be opened with a browser. It is just that the Arduino program gave an error that it could not connect to the weather server. I will try again when I have time.
  • #248 21357592
    robgold
    Level 20  
    Congrats to the author for an excellent project !!! I bow my head !
    I have already managed to run the v1 version on the current libraries. Some minor adjustments to variable declarations were required.
    Personally, I wouldn't go for any versions with a weatherman or other water features. I once made such a radio on a Raspberry Pi + OLED and scripts in Python.
    It worked nicely but the time it takes to boot up RPi vs ESP32 is a misunderstanding so the ESP version revived the desire to have this radio :) .
    Currently modifying this code for myself as for me it is missing:

    - a web server (you would need to add AsyncWeb) so that there is the possibility to edit WiFi and stream links without GitHub
    - to add support for a matrix of buttons (for modifications of current various tuners)
    - maybe I would go with the solution of a colleague from YT who describes a memory cell as P-000 and do it like this P- 1 digit bank number 2,3 digit - cell number (i.e. e.g. P-109) 1 bank, 9 station however....
    - I am not convinced that such a radio needs 15 banks, in fact 95 stations is already a cosmos listening to maybe 15-20. Factory Yamaha or Denon tuners support 50 "Favorite" stations and that is enough.
    - Get rid of the bit rate and frequency information. They may appear for a while but then they burn up the OLED pointlessly because they are static information.
    - I have already purchased the OLED for v2 - I would like to add on these new u8 libraries the "dotted" font options I used on my radio. This looks very cool. Ultimately to be fitted to the finished hardware.

    Some people will probably disagree with me, but I'll take my chances... the file player is pointless for me. Today hardly anyone listens to mp3 anymore and for music lovers FLAC is the wrong DAC. PCM is too poor in quality. You would have to use some kind of ESS and an external stabilised quartz generator (as it was, for example, in Audiphonic stremars for RPi) to be able to talk about quality. For Internet Radio it is form over content most strems are 128-256kbps in mp3 compression.

    Some pictures from my radio with the font I'm talking about
    OLED display with internet radio information and time. .
    OLED display of an internet radio showing station and time information.
  • #249 21357716
    MAJSTER XXL
    Level 29  
    @robgold Thanks for the feedback and positive howl. I'll currently be developing v2-if you run it you'll be happier than with v1. The amount of data on the display is optimally used - for me. I also find it convenient to do station updates via local files with station lists and links to them, which I sync to the github server via Github Desktop. That's why I'm publishing all the source code with extensive polish comments, so that it's easy to navigate and so that everyone can adapt it to their own ideas.
  • #250 21357728
    robgold
    Level 20  
    MAJSTER, for making the code available for such a huge amount of work, you really deserve a lot of respect and thanks. I would prefer to employ a secretary for my projects, who will clean up the code, write comments, prepare publications etc. :)

    I'll probably run v2 over the weekend for testing, I've already uploaded it to the ESP but haven't had time to solder the leads to connect the display and DAC.

    I wonder why the display support, is in several places ? Is it due to the convenience and strategy of writing the software you have adopted or is there something else behind it ?
    I mean the fact that there is no single place (v1 at least, I had a cursory look at v2 on file comparison and there I think) OLED support is in multiple places instead of a single void like update oled.
  • #251 21357893
    cubes
    Level 14  
    Hi,

    Will the project fire without a reader and SD card?
  • #252 21358386
    MAJSTER XXL
    Level 29  
    @cubes no problem, it will report an SD card error on the terminal, because I do write and read the last listened station to the card- I have not been able to successfully do this internally in the ESP32 memory. If it can't find the card it will set the default station to play- in my case Bank 1 Station 9.
  • #253 21358547
    cubes
    Level 14  
    ok, thank you.

    In my case, after trying to adapt your code to the ssd1306 display after full SPI(after I2c and the original library it wouldn't work) only the station name is displayed on the display, silence on the DAC. Adding SD did not help, although the files can be seen on the card.
    However I have to buy original display :) .
  • #254 21358650
    MAJSTER XXL
    Level 29  
    @cubes if you are changing the 'info' data coming from the radio on the serial terminal then you should have audio output on the DAC, have you made bridges as in the screengrab below?

    PCM5102A DAC connection diagram with visible jumpers on the module. .
  • #255 21358665
    robgold
    Level 20  
    MAJSTER, I have run the v2 version. It works, I didn't catch any major errors. Sometimes the display "glitches".
    For what reason did you introduce bank numbering into station files? Is this a preparation for a single file with stations in the future?
    In addition, v2 takes a very long time compared to v1 to download stations from github. Of course these are still milliseconds but it takes noticeably longer.

    There is a mistake in the schematics in the connection of the 256x64 SSD1322 display. You are using a hardware SPI with the U8G2 library and in the schematic you have swapped the physical pin numbers on the Esp32s3 board with the GPIO numbering. Please correct at your leisure.

    Added after 5 [minutes]: .

    >>21358547 .
    And have you changed the configuration for 1306 to 128x64 ? For the most part as I remember the 1306 came out with a 128x64 matrix. If you define the area wrongly then often the effect is to display only the upper part of the image on the display. I assume you have connected the display correctly because in the v2 diagram it is incorrectly drawn.
  • #256 21358695
    cubes
    Level 14  
    I wrapped the display by switching to I2C mode based on:
    https://sklep.msalamon.pl/blog/modyfikacja-wy...ULuhxxuAXnFY27f95yUsC7bAbcPjjzU15wJVBAEQcx0EA
    It ran on the original code.

    @robgold - jumpers on PCM done, but still silence - no inf. on display about sampling and bit rate:
    Breadboard with an OLED display and various connected wires. .

    In the monitor I get one strange message regarding Hostaddress every time I select a station:

    Currently selected station: 16
    Station link: Radio 2.0 http://46.252.154.133:8080/;
    info Hostaddress is not valid
    The file station_nr.txt already exists.
    Update station_nr.txt on SD card.
    File bank_nr.txt already exists.
    Update bank_nr.txt on SD card.
  • #257 21358705
    MAJSTER XXL
    Level 29  
    @robgold thanks for your vigilance, Czech mistake- I confused the GPIO port numbering of the ESP32 module with the foot numbering of the development board. I've corrected the schematic in that post and I'm also attaching the corrected one here in case you need it.
  • #258 21358721
    MAJSTER XXL
    Level 29  
    @cubes you should have the current time on the display and info data, my guess is that you don't have a network connection, did you do the correct wifi configuration when you first started up?

    edit, in total the station names were pulling you off, see somewhere an earlier screen shot of how you should have the parameters set up in the Arduino IDE under this ESP32.

    Screenshot of the settings menu in Arduino IDE 2.3.4 for ESP32. .
  • #259 21358730
    robgold
    Level 20  
    >>21358695 .
    Choose any station that streams at 100. RMF, italo4you. A lot of stations from further down the banks are dead. The second thing is that you have no blocked ports on your router?
  • #260 21358919
    cubes
    Level 14  
    With me there is a problem with the function audio.connecttohost(station) .
    The variable "station" contains the full station name, a dozen spaces and only the actual link :
    e.g. "Italo 4 You http://s0.radiohost.pl:8018/stream"

    After typing a permanent link e.g. audio.connecttohost("http://master.net-radio.fr:80/frequence3urban-256.mp3") everything works, the time on the display appears.
    I use the original code : https://github.com/sarunia/ESP32_radio_player/blob/main/ESP32_radio_player.ino
  • #261 21359014
    MAJSTER XXL
    Level 29  
    @cubes The changeStation() function did a good job of finding the correct link in the string, but in case you're wondering, I've added in both versions of the radio a check to see if the link contains the phrase https or http and that the string "station" always starts with https or http. I've just uploaded the fixes for both versions of the radio to github, you can download and check in action- it's ok with me in both versions of the radio.
  • #263 21364416
    robgold
    Level 20  
    I managed to sit on the radio a bit over the Christmas break. The project is dragging :) .

    - I added the DotMatrix font
    - I edited the Spleen font BDF file to have Polish letters and converted it to U82G format - attached if anyone would like to add it
    Admittedly, only ISO-8859-2 and Windows-1250 can be encoded in the 33-255 range, but it's always something
    Let's just say it works on most stations. The bushes are only on those using Unicode encoding
    - I have added a progress indicator for loading the station from the server
    - display of the IP number after start-up and connection to the network


    Master , trying to understand how you wanted to use the write to EEPROM. The range [MAX_STATIONS * (MAX_LINK_LENGTH + 1)] roughly exceeds the 4Kb that ESP emulates in Flash. It seems to me that the EEPROM (nvs) function will probably never write this. The only thing this creates is a large array in RAM to hold the stations. Correct me if I'm wrong.
    As a test, I reduced this size and threw myself a write test - the function started writing.

    Second thing, you keep a lot of variables like 0-255 (so one byte) as integer (2 bytes) why not uint8_t ?

    Electronic display showing internet radio information. Screen showing the progress of downloading radio stations from the GitHub server.
  • #264 21364511
    MAJSTER XXL
    Level 29  
    There's still quite a mess in the code, at the moment I've also sat on the project today, i.e. I've armed the new PCB, added the SD card reader to v2, the stations are now stored on the card so that when the power is restarted the radio goes back to the last station played. File playback from the card is also now up and running, but without the menu and display of folders and files- I need to do a lot of work here. I've also made a second encoder, in fact the first one, for now it handles the volume control.
    As for writing to the emulated EEPROM - here I haven't really thought too much about it, because somehow all the stations from each bank write and read when I request it, if I had encountered a problem I probably would have been up to something before. The fact that I'm at a resource limit, as I recently had to reduce the number of stations in a bank to 95, but extend the max characters to 110 due to the wider screen. I'll probably eventually do an SD card record of downloaded stations, but my plan is to still operate via github, as that's the most convenient way for me to update bank contents.
    I'm waiting for a new chassis to populate the v2 version, only the display and 2 encoders on the sides will remain on the front panel. I'll still upload the patches to github today, you can also look at the new banks, especially the last ones, I blew openfm because they change something there, but I added a lot of new ones, except that not all of them go either. I also did a test one bank with just FLAC, but here miracles happened including bad decoding and ESP32 reboots, so I deleted that bank for now.
    I don't think I'd be tempted to use the progress bar to load stations from the whole bank from github, as it literally takes a second.
    Overall cool that you took care of the Polish characters- I'll probably use it later, thanks!

    Electronic circuit with a display and encoders on a desk .

    I'm also uploading the current v2 schematic with the SD card reader added.
  • #265 21364561
    robgold
    Level 20  
    The question is whether you have checked the contents of what you "write" to the EEPROM after a reboot.
    My understanding is that the radio loads stations from the GitHub server using EEPROM commands but never writes them to Flash memory. It keeps the whole array in RAM.
    After a reboot, you read everything correctly again, so using EEPROM read you read the values correctly, but if you blocked the fetch from the server for a moment, it would turn out that there are only "FF "s in EEPROM.

    I added the progress bar because I like to see what is happening and it is always info on the display as to what the ESP is currently doing. Interestingly sometimes it takes 1 second and sometimes 3-4 seconds.
    The direction with the SD card is very good. Ultimately I think there should be copies of the banks and the address of the server from which to download them. I don't negate GitHub but I have a professional "twist" to project scalability and flexibility.

    As for the case, I was thinking of preparing a nice neat case as files for Printables to print including the front panel.
    Since you've already put so much work into the code and made it available let's make it a project that is accessible to All including the enclosure.

    And which enclosure did you choose?

    As for the Polish characters:
    however, most stations convert them to basic ASCII (e.g. all RMFs). While "station name" is always in pure ASCII, Streamtitle is not. Radio Nowy Świat stubbornly insists on using Polish characters, and VOX FM, which encodes in Unicode, is a real exception. But if you want to check a long "Streamtitle" Italo4You has no equal :) I once even wrote to Radio Nowy Świat to take care of it, but they blew it off. The bushes are displayed even on branded Denon or Yamaha stremers.

    BTW. do you have something in common with your colleague JCS from YT ? His project is surprisingly similar to this :) .
    On the I2S codec author's GitHub, JCS has just posted about problems with Paradise radio and FLAC encoding. It doesn't always work properly.
  • #266 21364676
    MAJSTER XXL
    Level 29  
    @robgold I guess such is the charm of this Arduino IDE with ESP32 that the write commands to the EEPROM are a sham, which is why I gave the last station write to the memory card as no methods of writing to the ESP32's internal memory worked Overall you're right that it's only held in that one big array, although I think at first as I was practising it I checked how it was written. I bought a standard case from Kradex type Z1 PS. As for the Fellow from YT- the fact it was an inspiration to me, as I wanted to convert a Technics tuner myself, but in the end I bought an ST-GT650 in such beautiful condition that I felt sorry to "spoil" it and abandoned the topic, although the project is tentatively very prepared to convert any tuner to internet radio- here let everyone adjust according to their needs.
  • #267 21364705
    khoam
    Level 42  
    MAJSTER XXL wrote:
    I guess that's the charm of this Arduino IDE with ESP32, that EEPROM write commands are a fiction
    .
    :D The EEPROM class has been unsupported in Arduino Core for ESP32 for many months ( Link ). It is better to use the class Preferences instead. It is easier to use and refers to stored data in NVS by a key that is a text string.
  • ADVERTISEMENT
  • #268 21365023
    robgold
    Level 20  
    >>21364705 Exactly, I realise that this is already a bit of an archive.
    Surprisingly, it works on the ESP32 if we trim the length of this EEPROM and, for example, do so:

    EEPROM.begin(3);
    EEPROM.put(1, bank_nr);
    EEPROM.put(2, station_nr);
    boolean res = EEPROM.commit();
    Serial.println("potwierdzenie zapisu EEPROM");
    Serial.println(res);
    delay(300);
    Serial.print("Zapisany wybrany bank z EEPROM: ");
    Serial.println(EEPROM.read(1));
    Serial.print("Zapisana wybrana stacja z EEPROM: ");
    Serial.println(EEPROM.read(2));
    .

    We will get the correct values after a reset.


    For "sport" will try to rewrite the record of the currently listened station and bank to the nvs.
    Ultimately I think, like Majster, that the SD card should hold everything.
    It's easily replaceable, we don't destroy the internal flash memory and in addition, it's easy to check what's stored on the card.
  • #269 21365665
    MAJSTER XXL
    Level 29  
    I have made a small change:
    - when fetching stations from the github server with the function fetchStationsFromServer() , all payload from a given bank is saved to a created or existing bank name file on the SD card,
    - when loading a station for playback with the function changeStation() , the given station is pulled from the SD card with the corresponding bank file and with the corresponding line index from the text file.
    What remains to be done is to take the station names for scrolling with the encoder wheel, probably best from an array (42 characters * 100 stations) to make it load faster, i.e. create such an array when loading the bank payload from the server. It seems to me that reading this from an SD card is rather pointless.
    I've uploaded the updated v2 version file to github:
    https://github.com/sarunia/ESP32_radio_player_v2/tree/main/ESP32_radio_v2
  • #270 21367549
    robgold
    Level 20  
    MAJSTER XXL wrote:
    I have made small changes:
    ...What remains to be done is to take the station names for scrolling with the encoder wheel, probably best from an array (42 characters * 100 stations) to make it load faster, i.e. create such an array when loading the bank payload from the server. It seems to me that reading this from an SD card is rather pointless.


    Thanks MAJSTER XXL for the update.

    Based on this code I have added the function: readSDStations(); // If the file exists we read it only from the card.
    That is, we only retrieve banks if the boolen flag bankUpdate = true is set and the bank does not exist on the SD card.
    After that, it only operates on the SD card records. In this way, you can, for example, keep your "Favourite Stations" in Bank 1 and update the others from the server.

    It would be nice if the station holding board worked in a similar way to the EEPROM function.
    Although actually when you remove the EEPROM.commit() function it works like writing to RAM.

    Additionally:
    - I have added information from where the bank is downloaded on the display
    - when entering the Banks menu, I immediately display which bank we are in
    - I have unlocked the WiFi manager so that, in the event of a connection failure, it displays the relevant information on the display. Ultimately, I think it is necessary to get rid of this manager
    get rid of it and copy the SSID and password from the SD card and then delete the access file on the card. The Wifi function rewrites this to the flash itself.
    With this you could try to "fire up" a normal Web server to manage the banks via the web like JCS did.

    Add your font definitions before displaying anything. Because if someone turns the volume encoder and changes stations almost simultaneously, they will end up in the radio station list with the font from Volume :) .

    I've noticed, a lot of problems with stations broadcasting in FLAC and it's not just Paradise radio that JCS wrote about on GitHub.
    They generally eat the buffer and can blow up the ESP.

    Do you also have the problem that after a reset you have to press reset a second time otherwise the ESP will not connect to the WiFi network?

    OLED display showing a network connection error message. Display showing a message about downloading stations from an SD card with a progress bar.

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