How to Read Speaker values from some device to use as if function

hi im making a project that uses the audio coming from a device as a trigger
can some one pls tell me how to read the values and use it as if function

Welcome to the forum

Are you looking to detect whether or not there is an audio input (ie binary) or do you need to measure the level of the input (ie analogue) ?

So that we can help you, post your code correctly.
To post code click the <CODE/> button on the toolbar.

Hi @malharja123,

welcome to the arduino-forum.

In electronics and in programming you have to provide detailed information.

Just as a thought-experimemnt:
If you would connect a headphone directly to car-battery all that would happen is the speaker-coils would be destroyed. The reason is: the voltage of the car-battery does not match to what a head-phone can stand.

Same thing with a microcontroller that is used to read in an audio-signal.
This is doable but you have to describe in detail what kind of device is delivering the audio-signal?
You have to describe the exact type of microcontroller that you are using.

  • if the device is a microphone the signal is so weak that it needs to be amplified HIGH before a microcontroller can detect it

  • if the device is a mp3-player the audio-signal needs to be amplified low before a microcontroller can detect it

  • if the device is a doorbell it highly depends on what kind of doorbell this is what to do with the signal

  • if the device is an amplifier itself the signal needs to be weakened to not destroy the microcontroller.

From your words

I can conclude that you are a real beginner about programming.
This is completely OK. Everybody here started as a real beginner.

so please

I'm pretty sure that you agree and will follow the way how to solve your problem mimimum 200 minutes faster.
This requires to invest 20 minutes of your precious time to read how to speedup solving your problems.

Directly after registering you got presented informations how to speed up solving your problem.
You should really read it.

best regards Stefan

1 Like

That should not be to hard, only one minor problem what type of signal is it and what does the signal look like? Without the asked for information the best you will get is an uninformed guess.

so its actually an electric doorbell and when some one come they press the bell button on that system and then it just play sound and it send notification on my phone so i opened that smart doorbell and get the speaker with two wires now how do i use the sound and attach those two wires and use it as if function like if the sound plays my relay should tern on

Is the bell button wired to the sound system or is it wireless ?

it is wired

should i send a video

Then you could probably detect the press of the button rather than the noise from the speaker

What is the voltage across the 2 wires to the button when it is open and when it is closed ?

1 Like

Audio is AC (it goes positive and negative) and the voltage to the speaker is unknown. The Arduino can be damaged by negative voltages or voltages greater than +5V.

So, you'll need a Protection Circuit.

Then you can run the output of the protection circuit into an analog input. You need a common ground so try to figure-out which speaker connection is ground. There may not be an actual ground, but you still need a "reference" connection for the Arduino, and neither side is actually grounded it can be wired either way.

Run the Analog Read Serial Example to see what kind of readings you're getting and you can use that information to set a threshold in your code.

If you are getting readings near zero (with no sound) and readings near 1023 with sound, you can use a digital connection.

If the readings float randomly with no sound you'll need a "pull-down" resistor between the Arduino analog input and the Arduino ground. The resistor value isn't critical but it should be at least 10 times higher than the current-limiting resistor in the protection circuit. You can also increase the current-limiting resistor up-to around 10K.

...It probably would be better to detect the button-push, but you might need to know something about the circuit.

it is a touch button

i will measure it

How many wires are there from the button to the sound unit ?

As a general remark:

as soon as you leave the super-standardised world of USB and bluetooth,
you have to take care of a lot more details than just

"does the plug fit int the socket?"

A lot of things are possible if the right components are put together.

At the place where the doorbell is mounted, is this environment always rather silent
or
can there occur really loud voices or loud noise?

if the environment is always rather silent it might be possible to use a microphone-sensor with adjustable threshold at what level of sound the sensor shall switch his signal.
When using a microphone sensor you must be aware that all kind of noise if just loud enough will trigger the microphone-sensor.

If you can place the microphone very close to the doorbell it might work reliably.

i dont know im just allowed to do things with speaker

i tried that it sense the noise and the doorbell speaker plays different sound so i just want the sound of bell

bcoz the bell button is also used for conforming the password
so if we conform the password it will ring the bell

@malharja123

we are at post # 18. If you keep this style of communication to post only one or two sentences. It will take you another 180 postings to get your project working.

The more precise you describe the details of your project the faster you will have finished your project.

You have chosen a picture of Nicola Tesla as your avatar.
I quogeled the question:
What was Nikola Tesla's personality?

the answer is:
People who met Tesla, claimed that he was polite and hard working, spending only few hours a day for sleep. Most of his time he spent working on his inventions. He was an introverted person and would spend days without talking to anyone.

Well you have chosen to ask the forum for help. So it seems that you don't want to work just on your own to realise this project. If you want effective help you should really read this

I'm pretty sure that you agree and will follow the way how to solve your problem mimimum 200 minutes faster.
This requires to invest 20 minutes of your precious time to read how to speedup solving your problems.

Directly after registering you got presented informations how to speed up solving your problem.
You should really read it.

best regards Stefan

what does this exactly mean?

Is this device you call "doorbell" not only a doorbell but makes sounds that have a DIFFERENT meaning then "doorbell"?

If this is the case. A very different and a much more complex electronic will be nescessary to distinguish between "doorbell" sound and the other sounds.

So this demontrates in your case like in 99.9999% alll other cases too that it is a MUST to know the details of your application / your project.

It might well be that english is not your motherlanguage. If this is the case
write down a detailed descritpion in your motherlanguage and use google-translate to translate it.

A poor 10 words english sentence has much less information than a 100 word google-translated description where maybe 4 or 5 words sound "weird" but are still understandable.

So what is your choice:

A: needing 10 weeks to get your project done by 100 two sentence-postings ?

B: needing only 1 week to get your project done by 10 postings with each posting having 20 google-translated sentences ?