Go Down

Topic: Recognize certain sound pattern / compare sound [SOLVED] (Read 4474 times) previous topic - next topic

USAfirefighter

Jun 22, 2016, 07:08 pm Last Edit: Jun 23, 2016, 09:38 pm by USAfirefighter
Hey Guys!

In case of a fire I want the Arduino recognize the smoke alarm sound and send me a text message.
I tried several things but its pretty hard to do so.
The smoke alarm goes like "----____----____----____________----____----____----____________"
(beep 500ms, break 500ms, beep 500ms, break 500ms, beep 500ms, break 1500ms)
I got my code like this:
if(beep) then delay(500) if(!beep)then delay(500) if(beep) then fire=true;
but that doesnt works 100%. It may take from a few seconds up to a minute until the Arduino gets it.

Do you think there is any better solution?

Thankful for any idea!


DVDdoug

I assume you have a "microphone board" or something to pick-up the sound?

Quote
if(beep) then delay(500) if(!beep)then delay(500) if(beep) then fire=true;
but that doesnt works 100%. It may take from a few seconds up to a minute until the Arduino gets it.
A couple of problems...   That's not going to do anything unless "beep" is defined somewhere.

You don't want any delays,* because the program pauses during the delay and it can't do anything.  Imagine you were using a stopwatch, you wouldn't pause/stop the stopwatch when you're trying to measure the time.

You need run the processor continuously and measure the duration of the beep (and the duration of the silence).

Start by simply doing that...   First, make sure you can detect the beep...  Maybe turn the LED on when you sense the beep.   Then save the millis() time when the beep starts, and save the millis() time when the beep stops.   Subtract to find the time.

Then, you can work on the main logic for your code (if-statements, etc.).      

Be sure to give yourself some tolerance.   It may not be exactly 500mS so maybe look for a duration of 450-550mS, etc.




* delay() is used rarely in real-world programs except occasionally for very-short delays or when you are sure it's OK for the processing to pause.

Magician

Here is similar project:
http://www.instructables.com/id/Secret-Knock-Detecting-Door-Lock/

May be you can use a piezo as a sensor, and completely replicate a project?

tmd3

A typical US smoke alarm beeps for two reasons:  it's detected smoke, and its battery is failing.  When the battery starts to fail, the alarm emits very short beeps with a fairly long delay between them.  

These detectors don't have a mode in which they beep in some other pattern, for some sizeable fraction of the time, to tell you about something other than smoke.  I don't think there's any necessity to check for a specific beep pattern - only that there's plenty of beeping.

If this is how your detector behaves, I'd suggest looking for a period in which beeping persists more than some reasonable percentage of the time, or something like that.  If it's beeping very much, then it's in alarm.

USAfirefighter

A typical US smoke alarm beeps for two reasons:  it's detected smoke, and its battery is failing.  When the battery starts to fail, the alarm emits very short beeps with a fairly long delay between them. 

These detectors don't have a mode in which they beep in some other pattern, for some sizeable fraction of the time, to tell you about something other than smoke.  I don't think there's any necessity to check for a specific beep pattern - only that there's plenty of beeping.

If this is how your detector behaves, I'd suggest looking for a period in which beeping persists more than some reasonable percentage of the time, or something like that.  If it's beeping very much, then it's in alarm.
You are missing the fact that there may be other sounds in the environment, e.g. a microwave. So i think it is important to compare a pattern unless you want some false alarms. And the standard for smoke alarms is the code 3 tone. Thank you for your answer!

USAfirefighter

I assume you have a "microphone board" or something to pick-up the sound?
A couple of problems...   That's not going to do anything unless "beep" is defined somewhere.

You don't want any delays,* because the program pauses during the delay and it can't do anything.  Imagine you were using a stopwatch, you wouldn't pause/stop the stopwatch when you're trying to measure the time.

You need run the processor continuously and measure the duration of the beep (and the duration of the silence).

Start by simply doing that...   First, make sure you can detect the beep...  Maybe turn the LED on when you sense the beep.   Then save the millis() time when the beep starts, and save the millis() time when the beep stops.   Subtract to find the time.

Then, you can work on the main logic for your code (if-statements, etc.).     

Be sure to give yourself some tolerance.   It may not be exactly 500mS so maybe look for a duration of 450-550mS, etc.




* delay() is used rarely in real-world programs except occasionally for very-short delays or when you are sure it's OK for the processing to pause.
Thank you for your idea! But i got my code working reliably. I know delay stops the whole script but it's not necessary to keep the script running for this project.

USAfirefighter

Here is similar project:
http://www.instructables.com/id/Secret-Knock-Detecting-Door-Lock/

May be you can use a piezo as a sensor, and completely replicate a project?
Hey thank you for your idea! I also found this project previously and you're right, it is quite similar. But i got my code working now.

ALiu

Hello... can you send me your fixed code, please? I want to do something similar except it has multiple properties (it's for deaf people)

Go Up