You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected: ESP32 as a bluetooth source should play music at normal bluetooth distance when not debugging (i.e. plugged into a computer without PlatformIO/Arduino or plugged into a wall)
I am using player-sdfat-a2dp.ino example sketch to play music from an SD card to a bluetooth speaker using an ESP32.
When I upload the sketch to the ESP32 from PlatformIO and start the device monitor, everything seems to be working; the bluetooth speaker is connected, music is playing, and I can move the bluetooth speaker around the room. The moment I exit the device monitor script and restart the esp32, the bluetooth range is severely limited. It will stop playing the music if I move the speaker more than a few inches away from the esp32. This also happens when I use power from the wall. The only time I was able to get it to work was when I had the serial monitor running. This is not ideal because I would like to plug the ESP32 into the wall and have it play music to a bluetooth speaker. I do not want to have to constantly run the serial monitor.
/** * @file player-sdfat-a2dp.ino * @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-player/player-sdfat-a2dp/README.md * * @author Phil Schatzmann * @copyright GPLv3*///remove this, to find issues regarding mp3 decoding
#defineHELIX_LOGGING_ACTIVEfalse
#include"AudioTools.h"
#include"AudioLibs/A2DPStream.h"
#include"AudioLibs/AudioSourceSDFAT.h"
#include"AudioCodecs/CodecMP3Helix.h"constchar *startFilePath="/";
constchar* ext="mp3";
AudioSourceSDFAT source(startFilePath, ext); // , PIN_AUDIO_KIT_SD_CARD_CS);
A2DPStream out;
MP3DecoderHelix decoder;
AudioPlayer player(source, out, decoder);
voidsetup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
// Setting up SPI if necessary with the right SD pins by calling // SPI.begin(PIN_AUDIO_KIT_SD_CARD_CLK, PIN_AUDIO_KIT_SD_CARD_MISO, PIN_AUDIO_KIT_SD_CARD_MOSI, PIN_AUDIO_KIT_SD_CARD_CS);// setup output - We send the test signal via A2DP - so we conect to a Bluetooth Speakerauto cfg = out.defaultConfig(TX_MODE);
//cfg.name = "LEXON MINO L"; // set the device here. Otherwise the next available device is used for output//cfg.auto_reconnect = true; // if this is use we just quickly connect to the last device ignoring cfg.name
out.begin(cfg);
// setup player
player.setVolume(0.1);
player.begin();
}
voidloop() {
player.copy();
}
Other Steps to Reproduce
Things I have tried or learned:
My computer does not have bluetooth support, so the ESP32 cannot be using the computer’s bluetooth range when it is working in debug mode (therefore this is probably a software issue and nothing is wrong with the board itself)
I used multiple different cables with multiple outlets and nothing worked except for the device monitor.
Running the device monitor works, but unplugging and replugging the esp32 caused the bluetooth range to diminish
I tried multiple bluetooth speakers in case it was the speakers fault, and they all resulted in the same issue
I tried multiple ESP32s and they all also result in the same issue
I also tried updating the firmware on one of the boards and still did not fix the issue
I tried streams-generator-a2dp.ino example sketch with an ESP32 with no pins connected (as this sketch sends a sine wave and maybe the SD reader did something), but it still had the same issue.
I tried switching to the denky32 board and removing the build_flags in the platformio.ini file, but I got the same issue in both cases
I tried switching to the espidf framework, but that broke a whole ton of things.
I tried increasing the TX power level of the bluetooth to P9 with esp_bredr_tx_power_set in the btStart() method and that did not work either.
I tried setting the bluetooth mode to ESP_BT_MODE_BTDM in BluetoothA2DPCommon.h, and that didn't work either.
I tried using the ArudinoIDE on both a windows and mac computer in case PlatformIO was doing something weird, but the bluetooth range was still limited
Did you try to set the log level to a reasonable value ?
You should use 5 only to debug your functionality and otherwise leave it at 2 (to see warnings) or 1 (to see errors only)
Yes, the AudioLogger is set to Warning in the setup function of the sketch. I also tried removing the build_flags entirely and I still got the same issue. I just tried to remove the logging entirely and see if that would help, but I still got the same issue.
The problem is, I cannot debug this, because it works properly in debug. Everytime I try to see the logs, it works as intended.
Problem Description
Expected: ESP32 as a bluetooth source should play music at normal bluetooth distance when not debugging (i.e. plugged into a computer without PlatformIO/Arduino or plugged into a wall)
I am using player-sdfat-a2dp.ino example sketch to play music from an SD card to a bluetooth speaker using an ESP32.
When I upload the sketch to the ESP32 from PlatformIO and start the device monitor, everything seems to be working; the bluetooth speaker is connected, music is playing, and I can move the bluetooth speaker around the room. The moment I exit the device monitor script and restart the esp32, the bluetooth range is severely limited. It will stop playing the music if I move the speaker more than a few inches away from the esp32. This also happens when I use power from the wall. The only time I was able to get it to work was when I had the serial monitor running. This is not ideal because I would like to plug the ESP32 into the wall and have it play music to a bluetooth speaker. I do not want to have to constantly run the serial monitor.
Here is my platformio.ini file:
Device Description
ESP-WROOM-32
Sketch
Other Steps to Reproduce
Things I have tried or learned:
esp_bredr_tx_power_set
in thebtStart()
method and that did not work either.ESP_BT_MODE_BTDM
inBluetoothA2DPCommon.h
, and that didn't work either.What is your development environment
PlatformIO
I have checked existing issues, discussions and online documentation
The text was updated successfully, but these errors were encountered: