Having trouble reading low/high from this sound sensor

Thread Starter

zirconx

Joined Mar 10, 2010
171
When using sound as a control signal (I.e. a digital output), there is additional processing beyond mere detection required.

Just detecting sound levels alone will oscillate. Plus, you have the issue of background noise.
The board has a sensitivity adjustment. The water flowing though the pipe, right next to the mic (touching it) should appear as very strong signal. Think about having your ear to a water pipe. It's loud. So I should be able to turn the sensitivity way down, and have it only trigger when water is running. I can deal with the oscillating triggering in software.

....
You’re reading this with an Arduinos, right?

Don’t use digitalRead(). Use analogRead() with an analog pin. Then, in your sketch, you can subtract the 3.3V or just ignore anything below 3.3V. Then, I’d take several measurements (with a slight delay) and average the results. This rolling average will produce a number at which sound is continuously detected.
No, I'm reading it with a Pine64, which is similar to a Raspberry Pi - no analog inputs.

I'm going order an oscilloscope in a next few days. Then I'll be able to see what the signal output actually looks like when there is sound. I'm trying to find a used one. Most people want way too much money for older equipment. I might end up ordering a Rigol DS1054Z in that case.
 

spinnaker

Joined Oct 29, 2009
7,830
A hint from the description

Can detect the intensity of the sound environment

so judging from the circuit it would return a voltage level. Not sure you you would be seeing ones and zeros.

But wait

Output form: digital switch output (0 and 1)

Huh? That does not make much sense. A datasheet would sure be nice.
 

djsfantasi

Joined Apr 11, 2010
9,156
Sorry, missed your comment in post #4. You don’t have an analog input. Restating the obvious, the problem is that (at least two) modules don’t go to a low enough voltage when detecting sound.

If you want to treat the symptoms, you could use another comparator to see if the signal is above or below 2.0V.
 

spinnaker

Joined Oct 29, 2009
7,830
I put together this little simulation. After seeing it I see the issue and why you might be getting a pulse train.

P.S. I am by no means a spice expert and even worse with OP amps. ;)

upload_2019-3-20_8-54-25.png




I simulated an input signal off 2000hertz. I took a real swag and figured 20mv for the mic output.

upload_2019-3-20_8-55-58.png

This is what the output looks like.

upload_2019-3-20_8-57-13.png

If you were reading this with a DMM, I can certainly see why you would be seeing 3V or so.
 

Attachments

KeithWalker

Joined Jul 10, 2017
3,063
I put together this little simulation. After seeing it I see the issue and why you might be getting a pulse train.

P.S. I am by no means a spice expert and even worse with OP amps. ;)

View attachment 172835




I simulated an input signal off 2000hertz. I took a real swag and figured 20mv for the mic output.

View attachment 172836

This is what the output looks like.

View attachment 172837

If you were reading this with a DMM, I can certainly see why you would be seeing 3V or so.
That's what I stated fifteen replies ago. The audio signal is not detected so the comparator is switched on and off by the AC waveform.
 

DbLoud120

Joined May 26, 2014
90
I recently purchased a few of these sound modules. Some of them don't work.

I took two pictures of my scope, one with 600 hz and one with sound from a cb radio.


IMG_0875.JPG IMG_0874.JPG

The potentiometer adjusts the sensitivity of the sound level.
 

Thread Starter

zirconx

Joined Mar 10, 2010
171
Yes, it's triggered intermittently during sound, as several have pointed out. I ordered an oscilloscope so I can watch it myself.

I'm handling it in code, it seems to work well.

JavaScript:
var gpio = require("gpio");

let OFF = 1
let ON = 0
var state = 0
var lastTriggered = null
var lastState = null

var sensorIn = gpio.export(75, {
           direction: gpio.DIRECTION.IN,
           ready: function() {
                   console.log('input ready')
                   setup()
                      }
});

var ledOut = gpio.export(74, {
           direction: gpio.DIRECTION.OUT,
           ready: function() {
                   console.log('led ready')
                      }
});


function setup() {
        sensorIn.on("change", handleChange);
        var checkLastTriggeredinterval = setInterval(function() {
                //console.log('checking last timestamp, its ' + lastTriggered)
               // if state of the input pin has changed in the last 2 seconds, then sound is on
                if (new Date() - lastTriggered < 2000) {
                        state = 1
                }
                else {
                        state = 0
                }
                //console.log('state is now ' + getState())
        }, 500);

        var checkStateinterval = setInterval(function() {
                var currentState = getState()
                if (lastState != null && lastState != currentState) {
                        console.log('state changed, its now ' + currentState)
                }
                ledOut.set(currentState)
                lastState = currentState
        }, 500);

}

function handleChange(val) {
        //console.log('value changed to ' + val )
        lastTriggered = new Date()
}

function getState() {
        return state
}

process.on('SIGINT', () => {
          ledOut.set(0);
          ledOut.unexport();
          sensorIn.unexport();
          process.exit()
});
 
Last edited:

Thread Starter

zirconx

Joined Mar 10, 2010
171
Well I bought a scope - a Rigol DS1054Z. :D I'm learning how to use it. And you all were right, the signal was oscillating quickly between off/on. Here are screenshots from my new scope showing me blowing on the mic for about a quarter of a second.

DS1Z_QuickPrint4.png

DS1Z_QuickPrint5.png

DS1Z_QuickPrint6.png
 

Thread Starter

zirconx

Joined Mar 10, 2010
171
Not without affecting the response time also.
Why would you need to if you have it working in the software?
SG
Just curious.

Here's what happens when I add a 22uf capacitor between +Vin and the output.

DS1Z_QuickPrint10.png

The low signal only gets down to about .5v on my DMM. Probably enough to signal a low in the SBC/microcontroller, but I haven't tried it.
 
Last edited:

sghioto

Joined Dec 31, 2017
5,380
Just for curiosity sake and if you could modify the module with the additional parts shown in the schematic.
This gives about a 100ms delay after the output goes high on pin1.
SG
EEE LM393 sound delay.PNG
 
Top