When my Bluetooth receiver is powered by a 5V USB charger plugged directly into mains power, I get no interference/noise. But when I power the Bluetooth receiver in the manner I've depicted below, I get a lot of interference/noise.
My setup is a bit more complex than the diagram I've put together; I actually have a ground loop isolator on the audio line, which then continues on to a preamp mixer that is grounded to mains ground, then the audio continues on to an amp. But, those things are working properly. What I would like to address/discuss is the diagram.
Clearly the relay is to blame. I perceive there to be three potential remedies:
Maybe a resistor on the 5V power line between the relay and the Bluetooth receiver (just a guess)
More confident in this alternative: Put an optocoupler after the relay and have the collector/emitter switch on power to the Bluetooth receiver on an isolated circuit. Yes, it's redundant to have a relay before the optocoupler, but since the ESP32 and the relays are in a junction box that I'd rather leave alone, I could build the optocoupler circuit as a simple addition instead of making revolutionary changes inside the junction box (unsoldering, soldering again, etc.).
The Bluetooth receiver probably draws more than 50mA, so the pc817 I would use is not enough for an isolated on/off circuit. I'd need the opto to drive something else, like an 2N2222 switch. If I were to solve this dilemma on my own, without reaching out for help, I'd probably aim for this, but before I start I'd like to ask for advice.
Edit: Perhaps it's not "clearly" the relay. I'm no expert. I suppose it could also have something to do with the shared GND.
I'd planned to use the 5V as VCC for some sensors that I've connected to my ESP32. But I've changed my design so I can power all sensors from "Power Source 1". I then removed the shared GND (connected the "Power Source 2" GND directly to the Bluetooth receiver), and left the "Power Source 2" 5V in the relay. The noise/interference was still very pronounced even though the GNDs were now not-shared.
I tried a resistor (and a potentiometer), which had no desired effect.
I tested the Bluetooth receiver with my multimeter, to find that it seems to peak at 40mA when it connects to my phone, but operating current is between 20mA and 27mA (music not playing vs. music playing). ...and 15mA when nothing is paired. Nonetheless I couldn't get it to power on with only the pc817.
Long story short, I've found success with remedy #3 from my original post. I tested it on my breadboard with a great result! Here is a schematic. I might have made some protocol errors; I don't know much about schematics but I did my best. Any feedback would be appreciated.
I didn't want to convolute things. I have an SX1509 driving the relays but including that would have only added to my time with the ol' Photoshop. ...and the audio stuff works/worked fine when the BT was powered in a non-relay fashion. So, I knew the culprit was captured in that diagram.
I'm happy with my remedy #3 result. If anyone has any recommendations for the resistance values, do chime in. I know these resistors work but if they can be improved upon I'm interested.
Those can't be completely justified without access to the entire documentation. If it works for you now, fine. There is nothing really bad about the circuit you posted.
This sort of implies that there are unrelated things that wouldn't affect the question. But that presupposes absolute confidence that they are not related.
Frequently here, we find that people miss things that they think are not related. That is often exactly why they can't find a solution. They aren't able or interested in pursuing possibilities that they have ruled out, without any reliable testing or investigation to prove them unrelated.
That is why we almost always expect questioners to follow the guidelines, which spell that out in detail:
We have a difficult job sometimes, it's hard to estimate the harm in small deviations from the normal forum expectations. It's not meant to scold, but it often has to be said.