ESP32 with max98357a board works. But I can't use void loop() function for other purposes
Posted: Fri May 20, 2022 5:23 pm
I have been learning how to program in esp32 using arduino IDE.
I couldn't figure out how to use max98357a board with Esp32-DevKitC. I have tried "Audio.h" and "AudioTools.h" libraries but not is changed.
My first attempt was just testing voice output. My code is below:
It works as intended but when I try to add some commands to the loop function, It stops working.
I mean if I change the loop function as below, it stops connecting to the audio stream.
Is it possible to use max98357a with some additional codes apart from just simple audio.loop().
I couldn't figure out how to use max98357a board with Esp32-DevKitC. I have tried "Audio.h" and "AudioTools.h" libraries but not is changed.
My first attempt was just testing voice output. My code is below:
Code: Select all
#include "Arduino.h"
#include "WiFi.h"
#include "Audio.h"
// Digital I/O used
#define I2S_DOUT 26 // DIN connection
#define I2S_BCLK 27 // Bit clock
#define I2S_LRC 14 // Left Right Clock
Audio audio;
String ssid = "MYCROFT";
String password = "145678abc789";
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.setVolume(21); // 0...21
// audio.connecttohost("http://www.wdr.de/wdrlive/media/einslive.m3u");
// audio.connecttohost("http://macslons-irish-pub-radio.com/media.asx");
// audio.connecttohost("http://mp3.ffh.de/radioffh/hqlivestream.aac"); // 128k aac
// audio.connecttohost("http://mp3.ffh.de/radioffh/hqlivestream.mp3"); // 128k mp3
audio.connecttohost("http://vis.media-ice.musicradio.com/CapitalMP3"); // 128k mp3
// audio.connecttospeech("Wenn die Hunde schlafen, kann der Wolf gut Schafe stehlen.", "de");
// audio.connecttohost("http://media.ndr.de/download/podcasts/podcast4161/AU-20190404-0844-1700.mp3"); // podcast
}
void loop()
{
audio.loop();
}
I mean if I change the loop function as below, it stops connecting to the audio stream.
Code: Select all
void loop()
{
delay(3000);
Serial.println("Hello");
audio.loop();
}