Go Down

Topic: Connecting audio (line or phones out) to Arduino A0 - need help please! (Read 399 times) previous topic - next topic

romandesign

Hi everyone, I'm stuck and I need help! What do I need to get the audio signal to Arduino for FFT processing? Is there a simple solution?

I would like to build audio spectrum analyzer based on Arduino Nano and MAX7219 FC16 dot matrix display module. I use the code from this video and here is the code.

The code is kind of working (I had to add "#define USE_FC16_HW   1" to the library to make it work with my display module), but I have problems getting the signal in with the right voltage (or at least I think that's what the problem is, it might be something else). It looks like it's getting a noise of some kind, even if nothing is connected to A0. I see the lines dancing a bit around same level. And when I try connecting audio - there's no change or maybe a very slight change, but no definitive reaction.

I tried connecting audio from smartphone 3.5mm jack directly to A0 (and ground pin), I also tried the attached voltage divider based schematics - no result. I tested reading analog values with the potentiometer (see attached) and simple test code outputting values and I get readings 0 to 1023 in serial interface, depending on pot position, so I haven't fried anything and analog read is working. I also tried connecting the same pot between audio ground and level instead of 5V - and on one extreme pot position I was getting 0 to 25 jumps in values (so very small voltage I guess) and on the other extreme - nothing at all. Connecting with the attached voltage divider schematics I do get values around 400 with test code even when nothing is playing, so I guess that's what I'm seeing as "the noise". With the code in the link, trying to read and output analog values hangs the board, I guess due to low-level settings that code uses and I don't understand.

Any advise on how to proceed? I'm not sure what am I doing wrong... Or is there a problem with the code? The video description says "The input audio is level-shifted and then put through an anti-aliasing filter. " but no further details are given. I would appreciate your help.

Grumpy_Mike

The first circuit is the one to use. If you get no signal all then you need more volume from the audio output.

romandesign

The first circuit is the one to use. If you get no signal all then you need more volume from the audio output.
Two problems with that:

1. There is "noise" even when no input and nothing is connected. I need to get it to zero, so something is not right. I tried both via USB from PC and separate regulated power supply as power source s.

2. The phone's output is already at the maximum volume. And when completed I will use it with line level RCA output, so I can't really make it higher.

It looks like LED spectrum levels get just a little bit higher when there is audio playing, so it's getting something, but just too low, and/or maybe reference point is in the wrong place because of the "noise". Not sure I'm making sense.

Grumpy_Mike

Quote
1. There is "noise" even when no input and nothing is connected.
So you haven't got that circuit correct, because you should not get noise. Try 10K instead of 100K but that value should be fine. So while the schematic is right it is likely that is not what you have. I have used that circuit many times with no problems.

Quote
2. The phone's output is already at the maximum volume. And when completed I will use it with line level RCA output, so I can't really make it higher.
So if you can't make it higher then you can't do this project. You need an amplifier to increase your audio signal to 2.5V peak to peak. It will not work with a small analogue signal.

romandesign

So you haven't got that circuit correct, because you should not get noise.
The noise is there even when this circuit is not connected - only display and USB are connected to Arduino. So it's not the circuit that's the cause. Same with USB power or cleaner regulated 12v through breadboard power supply, so I don't think it's noise from power. It looks like analyzer showing jumping medium levels in all spectrum bands, higher level in lower bands - so looks like it's kind of working as usually low frequencies are peaking. The code is beyond my knowledge, so I can't figure out if that's a problem with the code, or that my line level has to be at a specific voltage to provide "quiet" or "0" level and something above that as normal signal level. I just don't know.

Maybe I need an op amp... Not sure which, all I found on the internet is for mic amplification, not line level.

Grumpy_Mike

Quote
The noise is there even when this circuit is not connected
Yes it will be, that is because the input is floating, it is when you connect that circuit that the noise will stop, that is when you have connected the capacitor on the input to nothing. That is why I said you have not connected that circuit correctly.

The only difference between a microphone input amplifier and a line input amplifier is the gain, which you can work out from the ratio of the feedback resistor to the input resistor.

Feed the output of the FFT not to the serial monitor but the serial plotted to get a feel of what output you are getting.

Go Up