0
\$\begingroup\$

I have a sound sensor which I want to connect to a RaspberryPi.

RaspberryPi input voltage on GPIO is 3.3V and this sound sensor output gives 5V.

I've made voltage divider that looks like this:

enter image description here

It works fine when I connect it with power supply. It gaves me ~3.1V on V out.

However when I connect it to sound sensor it does not give me the expected voltage.

My circuit looks like this:

enter image description here

Output voltage is ~2V and voltage between sensor output and resistor R4 is ~3.3V.

I've also noticed that the small diodeon sensor (which lights when sound is detected) lights a bit when circuit is connected that way.

What might be causing this problem? Should I add a diode between R4 and sensor output? Will this solve the problem?


This is the circuit of the sound sensor:

enter image description here

\$\endgroup\$
6
  • 1
    \$\begingroup\$ @JRE I am unsure if you adding the schematic into the question is too helpful. As shown in my answer, once you look at the schematic, the reason for the 'incorrect' voltage is clear, so adding the schematic voids the question a bit I would think. \$\endgroup\$
    – MCG
    May 3, 2019 at 11:42
  • \$\begingroup\$ There are 10k pullup on the board since LM393 has open collector output. Furthermore, there are also LED in series with 470 ohm resistor. Two options: 1. Desolder the LED, short the R3 in your design. And then, since the output will be paralleled with the internal output bjt. You need to adjust R4 accordingly until you have 3.3V on the output. 2. Use an output buffer. \$\endgroup\$
    – Unknown123
    May 3, 2019 at 11:47
  • 2
    \$\begingroup\$ I don't think it voids the question. It is quite possible to look at a diagram and not understand why it causes you a problem. \$\endgroup\$
    – JRE
    May 3, 2019 at 11:50
  • \$\begingroup\$ Related: How to get audio from a sensor for an Arduino \$\endgroup\$
    – Unknown123
    May 3, 2019 at 11:53
  • \$\begingroup\$ @JRE fair point! \$\endgroup\$
    – MCG
    May 3, 2019 at 12:28

4 Answers 4

2
\$\begingroup\$

The LM393 is a comparator with open collector outputs.

So, based on your measurement your sensor output circuit will look like this:

schematic

simulate this circuit – Schematic created using CircuitLab

And this is why you are getting 2V at the output.

schematic

simulate this circuit

Have you tried to supply your sound sensor from the 3.3V rail? There is a chance it will work.

Also, this 2V at the output will be interpreted by a RaspberryPi as a high state. So no problem either.

\$\endgroup\$
1
  • \$\begingroup\$ Fortunately simplest solution worked. Connecting sensor to 3.3V gives the same output which is safe for RaspberryPi \$\endgroup\$
    – nervosol
    May 3, 2019 at 12:01
2
\$\begingroup\$

You can find the schematic for the module by clicking the download in the link you supplied. It looks like this:

enter image description here

It looks like when the threshold is reached, your output will go LOW, which enables the LED to turn on. When there is no noise, the output is high, and LED is off.

With a 10k pullup, you are not going to get the correct voltage on your divider. It may be better to use a MOSFET or transistor as a switch.

Moral of the story is always find a schematic if you are working with a breakout board.

\$\endgroup\$
1
  • \$\begingroup\$ Yes you are right. The output with no sound is HIGH. \$\endgroup\$
    – nervosol
    May 3, 2019 at 11:46
1
\$\begingroup\$

If you track down the circuit on the seller's site, you will see that it already has a resistor between the 5V supply and the output.

There's a 10k resistor on the board, and you have another 6k on your voltage divider. What have therefore is a voltage divider of 16k to 10k.

That ratio delivers 1.92V at the output. Almost exactly your measured value.


The circuit diagram also explains why the LED lights up (weakly.)

The lower resistor of your divider provides a path to ground for the LED. It is 10k, so not much current flows - but it is enough.


The simplest solution is to use a diode instead of a voltage divider.

Put a pullup on the GPIO pin on the Pi, and connect it to the sound sensor with a diode. Cathode (banded end) towards the sound sensor.

The Pi has a proper high input when there's no sound.

No current flows through the LED when it's quiet.

When there's a noise, the sound sensor pulls the output low and the Pi "sees" that through the diode - it has a proper low signal when sound is detected. And, the LED will light up correctly.

\$\endgroup\$
0
\$\begingroup\$

You should measure the resistance between Vout and Gnd on the module to see if there is a pull down present. If so, you will have to recalculate your voltage divider. Furthermore, a voltage divider is usually only a good idea to use with high impedance IO since any for of parallel resistive load will screw with your ratio. It's better to use a transistor in your case.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.