Reading volume level from AdaFruit SoundFX

Hi everyone, I've spend the last few days pouring over the great information in all these threads, but haven't been able to solve my problem.

Project: Read the audio volume LEVEL from an Adafruit SoundFX board, and then in work some servos depending upon the LOUDNESS. (I'm actually building an animatronic Teddy Bear and will be moving the mouth based on whether there is volume (talking) or not. The arduino is trigger the soundFX and that is working all well.)

So far: I have the grounds of the AdaFruit SoundFX and the Uno R3 wired together. A bias circuit shows a constant reading of 509. The SoundFX is triggering and playing sound fine.

What's wrong: When I trigger the sound I am only getting a change of 1-2 in the analogpin read. Is this due to the low mv output of the soundfx? I am just worried there won't be enough fidelity.

Any thoughts?

Links: Adafruit SoundFX Adafruit Audio FX Sound Board - WAV/OGG Trigger with 16MB Flash : ID 2220 : $24.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Bias Circuit I am using:

Since the output is 1 volt p-p, and already AC, you do not need R1 or C. R2 needs to raise pin A0 to 0.5 volts so the negative peaks are at zero. Rework the values for the voltage divider so the bottom resistor gives 0.5 volts to pin A0.

1 Like

You need to have a peak detector sometimes known as an envelope detector circuit before the Analogue input to your Arduino. You do not want to read audio here but just the peak positive value.

Thanks all for the reply. As I build the circuits I am trying to improve my basic understanding of electronics - I read through the envelope detector circuit links (thanks @Grumpy_Mike ), and this seems exactly what I need. As @Paul_KD7HB replied, the SoundBoard is 1v PP (from the data sheet "The outputs are 'live level' (about 1Vpp) and have DC blocking capacitors so it can be connected to any kind of amplifier.")

I understand I need to build this circuit:

  1. How do I calculate the values needed for the resister and cap, given the 1Vpp, and going into a 5V Arduino Uno. I've looked through a few links and can't figure how to do the calculations.

  2. Also would a 1N4148 work for the diode (or can you recommend a better one).

Really appreciate the help here all.

Phil

No, that will not give you a volume level. It will give you a DC level of approximately 1/2 the p-p value, but understand the + peaks of your sound are not the same as the - peak voltage. It takes both parts of the sound waves to make a volume level. That is why you bias the input so you can measure both the + peak and the - peak of each sound wave. Sound is NOT symmetrical, except for some stringed instruments.

1 Like

But if the input to that circuit is connected via a capacitor then it will give the peak reading. That capacitor might already be there as it was in your initial circuit you don't need another. You don't need the pull up and pull down biasing resistors.

Experiment with the values until you get a good effect the capacitor controls how quickly the circuit reaches a peak, start with a 0.1 uF. The bigger it is the slower it takes to reach a new peak.
The resistor controls how quickly the envelop decays, start with a 10K.

Any diode will work but a better diode is
Schottky Diode
It has less of a forward voltage drop than a conventional silicon rectified or signal diode.

If you knew what shape of envelope you wanted you could calculate these values. But as you don't know what works well for your servos and animatronics so that is why no professional engineer would ever dream of calculating these values. It has to be trial and error as to what works wel, for your unique setup.

If you want to get a bigger signal then you could apply a times 5 gain with an operational amplifier before the diode. But it needs to be a rail to rail amplifier or one that is close to rail to rail.

1 Like

Hey all, my diodes haven't arrived to try the envelope detector, so I have tried this and it seems to be working as desired:

This set's the voltage at 2.5, and I have coded the project to read the positive and negative peaks. Seems to work fine, and I am getting a good spread of ADC read values (+ or minus ~30max), and able to work the servos in response.

I am trying to improve my understanding of electronics, and wondering what purpose the 1uf capacitor serves - is this to smooth the signal?

This has been a fun project and I super appreciate all the advice.

It removes any DC component of the audio signal and is probably redundant as the headphone connection will already have a capacitor. Headphones won't work well with a steady DC current going through them.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.