Change GPIO state using a Sound detection device

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
goldriver
Normal user
Posts: 15
Joined: 14 Jan 2018, 22:55

Change GPIO state using a Sound detection device

#1 Post by goldriver » 19 Jan 2018, 23:08

I need help in regards with the switching On/Off with a Sound device

I builded a project where I light up a LED with a On/Off button and everything works fine, I am able to turn on and off a LED (via a rule i created) with the push of the button and I see the event in the serial interface:

SW : State 0
EVENT: button#LED=0.00
ACT : gpio,12,1
SW : GPIO 12 Set to 1
SW : State 1
EVENT: button#LED=1.00
ACT : gpio,12,0
SW : GPIO 12 Set to 0


When I replace the button with a switch sound device, I am unable to get the LED turned ON, If I activate the sound probe, I can see a momentary LED flash on the sound device and I can also see a momentary flash of main the LED on the ESP but my test LED does not turn On/Off neither any event in the serial interface

My sound switch is connected to D4, GND and VIN and is configured as below:
switch.PNG
switch.PNG (44.31 KiB) Viewed 3567 times
And here is a picture of my setup:
breadboard.jpg
breadboard.jpg (76.51 KiB) Viewed 3567 times
Should I plave a resistance or anything ?

thanks for any help
Last edited by goldriver on 20 Jan 2018, 19:55, edited 1 time in total.

TD-er
Core team member
Posts: 8749
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Change GPIO state using a Sound detection device

#2 Post by TD-er » 20 Jan 2018, 14:05

I am not sure how that switch device you have is performing the switch.
Does it have a pull-up or pull-down resistor internal? Or is it connected to GND and with "1" the pin just floating?
And also how is the GPIO pin in the ESP8266 wired? (pull-up resistor?)

Those are probable causes.
So first try to find how the switch you use is wired internally.
And it looks like you power it from 5V. If the switch gives 5V on the switch when set to "1", it might be you just killed the input pin on the ESP8266.

I expect the switch will pull to GND for a "0" and has the pin floating on a "1" and then the pin must be pulled up to 3.3V via a resistor.
This can also be done in the ESP if I remember correctly.

So first try to get more info on the switch itself.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Change GPIO state using a Sound detection device

#3 Post by Shardan » 20 Jan 2018, 14:47

Another problem might be the output of the switch module.

The circuit seems to be quite simple, a microphone and a chip which defines a threshhold as far as i can see from the photos.

Usually the chip is a LM393 or similar comparator chip. Depending on the exact type of this chip it might have an "Openb Collctor"
output. Youmay try a 10 K Ohm resistor from VCC to GPIO/Output of the switch. It won't hurt if there is another comparator type
but it might help if it is an open collector type.

Anyways these soundswitches might have a disadvantage depending on the circuit: A sound is not that well defined.
The comparator might generate several pulses from something that you hear as one sound.

Sadly i don't have such a sounswitch module at hand, it would be interesting what the output looks like on an oscilloscope screen.
Regards
Shardan

Post Reply

Who is online

Users browsing this forum: No registered users and 75 guests