Page 1 of 1

Sensing sound from a speaker

Posted: Thu Jan 10, 2019 8:25 pm
by andydj
MicroPython newb here. Know python, arduino, some basic electronics, now venturing into MicroPython Land. Everybody's got to start somewhere, right?

I recently bought a D1 Mini clone, with a view to using the wifi capabilities. What I want to do is detect whether my doorbell is ringing, and if so senda udp packet to my laptop over the wifi - I can handle the socket programming bit, it's the other bit I'm struggling with. The doorbell is one of those cheap wireless ones, and it plays cheesy tunes when someone presses the button. I'd like to somehow attach the D1 Mini to the doorbell speaker (I'm thinking maybe to the A0 pin) and poll that, then send the udp packet if the signal is over a threshold value.

I haven't taken it apart yet, but I'm hoping I can simply solder some leads onto the back of the speaker, back to the D1, maybe with a current limiting resistor to keep it in range. Can anyone point me in the right direction?

Thanks in advance.

Re: Sensing sound from a speaker

Posted: Thu Jan 10, 2019 8:37 pm
by Roberthh
Without knowing the kind and level of signal at the speaker it is hard to give any advice. If that door bell has also a LED which lights up at the same time, interfacing is much easier. But still level & polarity must be known.

Re: Sensing sound from a speaker

Posted: Thu Jan 10, 2019 8:52 pm
by ThomasChr
First you should try to examine the signal. An oscilloscope would be needed for that. Also Tones are no simple DC Voltage. It‘s AC. So depending on the moment of measuring you can get 5V, 0V or maybe -5V. As an alternative you can get simple chinese mikrophone moduls. They have an A0 analog AC Output but also a digital D0 Output which gives a clean High when the loudness is above a configurable Threshold.

Re: Sensing sound from a speaker

Posted: Fri Jan 11, 2019 5:16 am
by kevinkk525
I connected my esp directly to the doorbell signal going into the doorbell device using a transistor. Our system is however very old.
Works good though using a pin interrupt and debounce.
Depending on the signal your doorbell device receives, this might be an option too.

Re: Sensing sound from a speaker

Posted: Fri Jan 11, 2019 9:46 pm
by andydj
Thanks, all. Some useful points. It doesn't have an LED, but I've now opened it up to have a look, and it DOES have 2 unused pads on the PCB, one of which connects has a small SMD resistor on it, and the other is on the ground plane. Looked to me like it was intended for an LED option, especially since it's marked "LEDGND"... so I grabbed one out of my Arduino box, and held it in place while I pushed the bell button, and lo and behold, it flashed!

OK, so I think that is the route I'm going to go down then.

Re: Sensing sound from a speaker

Posted: Sat Jan 12, 2019 8:52 am
by ThomasChr
Great news! Sensing a LED is childs play :-)

Re: Sensing sound from a speaker

Posted: Mon Jan 14, 2019 11:50 am
by nekomatic
You could connect the LED side of an optocoupler like a 4N35 to those pads on the doorbell, then you have an electrically isolated open-collector output that's easy to interface to a pin on the ESP side. Or if isolation isn't important you can just connect a suitable resistor across them and detect the voltage level.

Re: Sensing sound from a speaker

Posted: Mon Jan 14, 2019 9:57 pm
by andydj
I thought I'd put in an update: I got it working. Thanks for the hints!

The voltage on the LED pads read as about 1.8 volts, and this was confirmed by looking at it with the oscilloscope at my makerspace. So, being aware of the 1 volt upper limit on the ADC, I had to look at how to make a voltage divider, and breadboarded that, with some wires soldered to the LED pads. After checking with the meter that I was getting low enough voltages, I then attached it to the ESP8266, and wrote a loop to read A0, and sure enough, I was getting zeroes until the doorbell chimed, at which point I saw a few pulses at about "120" from the ADC, in sympathy with the blinks on the LED.

I've now soldered my two resistors for the voltage divider to the LED pads and splashed the extension wire onto that to connect to the ESP8266, and confirmed it's working.

Tonight, I wrote up a little python UDP socket server, and a micropython, adapted, adapted from here: ... er-example (though there are loads of examples round - I just chose the first one I found, as I know the score and just needed a bit of a hint). Took a few iterations, but I have a rudimentary version working of both now. Happy to post the code if anyone's interested (it's not rocket science).

Re: Sensing sound from a speaker

Posted: Tue Jan 15, 2019 5:50 am
by ThomasChr
Just a hint: Many of those cheap NodeMCU ESP8266 Boards have the voltage divider already built in.

Glad to hear that it works :-)


Re: Sensing sound from a speaker

Posted: Thu Jan 24, 2019 4:06 am
by mcauser
Sensing sound from a speaker -> Sensing RF from a doorbell transmitter

Your doorbell button is most likely a cheap ASK/OOK transmitter, operating on either 315 or 433.92 MHz.

I recently made an ESP8266 based project which listens for RF packets emitted from my doorbell and urequest posts them to a Slack channel.
Rather than physically attaching to the existing doorbell receiver and trying to figure out if it received the RF packet and chimed, I just made a 2nd receiver which grabs the radio signal too.

Starting with a RTL-SDR dongle, I sniffed the signal coming out of my remote and found it to be a 12-bit long sequence, repeating 10 times, on 433.92 MHz. Universal Radio Hacker is the tool for capturing and analysing the signal. Converting the analog waveform into 1s and 0s. Once you know the pattern, all you need is a cheap ASK/OOK receiver module with it's data pin hooked up to a free GPIO pin, then just add an interrupt on the pin and count the times between when it goes high/low until you see your signal repeating.