Ground loop issue with piezo sensor

Hello!

I am currently working on an audio project. I want to read the voltage of a piezo sensor which is fixed on an electric bass through the analog input A0. Here the schematic:

When my mac isn't plugged on the power supply it's working fine, but once it's plugged I ve got a noise and I am not able to read correctly my analog input. I tried to use an USB isolator but didn't work.

Did you already have similar issues ?
Thanks

No, but the issue I am, currently, having has to do with a MLX90393 and the ESP32 SPI API.

Use shielded wire for the connection, with the outer shield connected to Arduino GND.

If this is a true 'audio project', then the piezo must be biased mid-voltage.
Because the Arduino can't measure negative signals (the way you have connected it).

Using two 2.2Meg resistors instead of one 1Meg resistor could solve this.
Connect one from A0 to ground, and one from A0 to 5volt (assuming a 5volt Arduino is used).
The 'load' on the piezo is still ~1Megohm, but there is now a ~2.5volt bias (A/D ~512) on A0.

A laptop/PC audio groundloop is a common problem.
Can't advise there, because you didn't show the full setup.
Professional audio uses ballanced audio to eliminate these problems.
Leo..