Page 1 of 1

LM393 Sound Detection Sensor Module and ESPEasy as a switch

Posted: 08 Mar 2019, 20:36
by Teknor
Hi all - I have a NodeMCU running ESPEasy with a few sensors.

One of them is a LM393 Sound Detection Sensor Module.
Image

How do I configure this in ESPEasy to send one switch "on" when there is noise triggering the "switch"? I have tried a few alternatives, but ESPEasy dont put the switch back to "0" when silence.

All tips and help are much appreciated.

Pic01.png
Pic01.png (98.26 KiB) Viewed 9805 times

Re: LM393 Sound Detection Sensor Module and ESPEasy as a switch

Posted: 08 Mar 2019, 23:29
by Shardan
Due to the data sheet of the LM393 it's a comparator with open collector output.

So it should be easy to connect to an ESP-Chip.

Connect the output of the FC-04 to a GPIO, for example GPIO 13.
Connect a resistor of about 10 KOhm from the connected GPIO to +3.3V.
The FC-04 should work with 3.3V or 5V. I'd prefer 3.3V in this case.
So conenct the Vcc of the FC-04 to 3.3V and GND to GND.

Configure a switch in ESPeasy to the used GPIO.

the trimmer at the FC-04 board sets sensivity. Turn up until the switch changes to "1",
then turn back until switch just hops back to "0".

Noise can be eliminated even with the trimmer too, by making it less sensitive.
If the noise level is nearly same as the sound that should trigger the switch, it will be very difficult to
get this to work. It is not a problem of ESPeasy, but a problem of the microphone.
There's a reason why modern smartphones or voicecontrols use microphone arrays of
four to eight microphones and digital signal processing.....

Re: LM393 Sound Detection Sensor Module and ESPEasy as a switch

Posted: 10 Mar 2019, 11:41
by RobertM
Shardan wrote: 08 Mar 2019, 23:29 Connect a resistor of about 10 KOhm from the connected GPIO to +3.3V.
Why not simply click "internal PullUp" ;)

Re: LM393 Sound Detection Sensor Module and ESPEasy as a switch

Posted: 10 Mar 2019, 17:27
by Shardan
RobertM wrote: 10 Mar 2019, 11:41
Shardan wrote: 08 Mar 2019, 23:29 Connect a resistor of about 10 KOhm from the connected GPIO to +3.3V.
Why not simply click "internal PullUp" ;)
The internal pullup is a so called "weak pullup" with a high impedance.
The LM393 has a significant leak current on "high" state (see datasheet), the more
as on some of these modules a LED is connected to the output.
Due to my experience in many cases using an external pullup works more reliable.

Re: LM393 Sound Detection Sensor Module and ESPEasy as a switch

Posted: 10 Mar 2019, 20:06
by Teknor
Thanks for great support.

I have hooked the sensor up to the nodeMCU and it triggers the switch. However, when I clap (once) the switch turns on. And stays on... Until next time I clap. Then it turns off.
Clap first: 79882796: SW : GPIO=12 State=1 Output value=1
Clap again: 79885596: SW : GPIO=12 State=1 Output value=0

Is it a function to configure this to Output value=1 when noice and then back to 0 after a few seconds? Like a PIR sensor?
pic2.png
pic2.png (51.02 KiB) Viewed 9755 times

Re: LM393 Sound Detection Sensor Module and ESPEasy as a switch

Posted: 10 Mar 2019, 23:42
by ThomasB
However, when I clap (once) the switch turns on. And stays on... Until next time I clap. Then it turns off.
Change the Switch Button Type to "Normal Switch."

Edit: Be aware that the sound sensor's output goes logic-low only during the noise event and immediately returns to logic-high. So if you intend to see the Device's state change in the web browser then the noise would need to have a constant uninterrupted duration of several seconds. As a workaround you can use the system Web Log to see when a brief noise was detected.

Also, I found a schematic. There's already a 10K ohm pull-up on the sound board, so no need to add another. It is OK to use the Switch plugin's Internal Pullup function too.
http://www.mpja.com/download/31072mp.pdf

- Thomas