logo elektroda
logo elektroda
X
logo elektroda

Internet radio and audio file player on ESP32-S3

MAJSTER XXL 100719 1227
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #421 21401942
    robgold
    Level 20  
    Master , from what I can see from your analyser you have a falling edge trigger set up and you also go low for 9ms.
    I inserted Serial.print where theoretically it should be those 9ms and it was giving me 0us pulse length or some very large values which puzzled me.

    Screenshot from a signal analyzer showing an IR-NEC protocol readout from an input channel with falling edge triggering in KingstVIS. .
  • ADVERTISEMENT
  • #423 21402335
    robgold
    Level 20  
    And whose version did you upload?
  • #425 21402352
    robgold
    Level 20  
    That is, for some reason the function cannot recognise the remote control code. Upload the Major's sketch still and see if you will have the correct codes in the terminal.
  • #426 21402402
    hevet
    Level 16  
    On the Major's sketch the remote works, although there are mixed up buttons, 2 is quieter, ok is louder. A matter of assigning the buttons correctly.
  • #427 21402453
    robgold
    Level 20  
    Download the current version 3.14, no NEC misframe lock, and paste what times appear in the terminal for pulses.

    I have about 5 of these little remotes, from various devices I've accumulated. Tragically they keep time levels. They very often exceed the hysteresis tolerances of 120 or 150us. Especially on the shortest pulse they can have even 700us. The RC-406 Kenwood is an exemplary competitor.
  • #428 21402460
    hevet
    Level 16  
    Only this showed up in the terminal
    NEC code OK:FF18E7 MSB-LSB: E718FF00 ADR:0 CMD:18
    debug -- Analysis - pulse 9ms:9063 4.5ms:4491 1690us:1634 690us:589
    Other button
    Stack:5152
  • ADVERTISEMENT
  • #429 21402463
    robgold
    Level 20  
    So it reads your remote control correctly.
    NEC code OK
    FF18E7 MSB-LSB: E718FF00 ADR:0 CMD:18 .
    9ms:9063
    4.5ms:4491
    1690us:1634
    690us:589

    As I wrote, the worst these remotes hold is this short pulse but here it is not a tragedy.
    Now for each button read yourself these two values ADR:0 CMD:18 and in the definition section of the remote control
    e.g. for the voice command you have:

    #define rcCmdVolumeUp 0xB914 you change to #define rcCmdVolumeUp 0x0018 i.e. you give the address and right after it the command.

    So for all buttons.
  • #430 21403321
    hevet
    Level 16  
    Thanks for the explanation. Unfortunately the codes from the remote read very poorly, randomly once from closer, once from further away. after pressing the button several times. I've tried several IR sensors, same thing on each, same sensors on other radio projects work without problem. I have added a filter capacitor as per datasheet, with no result. On the Majster code it is better, but here it also sometimes misrepresents the remote control code, but pretty much works. The terminal shows that it receives codes from the remote.
  • #431 21403359
    khoam
    Level 42  
    robgold wrote:
    The operation of the void IRAM_ATTR analyzePulseFromIR() function occurs in the Ticko Timer2 interrupt set to 50us
    .
    It is the CPU on which this timer is fired that is no longer dealing with anything else. Have you checked how long it takes to execute the analyzePulseFromIR() function?
    https://docs.espressif.com/projects/esp-idf/e...ce/system/esp_timer.html#timeout-value-limits

    The Arduino Ticker is nothing more than a wrapper for esp_timer.
  • #432 21403396
    robgold
    Level 20  
    >>21403359 I don't expect Ticker to be anything other than a 'wrapper' for one of the ESP timers it seems obvious. The function in its entirety only executes if an external interrupt from the receiver pin "catches a change" on that pin.

    Khoam
    Do you have any suggestion on how to check this ? Memorize the millis before and after and "spit out" on the terminal ?
  • #434 21403450
    robgold
    Level 20  
    And just out of curiosity, are you basing this on your experience that 50us can "kill" a programme or on ESP documentation ?
  • #435 21403542
    khoam
    Level 42  
    robgold wrote:
    And just out of curiosity are you basing this on your experience that 50us can "kill" a program or on the ESP documentation ?
    .
    I base this on my experience and the ESP-IDF documentation. Too short esp_timer call times can negatively affect critical mechanisms such as TCP/IP stack support, SPI, I2C or UART. Additionally, such practices are discouraged in the context of real-time systems. If you have other experiences or sources, I'd be happy to hear about them - it could be an interesting exchange of knowledge.

    The Arduino Ticker uses the ESP_TIMER_TASK timer mode, not ESP_TIMER_ISR (vide Arduino Core sources). Higher priority tasks (Wi-Fi, BLE) may therefore block the operation of such a timer, and its subsequent calls will be delayed. Tasks handled by esp_timer in ESP_TIMER_TASK mode are run in a priority 22 thread, not as interrupts.
  • ADVERTISEMENT
  • #436 21403590
    robgold
    Level 20  
    That's why I asked about your practical experience regarding spinning these values to the limits and beyond what the documentation states. Do you have any project where at these "Arduino" 50us something already stopped working properly in ESP ? Espressif gives 50us as "cycle" (Periodic timers: ~50 μs) and 20us as "one shot" allowed. From what you have written it appears that this is an Arduino software prosthesis anyway and there is no chance of "messing up" the system with this.

    I would be happy to use the knowledge you have, maybe you can help write the read functions of this remote control correctly ?

    As for the limits given to the public, my experience is that more than once we have asked the manufacturer of a given IC for values from their EOL and limits from testing. Everything you read in the datasheet is worstcase + margin. So that it ALWAYS works.
  • #437 21403692
    khoam
    Level 42  
    robgold wrote:
    Whatever the publicly stated limits are, my experience is that more than once we have asked the manufacturer of a given IC for values from their EOL and test limits. Everything you read in the datasheet is worstcase + margin. So that it ALWAYS works.
    .
    No, datasheets are written so that users at different levels of experience can rely on them without risk of failure or problems. If in doubt, you can consult the manufacturer.

    Regarding the use of hardware timers and interrupts in the Arduino for ESP32, you can use the function set to handle them:
    https://espressif-docs.readthedocs-hosted.com/projects/arduino-esp32/en/latest/api/timer.html
    esp32-hal-timer.h header file. These are the so-called General Purpose Timer (GPTimer) functions.
    https://docs.espressif.com/projects/esp-idf/e.../esp32/api-reference/peripherals/gptimer.html
    Maybe this information will be useful to someone.
  • #438 21405436
    robgold
    Level 20  
    Update for version 3.14 - Link

    - I have improved the remote control reception functions. This version should respond correctly to the remote control. On my test radio it works very responsively, it does not "lose" commands
    - the numeric buttons on the remote control work, you can enter any station number, on the screen you will get information which station is under a given number, switching is done by pressing the button defined as "Enter/OK". If you do not press anything, the radio will return to the main screen after 6 seconds (without changing stations).
    - switching of banks from the remote control works
    - it is possible to switch off the VU-meter "beautification" from the remote control
    - an information screen has been added during the stream loading (helpful if a station is "dead" then we know what is happening)
    - when a station is opened, the station list moves to the position of the newly opened station
    - one of the remote control buttons (rcCmdMute 0xB916) test-added to the function activating the preview in the terminal on filling the audio buffer

    The remote control is defined in this area of the code. Most Chinese remotes on the NEC protocol will have an address of 00, so enter 0x00 and the command number read from the terminal for the key.

    #define rcAdress 0xB9
    #define rcCmdVolumeUp 0xB914      // Głosnosc +
    #define rcCmdVolumeDown 0xB915    // Głośnosc -
    #define rcCmdArrowRight 0xB90B          // strzałka w prawo - nastepna stacja
    #define rcCmdArrowLeft 0xB90A      // strzałka w lewo - poprzednia stacja  
    #define rcCmdArrowUp 0xB987    // strzałka w góre - lista stacji krok do gory
    #define rcCmdArrowDown 0xB986  // strzałka w dół - lista stacj krok na dół
    #define rcCmdOk 0xB90E          // Przycisk Ent - zatwierdzenie stacji
    #define rcCmdSrc 0xB913
    #define rcCmdMute 0xB916
    #define rcCmdDirect 0xB90F
    #define rcCmdBankMinus 0xB90C
    #define rcCmdBankPlus 0xB90D
    #define rcCmdKey0 0xB900
    #define rcCmdKey1 0xB901
    #define rcCmdKey2 0xB902
    #define rcCmdKey3 0xB903
    #define rcCmdKey4 0xB904
    #define rcCmdKey5 0xB905
    #define rcCmdKey6 0xB906
    #define rcCmdKey7 0xB907
    #define rcCmdKey8 0xB908
    #define rcCmdKey9 0xB909
    .


    Radio screen displaying station number 12 with bank 1 and label Radio 357. .
    Radio display showing station selection. .
    Display showing Loading stream... message and station name RMF Classic. .
  • #439 21405492
    MAJSTER XXL
    Level 29  
    @robgold It's great that you've got it right, I've just uploaded your program and it's finally got all my NEC remotes working beautifully, admittedly I didn't change the codes, but I did read them on the serial, so I can confirm that it's finally as it should be with this remote control reception. At the weekend I'm going to change my version, today I've also added the bank switching at my place, but the more codes I have declared the worse it works.
  • ADVERTISEMENT
  • #440 21405526
    DJCheester
    Level 26  
    Hello Foreman XXL I have a question about how it is with you with these directional buttons

    https://pl.aliexpress.com/item/1005001594194930.html

    Will they be used ?

    Because on the diagram you have such a manipulator so I understand that one should be purchased

    https://allegro.pl/oferta/joystick-analogowy-arduino-modul-2-osiowy-13845360235

    And a question to my colleague robgold, is the evo3 version already on one encoder + remote control operation ?

    And you once wrote that you give up support for sd card as MP3 player or does the soft still support MP3 playback ?

    Gentlemen and last question any standby button ? Have you not thought about it ? Unless by pressing the encoder it is implemented ?

    Greetings ...

    Greetings ...
  • #441 21405554
    MAJSTER XXL
    Level 29  
    @DJCheester in the diagram it's a joystick with a button like in the second link, it does in my case as an analogue simulator for a digital switch, I didn't have anything compact directional so I used it for quick right - left switching. I don't have a program under a dedicated directional switch like you gave in the first link, so the code has to be adapted. At the moment the remote is the most useful, in fact since we are embracing the remote my buttons are slowly becoming unused.
  • #442 21405569
    DJCheester
    Level 26  
    Thanks for the reply, I'm slowly getting down to the PCB but I'm still holding back so that I can possibly add what you are currently writing i.e. an infrared receiver.

    And the question of switching on the radio, is it done with an encoder, for example by pressing ?

    Or are you planning a standby button from the remote control?
    And if you do not use an encoder to turn on the radio, is it not worth adding a nice button, e.g. a metal one illuminated with LED for the sake of craftsmanship?

    I ask because I would add it to the PCB right away.

    And last question, maybe it is worth to think about some kind of clock mode when the radio is off, to collect time from the net ?

    What do you think about such ideas.

    Beautiful work this radio, greetings....
  • #443 21405590
    robgold
    Level 20  
    @MAJSTER XXL , at you too since there is a remote control the encoders might not exist ? ;) I have exactly the same.

    @DJCheester ,
    The Evo3 operates the radio from a single encoder (volume, station switching, bank switching). At the moment, in 3.14 there is still the rest of the functionality i.e. mp3/flac/aac player and support for a second encoder, so if you connect them it will work. However, since there is a remote control, I gave up on the directional buttons (even though they came to me from Ali, I will probably use them for something at some point).

    SD card is and will be supported, for me it's the best way to keep settings and banks because it's easy to edit using a computer

    The Standby button scrolls in from time to time as an option but if it does it's more likely to be a hardware/software solution with me. That is, we cut the power with a mosfet and by pressing the button we switch on the gate and then ESP sustains it by itself. At the moment I have such a nice micro-switch implemented.

    Clock..hm I was thinking about it, but I already have so many watches around, another "power eater" with USB ;) To consider. Question about the durability of the OLED with such 24/7 operation
  • #444 21405604
    Andrzej Ch.
    Level 33  
    @robgold
    Well done on the IR remote control :) .
  • #445 21405605
    hevet
    Level 16  
    @robgold does the first encoder button do anything in your code? Right left is the volume, and the button?
  • #446 21405615
    DJCheester
    Level 26  
    Acha meaning create under one or two encoders (that's how I have it now) as for the clock actually OLED is not the same as LCD and here durability will fly hard. I hadn't thought of that.

    As for the standby you would have to draw it on the schematic somehow, or just make a hebel to cut off the power supply - probably the easiest way.

    Regards...
  • #447 21405617
    robgold
    Level 20  
    In addition to the original function envisaged by Majster - entering the "player - radio" selection menu after holding down 3 seconds, when we are in the bank selection menu pressing it always forces an update of the bank in question from the GitHub server regardless of whether we have a file of that bank on the SD card or not.

    I will move this function to the remote control which will make it completely unnecessary to have a second encoder for the radio.
  • #448 21405623
    DJCheester
    Level 26  
    As for the remote control, the MP3 player's functions could also be operated from the remote control alone. This would simplify the hardware issue to a minimum, i.e. one encoder and an ir sensor for operation and that would be all.

    It would be good for you guys to finalise your softwares so that they are compatible with one hardware.

    Regards....
  • #449 21405629
    robgold
    Level 20  
    @DJCheester

    I'm beating myself up with my thoughts but I will most likely cut out the player function completely. For me it would still make some sense if it wanted to work properly with FLAC files. Unfortunately I fought for a while with the audio library but it has a very big problem with playing (in fact it doesn't play at all) FLAC files of size 100 or 150MB. Perhaps Majster will have a moment to refine this topic...we'll see.

    For the moment we have 100% compatibility. Of course, remote codes will always be different because everyone has a different remote. Perhaps a dedicated PCB will force some changes in the trunks but then this can be taken care of with a header file.

    By the way from colleagues who are drawing the board for the ESP module. Has anyone found a library for the EPS32-S3 WROOM module itself ? Because I feel something like I'm in for the fun of drawing it.
  • #450 21405636
    DJCheester
    Level 26  
    For me, an MP3 player would be enough, and I want to make a small kitchen radio so that I can listen to stations from the Internet as well as my own tracks.

    In fact, the version I read about would be ok, one encoder +ir the rest of the options on the remote control are basic, that is knob right left volume and when pressing and turning stations and finito MP3 support, if it does not interfere with the code I would leave it fully switched and supported only by ir (possibly 3 seconds as you wrote selection of radio/player mode) and then the same operation normally volume right left and after pressing song up/down from the card and nothing more is needed from the control panel.

    You don't really need anything else from the remote control, such as UV Meyer eq, station numbers from the numeric keypad and other additional trinkets.

    Nice radio 😀.

    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