-1

I use Waveshare's Sound Sensor module.

I use this simple code to test the module:

enter image description here

enter image description here

As you can see, the problem is that when I have a delay in the program, once the analogRead is bigger than 10 (by slightly knocking the mic with my finger), "sound" is printed, but sound sensor's output doesn't decrease back to normal values and "sound" keeps repeating. If I don't use delay, everything works fine, but I need that delay.

*NOTE: on this test I use a STM32 nucleo development board, but I don't think that contributes to the problem.

  • 1
    What is a "Waveshare's Sound Sensor module"? We aren't psychic. No links, no answer. – Majenko Oct 16 at 22:49
  • please print the actual values ... do not use a graph – jsotola Oct 16 at 22:58
  • I uploaded monitor's prints – BrainTrance Oct 16 at 23:35
  • Is this your mystery device? If so, how are you wiring it? Are you trying to read the AOUT or DOUT pin? – Majenko Oct 16 at 23:50
  • Majenko no need for superpowers. You only need 5 seconds to google it and find all the infos in the first link that appears. If spending 5 seconds is too much time feel free to dismiss the question and save your time – BrainTrance Oct 16 at 23:53
1

The AOUT pin of that device is no more than an amplified audio signal. It is AC coupled, and that means that it is a small signal varying around 0v. It is not suitable for feeding directly into an ADC.

The AC coupling capacitor will be being charged up by the DC offset it is there to remove, and the lack of any drain on that capacitor while the ADC is not sampling means it never discharges as it should. By sampling faster you increase the load and thus it can discharge somewhat.

To properly read that AOUT pin you need to add your own DC offset to half the VCC voltage of your Arduino board, which can be done by adding two 10k resistors. One from VCC (5v) to the analogue input, and the other from the analogue input to ground.

The signal you read will then be "idle" at around 2.5v (512 ADC reading) and vary around that as sound is picked up.

Note that you can't just sample once per second and hope: there is no provision for "did sound happen in the past second". Instead you really need to be sampling all the time.

If all you care about is if some sound above a threshold has happened then you would be better using DOUT connected to a digital input or even an interrupt pin, and using the threshold setting trim pot on the board.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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