Reading unplugged 3.5mm jack input with ADC

Hello everyone! I am working on a project (spectrum visualizer) using RPi Pico and its ADC. One of the possible inputs is 3.5mm jack connected to the voltage divider. When I disconnect a plug, it looks like signal is oscillating around ~1.6V. An average value(DC component) is subtracted from each sample in software, but the signal amplitude when there is nothing connected just seems too high, so the MCU processes it like a valid wave. I can get rid of this by filtering out amplitudes less than some constant value, but that means losing a lot of info from a real audio signal. Is there a way to reduce the amplitude or get the ADC to read zero (or 3.3V) when there is nothing connected? Thanks.


The schematic shows pins 4 and 5 on the 3.5mm jack are not connected to ground. That will cause what you describe as the input is now acting like an antenna!

1 Like

Oh, that's it! I was clearly overthinking there, haha. Thanks a lot!

Even without those pins grounded you were only reading a value in the range 124-127, which is probably too low a variation to be considered a signal. If you get a constant value with those pins grounded, I think you got lucky. A variation of 1 bit wouldn't be unusual. Perhaps your code should ignore variations of 1 or 2 off from the average value when no signal is connected.

What if do you want your code to do if:

  • A jack cable is plugged into the Pico, but the other end of the cable isn't plugged into anything.
  • A jack cable is plugged into the Pico, the other end is plugged into some device, but the device isn't producing any output.

Do you want the Pico to regard the noise pick up in those cases as a signal, or as no signal? If the latter, then you will need to check the min/max values from the ADC and decide on some threshold that constitutes a signal versus just reading noise pick up.

It's only a couple of counts, which if you are getting "full range" with a normal signal is only a couple of percent. That's not terrible.

With ANY analog-to-digital conversion you can be on the "hairy edge" between 2 counts and you can't always have absolute stability.

You could include some "fuzzy logic" to ignore lol values after getting only low readings for a couple of seconds, etc.