PCM5102A Lots of different types of noise (clicking, high frequency, low frequency)
Tuxorials opened this issue · comments
Problem Description
As soon as the esp+PCM5102A breakout (the aliexpress cheapo variant) are connected to the amp, a plethora of noise is made depending on if the device is connected or not. Check the attached video (Everything is recorded at 20cm distance on an AT2020 Microphone)
a2dp.noise.mp4
Device Description
ESP32 Wroom (just the normal version you see everywhere (im yet to find the actual name for the board))
PCM5102A (this one)
Sketch
#include "AudioTools.h"
#include "BluetoothA2DPSink.h"
I2SStream i2s;
BluetoothA2DPSink a2dp_sink(i2s);
void setup() {
Serial.begin(115200);
pinMode(27,INPUT);
pinMode(21,OUTPUT);
auto cfg = i2s.defaultConfig();
cfg.pin_bck = 4;
cfg.pin_ws = 15;
cfg.pin_data = 2;
i2s.begin(cfg);
static const i2s_config_t i2s_config = {
.mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_TX),
.sample_rate = 44100,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = (i2s_comm_format_t) (I2S_COMM_FORMAT_I2S_MSB | I2S_COMM_FORMAT_I2S_LSB),
.intr_alloc_flags = 0, // default interrupt priority
.dma_buf_count = 48,
.dma_buf_len = 256,
.use_apll = false,
.tx_desc_auto_clear = true // avoiding noise in case of data unavailability
};
a2dp_sink.set_i2s_config(i2s_config);
a2dp_sink.set_channels (I2S_CHANNEL_STEREO);
a2dp_sink.set_auto_reconnect(true, 1000);
a2dp_sink.start("Big Speakers");
}
void loop() {
delay(50); //Simplified, normally theres battery voltage measurement going on here
}
Other Steps to Reproduce
I tried both a Pixel 8 and a Galaxy A23 5G as bluetooth devices. the amps arent high quality by any means (3,80€ on aliexpress) but they dont cause any noise when the input is bridged as can be seen in the video
Provide your Version of the EP32 Arduino Core (or the IDF Version)
2.0.13
I have checked existing issues, discussions and online documentation
- I confirm I have checked existing issues, discussions and online documentation
Your code does not make any sense at all!
Please stick to the documented functionality that you can find in the Readme!
If you absolutly want to use the legacy functionality, you can find the documentation in the Wiki
The documentation isnt great as its somehow mixed between the legacy api and the new one. can you help me out in telling me which part is the legacy part
No, it is not mixed: The Readme contains the actual API!
The Legacy API is documented in a separate Wiki
Finally, there is a Wiki for the different DACs
Alright.. so i copied the code from the Readme.
#include "AudioTools.h"
#include "BluetoothA2DPSink.h"
I2SStream i2s;
BluetoothA2DPSink a2dp_sink(i2s);
void setup() {
auto cfg = i2s.defaultConfig();
cfg.pin_bck = 4;
cfg.pin_ws = 15;
cfg.pin_data = 2;
i2s.begin(cfg);
a2dp_sink.start("MyMusic");
}
void loop() {
}
Exactly the same issues. So as i suspected its not a problem of the code
Did you read the Wiki for your DAC?
I did. everything is as suggested, except for the pin layout
Did you check the solder bridges ?
Yes, although i will check them again since i have heated up the board recently (although the issues also happened before that)
I suggest to do the tests with a simpler sketch and test your I2S functionality first.
I bet the issue is either the connection or your module is damaged.
I suggest you also try another GND pin. I noticed that on my ESP32 not all GND pins are working as expected.
All resoldered ✅ Same issue. I'm pretty sure this has to be a software issue as e.g the high pitched noise is only audible for like 5 seconds after connecting, after unlocking, and obviously during and after playback. I will try what you just suggested, but again, it doesnt make sense why this would happen after stuff thats going on via bluetooth. Anyways, ill try and let you know
Is that cracking sound intended? can i buffer the sound somehow so its not so choppy but a clean sine wave
If the sine wave sketch does not give a clean sound, set the log level to Warning.
So, no there should not be any crackling sound!
I would not recognize your recorded sound from above.
Do you get the same when you test with earphones ?
I do get the same sound with headphones and on the speaker. the blue indicator led is flashing as well though so im still unsure its a hardware problem
Do you get at least a clean sine signal ?
What is your power supply ?
i have both a stepdown converter running off a lipo (the lipo powers the amps as well) as well as a usb line to the esp obviously. the cracking occurs on any combination of them (only usb, only battery, both). the signal is not clean at all
sine.2.mp4
Is this with log level Warning ?
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
This is definitively not how it should sound like and this noise is not normal.
What are the settings of your Solder Bridges ?
Oh, now that ive set it to warning, it sounds normal. I have purchased new ESP32s, but on the bluetooth code, it still has all the aforementioned issues
It was BOTH OF MY SUPPLIES.... its fixed, by using a cleaner power source.. sorry for bothering you