ESP32-audioI2S icon indicating copy to clipboard operation
ESP32-audioI2S copied to clipboard

Unable to get working with ESP32-S3

Open builderdev212 opened this issue 2 years ago • 11 comments

I was wondering if anyone has been able to get the library working with the ESP32-S3? I'm using the I2Saudio example and i've modified the pins to this:

#define SD_CS          5
#define SPI_MOSI      12
#define SPI_MISO      13
#define SPI_SCK       11
#define I2S_DOUT      42
#define I2S_BCLK       2
#define I2S_LRC        1

I know that my sd card pins are working properly, and the code compiles fine and connects to the webserver. I believe my issue lies in the pins I'm using for I2S. Any advice on how to properly hook up my amp would be helpful. I'm using a max98357A, which should be supported as it is similiar to the PCM5102A in pinout.

builderdev212 avatar May 08 '23 13:05 builderdev212

#define I2S_BCLK 14
#define I2S_DOUT 13 #define I2S_LRC 12

Hi. use this, to esp32 s3. It is working for me!. I'm using max98357a and 1w. connect with sd mp3 and wifi radio perfectly.

jolugama avatar May 25 '23 19:05 jolugama

I am wondering if HTTPS links work better on S3?

podaen avatar Jun 06 '23 11:06 podaen

I am using it successfully with a Seeed esp32-s3. Although for some reason I have the I2S pins set at

#define I2S_DOUT 4 // 26 // connect to DAC pin DIN #define I2S_BCLK 3 // 27 // connect to DAC pin BCK #define I2S_LRC 2 // 25 // connect to DAC pin LCK

I am using pins D3, D2, D1 on the actual board and it works just fine with various internet streaming radio channels such as "Absolute 60s", "LBC", etc, some of which transmit at a sample rate of 44khz. I have not tried anything other than the HTTP input.

I suspect my original definitions are a hangover from a Wemos D1 Mini (8266).

Les-A avatar Jul 07 '23 18:07 Les-A

Hi. use this, to esp32 s3. It is working for me!. I'm using max98357a and 1w. connect with sd mp3 and wifi radio perfectly.

Pretty please with a cherry on top can you link the speaker you are using or a photo of it? I am losing my mind trying to get audio out of the max98357 controlled by an esp32-s3. Thanks!

ConstantinCreations avatar Aug 04 '23 18:08 ConstantinCreations

Hi. use this, to esp32 s3. It is working for me!. I'm using max98357a and 1w. connect with sd mp3 and wifi radio perfectly.

Pretty please with a cherry on top can you link the speaker you are using or a photo of it? I am losing my mind trying to get audio out of the max98357 controlled by an esp32-s3. Thanks!

4,29€ 10%de DESCUENTO | 10 Uds nuevo perro electrónico navegación GPS placa para altavoz 8R 1W 8ohm 1W 2030 20*30MM de espesor 4,2 MM https://a.aliexpress.com/_EJQ7GRd

jolugama avatar Aug 04 '23 21:08 jolugama

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Feb 10 '24 01:02 github-actions[bot]

I hope it's OK to resurrect this issue as I'm facing the same problem as the title of this issue states. Otherwise let me know and I'll open a new issue.

I've been struggling for a week now to get a single beep out of my PCM5102A when I'm using ESP32-audioI2S on any of my three esp32-s3-devkitc-1-n16r8v boards I've bought.

I'm a beginner when it comes to microcontrollers. But I've managed so far to get an internet radio project converted from .ino to .cpp, compile in vscode with platformio and running on my esp32-s3 to the extent that it connects to wifi, drives the TFT and it reacts to touch. So I've made quite a few experiences until now. But I'm stuck getting I2S working.

I've tried a very simple code on the same controllers that just plays a web stream over I2S:

#include "Arduino.h"
#include "WiFi.h"
#include "Audio.h"

// Digital I/O used
//#define I2S_LRC 4
//#define I2S_DOUT 7
//#define I2S_BCLK 6
#define I2S_DOUT 4 // 26 // connect to DAC pin DIN
#define I2S_BCLK 3 // 27 // connect to DAC pin BCK
#define I2S_LRC 2 // 25 // connect to DAC pin LCK

Audio audio;

String ssid =     "xxxx";
String password = "yyyy";

void setup() {
    Serial.begin(115200);
    WiFi.disconnect();
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid.c_str(), password.c_str());
    while (WiFi.status() != WL_CONNECTED) delay(1500);
    audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
    //audio.setI2SCommFMT_LSB(0);
    audio.setVolume(10); // default 0...21
    audio.connecttohost("http://www.wdr.de/wdrlive/media/einslive.m3u");         // m3u
}

void loop()
{
    audio.loop();
}

I've found that this code works on an ESP32 but not my ESP32-S3 controllers. The same is true of another simple code example I've tried to play an MP3 file from SPIFFS. Again it worked on ESP32 but not on ESP32-S3.

I've flashed the above code to my ESP32-S3 with vscode/platformio but no success whatever I try. From the serial monitor it appears to do what it's supposed to do, but no matter what I've tried, no sound at all comes out of any of my PCM5102A DACs.

This is what I've tried:

  • ESP plugged into breadboard with TFT and DAC connected.
  • ESP wired directly to the PCM5102A and nothing else.
  • Powering it both with PC-USB and bench PSU.
  • Shorter dupont wires between ESP and DAC.
  • Various GPIO pin combinations while taking care not to pick pins that are used for JTAG, UART or USB.
  • 3 different PCM5102A boards.
  • include ESP32-audioI2S via gitlab link to this repo as well as "esphome/ESP32-audioI2S@^2.0.7".
  • Countless compile options to enable PSRAM and debugging.

I started to suspect that my 3 Chinese PCM5102A boards are all faulty. The next thing I've tried is to order a regular ESP32 (esp-wrover-kit). This controller arrived today and I've flashed the same code on that with the default Pinout I've found for regular ESP32s:

#define I2S_DOUT      25
#define I2S_BCLK      27
#define I2S_LRC       26

To my surprise the code actually worked on the ESP32 and my PCM5102A board played the radio station. So I'm pretty confident that my PCM5102As should work in general. But I don't really want to switch microcontrollers and start over with an ESP32 after all the time I've invested in figuring out the ESP32-S3.

I'm pretty confident that I've got the general concept for wiring up the PCM5102A and sending audio to it via I2S figured out. My problem must be related to the ESP32-S3 devkits I'm using. But I've hit a dead end on what to try next. Several comments I've found claim that this is supposed to work. But in my case nothing I've tried so far made it work.

If anyone has any idea what else I could try I'd much appreciate any help.

MyAir avatar Feb 20 '24 22:02 MyAir

Based on the detailed description, I don't think you've done anything wrong. On some S3 boards, the 5V pin is only an input and does not provide 5V, in which case the DAC could be de-energised. If this is the case, you can bridge the diode on the 5V pin or use the 3.3V output.

schreibfaul1 avatar Feb 20 '24 23:02 schreibfaul1

Thanks for the quick reply. I don't think that the 5V pin is the issue in my case. Otherwise I would have seen that problem already with the TFT display while only powered via USB during my inital attempts. I've wired my breadboards 5v power rail to the 5V pin and fed that to the VCC of my TFT. Also the DAC should have have worked with the bench PSU connected. But I'll try again a few variants with the PSU just to be sure. Is there a chance that I've messed up anything in platformio.ini?

[env:esp32-s3-devkitc-1]
platform = https://github.com/platformio/platform-espressif32.git#v6.4.0
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.14
board = esp32-s3-devkitc-1
board_upload.flash_size = 16MB
board_build.partitions = default_16MB.csv
build_flags = 
	-DBOARD_HAS_PSRAM
	-DARDUINO_USB_CDC_ON_BOOT=1
	-mfix-esp32-psram-cache-issue
	-DARDUINO_ESP32S3_DEV
	-DCORE_DEBUG_LEVEL=5
	-DCONFIG_SPIRAM_USE
board_build.arduino.memory_type = qio_opi
framework = arduino
monitor_speed = 115200
debug_tool = esp-builtin
debug_init_break = break setup
build_type = debug
lib_deps = 
	https://github.com/schreibfaul1/ESP32-audioI2S.git
;	esphome/ESP32-audioI2S@^2.0.7

I've come across some comment stating that I2S was not working until that guy got PSRAM activated. Another thread I've come across talked about some clock frequencies being off. But I didn't understand what they were talking about at all.

MyAir avatar Feb 20 '24 23:02 MyAir

Ich verwende auch die hier beschriebene Konfiguration und ein angepasstes Testprogramm um zusätzliche Informationen zu erhalten. Das ESP-Board ist ein ESP32-S3 DeviceKit N16R8 mit einem ESP32-S3-Wroom-1 und ein PCM5102. Meine Platformio.ini sieht so aus:

`[env:esp32-s3-devkitc-1] platform = espressif32 board = esp32-s3-devkitc-1 framework = arduino

monitor_speed = 115200 monitor_filters = esp32_exception_decoder upload_speed = 460800 ; 921600, 512000, 460800, 256000, 115200

board_build.mcu = esp32s3 board_build.f_cpu = 240000000L board_upload.flash_size = 16MB board_build.arduino.memory_type = qio_opi build_flags = -DCORE_DEBUG_LEVEL=3 -DCONFIG_ARDUHAL_LOG_COLORS -DBOARD_HAS_PSRAM -DCONFIG_IDF_TARGET_ESP32S3 -DARDUINO_RUNNING_CORE=1 -DARDUINO_EVENT_RUNNING_CORE=1 -mfix-esp32-psram-cache-issue build_unflags = -DCONFIG_IDF_TARGET_ESP32 -Wall -Wextra -DARDUINO_RUNNING_CORE -DARDUINO_EVENT_RUNNING_CORE

lib_deps = ; esphome/ESP32-audioI2S@^2.0.7 https://github.com/schreibfaul1/ESP32-audioI2S.git `

Und wenn der ESP gestartet ist bekomme ich diese Meldungen am Seriellen Monitor:

_ESP-ROM:esp32s3-20210327 Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x2b (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:1 load:0x3fce3808,len:0x44c load:0x403c9700,len:0xbd8 load:0x403cc700,len:0x2a80 entry 0x403c98d0 [ 230][I][esp32-hal-psram.c:96] psramInit(): PSRAM enabled Serial Ausgabe aktiv [ 295][I][WiFiMulti.cpp:84] addAP(): [WIFI][APlistAdd] add SSID: Lorenz_net1 Starte WiFi [ 3281][I][WiFiMulti.cpp:114] run(): [WIFI] scan done [ 3282][I][WiFiMulti.cpp:119] run(): [WIFI] 4 networks found [ 3283][I][WiFiMulti.cpp:160] run(): [WIFI] Connecting BSSID: 98:DA:C4:63:68:48 SSID: Lorenz_net1 Channel: 11 (-65) [ 3309][W][WiFiGeneric.cpp:1061] eventCallback(): Reason: 202 - AUTH_FAIL [ 3411][I][WiFiMulti.cpp:174] run(): [WIFI] Connecting done. Setze Audioausgang Setze Audio Lautstärke info Connect to new host: "http://mp3.ffh.de/radioffh/hqlivestream.mp3" info PSRAM found, inputBufferSize: 638965 bytes info buffers freed, free Heap: 254404 bytes info Connection has been established in 63 ms, free Heap: 253312 bytes Schreibe Audioquelle fest Total heap: 351396 Free heap: 251820 Total PSRAM: 8385815 Free PSRAM: 7701335 Setup beendet icyurl https://www.ffh.de station HIT RADIO FFH bitrate 128000 info MP3Decoder has been initialized, free Heap: 252296 bytes , free stack 5952 DWORDs lasthost http://mp3.ffh.de/radioffh/hqlivestream.mp3 info stream ready info syncword found at pos 0 info MP3 decode error -2 : MAINDATA_UNDERFLOW info syncword found at pos 416 info syncword found at pos 0 info Channels: 2 info SampleRate: 44100 info BitsPerSample: 16 info BitRate: 128000 info StreamTitle='' streamtitle info StreamTitle='FFH NACHRICHTEN' streamtitle FFH NACHRICHTEN info StreamTitle='FFH STAUPILOT' streamtitle FFH STAUPILOT info StreamTitle='FFH WETTER' streamtitle FFH WETTER info StreamTitle='Du hörst HIT RADIO FFH' streamtitle Du hörst HIT RADIO FFH info StreamTitle='Avicii feat. Aloe Blacc - Wake Me Up' streamtitle Avicii feat. Aloe Blacc - Wake Me Up

Das Programm scheint zu laufen, aber ich erhalte keine Tonausgabe am PCM5102. Hat jemand eine Idee woran das liegen kann?

IGLO70 avatar Feb 22 '24 20:02 IGLO70

Your hunch about the 5V pin on the ESP32-S3 was correct Wolle! It is indeed an input-only pin and does not output 5V when connected via USB alone. I gave it another try on my breadboard with the bench PSU connected and (sort of) succeeded with the following pinout:

ILI 9341 TFT:	ESP32-S3:
VCC		3.3V Rail
GND		GND 
CS		10
RESET		5
DC		6
SCI (MOSI)	11 (Same as T_DIN)
SCK		12 (Same as T_CLK)
LED		7
SDO (MISO)	13 (Same as T_DO)
T_CLK		12 (Same as SCK)
T_CS		1
T_DIN		11 (Same as SCI MOSI)
T_DO		13 (Same as SDO MISO)
T_IRQ		2

PCM5102MK:	ESP32-S3:
VCC		5V Rail (No 5V output from ESP32-S3 5V pin!)
GND		GND
GND		GND
LRCK		17
DATA		18
BCK		8

With this setup I FINALLY was able to get the first few sound fragments out of my PCM5102 from the web radio stream I'm connecting to. I also had to change the FLT jumper on my PCM5102MK from LJ to I2S to get sound instead of noise. Please let me know if my pinout is questionable or non standard. I tried to pick pins that are not used by USB or JTAG and this is what I came up with. But if there's a better, more standard setup, let me know and I'll try that out as well.

It appears that the breadboard is still interfering with the wifi connection despite me soldering a small wire to the antenna. Found that tip with the antenna here Moving the wifi AP next to the breadboard improved the sound quite a bit so I barely had any dropouts anymore. So it's definitively the breadboard that's interfering with the wifi antenna of the ESP32-S3.

Thanks a lot for that tip with the 5V pin! Now I can continue my journey with the ESP32-S3. I guess I'll start with figuring out how to make the 5V pin to output power coming from the USB so I can construct a test setup without breadboard. Maybe I can do with raising the microcontroller from the breadboard with some raiser pins but I don't have these at hand at the moment. But eventually I'll have to construct a stripboard for all the components anyway if I ever want a fully functional radio alarm clock. Hopefully I can find a placement for the ESP32-S3 on the board where wifi antennan still gets enough signal.

EDIT: I've found a solder pad jumper on my board called IN-OUT. If I solder these pads together I get 5V output on my 5V pin and my DAC also workes with just USB plugged in and the PCM5102 connected with a few jumper wires. I also found that GPIO 17 and 18 are used for U1TXD and U1RXD so I'l probably use GPIO 9 and 8 instead.

@IGLO70 Check bei Dir mal mit dem Multimeter ob der PCM5102 auch 5V bekommt zwischen VCC und GND. Evtl. hast du ja das gleiche Problem wie ich, dass die 5V Spannung vom USB Anschluss nicht auf dem 5V Pin vom ESP32-S3 heraus kommt.

MyAir avatar Feb 23 '24 14:02 MyAir

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Mar 25 '24 02:03 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Apr 08 '24 02:04 github-actions[bot]