Pages: [1] 2   Go Down
Author Topic: Toilet Flushing Recognition  (Read 2751 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I am trying to build toilet flushing recognition system. I know it sounds stupid b/c I can just add sensor on the toilet to detect the toilet flush, but as it is my senior design, I cannot just use simple sensor to detect toilet flush...T__T  (instructor won't let me)

General idea is to add MIC (w/ Band pass filter and amp-circuit: http://www.sparkfun.com/products/9964) and connect to one of the analog input of the Arduino and compare the input sound with stored value. Output(digital) will be connect to ISD1000A or speaker to alarm the user.

I was wondering how to store the reference toilet flushing sound in the Arduino and how to compare (bit by bit) them.
« Last Edit: March 30, 2011, 03:27:54 pm by daguri87 » Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 5519
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Even if the Arduino had enough memory to store a "reference sound" (which it doesn't), expecting to be able to compare two essentially random noise sounds and be able to pick up that they match is going to be a very difficult, if not impossible (note: depending on your experience in audio processing, artificial intelligence and pattern matching algorithms).

I'm not trying to dissuade you here - I am just hoping you understand how difficult a problem this really could be.

I think the way I would approach it would be to figure out how to do it on a PC first, using sound files - I'm thinking some kind of "eigen-filtering", or perhaps a bayesian approach for the matching algorithm (probably using FFT for spectral analysis of the sounds, and storing the peaks of those as your filter?). Perhaps you could get it simplified down enough so that your filter "reference" values (plus "best fit" window percentages?) could be fit into memory on the Arduino (or perhaps external storage), then the Arduino could (perhaps) do a real-time FFT and compare the values...?

Alright - tons of "ifs" there, but hopefully you see where and how my thoughts went; hopefully this doesn't prejudice you into thinking the above is the only way. That's just how I would start to approach things (and I am probably completely wrong with the above - but then again, I really don't know for sure).

smiley
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 515
Posts: 31567
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There is not enough memory in the arduino to do this. You can only store a fraction of a second of sound.

Even if you could store the audio then a byte by byte comparison will not work. This is because the sampled waveform is never the same twice because you are not synchronising the sampling rate with the waveform. Therefore the waveform gets sampled at a different point every time and so the numbers turn out to be different every time.

You really ought to get an instructor who knows what he is doing. Ask for a different project. (or instructor)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

T__T
How long that Arduino can capture the sound signal??
not even a second?

Thanks guys.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A typical sampling rate is 40 KHz or so. That is, 40000 samples per second, where a sample is typically at least 8 bits. So you would need 40K of RAM to hold one second. This is on a processor that has around 2K of RAM. So you are going to get around 1/20 of a second. That's for the recorded sample. And to hold a "comparison" sample would double your memory requirements. Which means you could only sample 1/40 of a second.

In any case, since they are both "noise" rather than a tune the whole thing is hopeless.

However what *might* work is a simpler approach of a Mic, suitable low-pass filtering tweaked to let through the "rumble" of the flush but exclude things like doors opening (or the seat being lifted). Then you simply need to do an analog read to see if the sound level exceeds a certain threshold.

So you might have one adjustment pot (the sound threshold) and another (the frequency) and with a bit of experimenting get a fairly good result, with a minimum of parts, and a simple program.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12487
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I cannot just use simple sensor to detect toilet flush
Is the simplest solution not allways the best?

OK, some ideas to make it really complex:
<brainstorm>
- use a flow meter to count the liters/gallons - how much water is used - sustainability ==> extra points
+ add a temp sensor e.g. DS18B20 is a favorite here
+ add a gas sensor e.g. - http://www.emartee.com/product/41943/Arduino-MQ2-Gas-Sensor-Brick#
+ add an alarm
+ add a weight sensor
+ add a RTC to time "the call of nature"
+ add an ethernetshield to twitter the status
+ add an LDR to check the light
+ add a relay to shut the light off
+ add a fan
+ add a out-of-paper detection (printers used to have a separate line for that smiley
+ ....
</brainstorm>
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think cr0sh has the right idea here. A Fast Fourier transform should work pretty accurately, and give you good marks as well. smiley-wink

I think I would do this:

  • Wait for a certain sound level to occur
  • Then pause about 1/2 to 1 second, to eliminate things like banging doors, coughs, hand-claps
  • If the sound persists, capture as much as you can (eg. 1000 samples)
  • Run a FFT analysis on the capture buffer, checking if various "signature" frequencies are there
  • Check that the sound stops after approximately the correct time (eg. toilet flush ... 5 seconds?)

http://en.wikipedia.org/wiki/Fast_Fourier_transform

If it passes those tests then you have it!

Quote
... or speaker to alarm the user. ...

Don't worry, they'll be alarmed alright.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, some ideas to make it really complex:
<brainstorm>
...
</brainstorm>


And a public-address announcement:

Code:
Warning! Toilet has been flushed! Structural integrity failure in 10 seconds .. 9 .. 8 ..
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 332
Posts: 16566
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Simple, I would mount/attach a simple float switch inside the water tank. Trying to use sound recongnition using a arduino is a brain dead idea and a waste of time IMHO. In the real world one searches for simple, elegent, cost effective solutions. I guess in your instructors course, not so?

Lefty

« Last Edit: March 30, 2011, 05:07:41 pm by retrolefty » Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 5519
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Simple, I would mount/attach a simple float switch inside the water tank. Trying to use sound recongnition using a arduino is a brain dead idea and a waste of time IMHO. In the real world one searches for simple, elegent, cost effective solutions. I guess in your instructors course, not so?

Lefty



He's already stated that a simple sensor doesn't fill his instructor's requirements. I'm sure if the goal was only to detect when a toilet was flushed, a sensor on the tank or valve would be the appropriate method. I don't think that is necessarily the case.

Maybe the goal is to get the OP to think outside the box? Perhaps the goal is "can you think of a non-standard way to detect the presence of an event without using normal means"?

Which is where I was going in my solution; ie, could you get a small, low-speed, low-memory microcontroller to recognize a given sound?

Although not related - what about if you were trying to detect a gun shot? Or a bomb blast? Or a particular image piped in from a camera (maybe an extremely low-resolution camera - perhaps 32x32 pixels)?

Thinking outside the box might yield solutions to potentially hairy problems that need lower-power processors, where you can't (or don't want to) dedicate the equivalent of an entire PC (or cluster) to the problem. Perhaps that is what the goal of the project ultimately is - not necessarily limited to the domain of toilet flushing...?

smiley
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 515
Posts: 31567
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
A Fast Fourier transform should work pretty accurately,
Nick have you actually used a FFT and looked at the results, it is not as clean as the text books would have you believe. Then when you have got a spectrum extracting meaningful data out of it is anything but simple.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Glad you asked me that Mike, because I am attempting to do that right now. I'll let you know later on whether theory and practice can be made to merge at all practically. :-)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you guys for all the help.

I was also thinking about the sound pitch detection. eg. setting the threshold and alarm the user.
However, I was concerning with all those noise inside the bathroom.
Is there any known frequency range for the noise? (such as door knocking, water, cough, voice, etc)
My MIC already has band pass filter (pass band 100Hz 10KHz)

Again, Thank you so much guys
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So you might have one adjustment pot (the sound threshold) and another (the frequency) and with a bit of experimenting get a fairly good result, with a minimum of parts, and a simple program.

Hey Nick, thanks for the idea.
I know how to set up the sound threshold but how can I set up the frequency?
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This may be interesting to all: http://www.youtube.com/watch?v=IpRbdIheUlc&feature=player_embedded#at=65

Voice recognition on a wiring board.

There are links in the video info.
Logged

Pages: [1] 2   Go Up
Jump to: