Go Down

Topic: peizo knock Example (Read 3615 times) previous topic - next topic


Arduino UNO Board:
I have actually progressed from the blink example.  I have  read  everything I can find, and look at so many items in the forum , but cant find anything  on the knock example.
I think I have followed what  directions I have found,  but  I  am unable to get it to work.
If kind person that has progressed  through this area might be able to enlighten me, I would be appreciative. 


but  I  am unable to get it to work.

You'll need to explain what that means... what's happening that should not happen, what's not happening that should?

Is your sketch compiling but not working properly, or not compiling in the first place... if it's not compiling what are the compile messages?

Post your code and a schematic... not the code and schematic as suggested in the tutorial, but the code you typed in and the schematic as built.


Please modify the Subject in your first post. Peizo -> Piezo

About your question, http://lmgtfy.com/?q=arduino+piezo+knock


Reply to Jimbo
1) what's happening that should not happen, [ Nothing, seems fine ]
2) what's not happening that should?  [ It is suppose to activate the LED and place a notice on the monitor The peizo does not work the program ]
3) Sketch is loading, compiling OK & from what I know it appears to be working OK  There are no error messages in the box.
The TX TR led's flash on loading as well as the led.

4) The code I have used & loaded is the code in;  File/ examples/ Sensors/ Knock

Arduino has assigned COM3
I have connected the board as per Image


Hey Rod... nope, not working for me either. I even changed the threshold value to 10 and then to 5, still nothing.

Maybe piezos of different make and model, would require a different resistor.... I wouldn't know.

For the record, mine is a HCM1206UX-G, and I just tested it as a buzzer with 9V in and it works that way round.

BUT....I set the threshold to 0, which would make the line if (sensorReading >= threshold)  activate every time, since >= includes 0, and it actually works.

So I'm guessing it's a piezo sensitivity thing.



Some piezo buzzers have circuits in them to make them "buzz" when voltage is applied (they're "self oscillating"). That's what yours is, JimboZA, and those (apparently) don't work as knock sensors.


those (apparently) don't work as knock sensors.


So, next question then, is how does one specify to the shop that one wants one as a sensor not as a buzzer? (Hmmmm, probably answered my own question there  ;) )


JIM,  Thanks for putting in the time & effort to do that,

I have it working of sorts.  Nothing like the sensitivity I want, but working.
Look at this for sensitivity:   https://www.youtube.com/embed/8ZVFKvgJQtA?feature=player_detailpage

I have changed
1) const int threshold =1;  // threshold value to decide when the detected sound is a knock or not
2) int sensorReading = 1.2;      // variable to store the value read from the sensor pin
3) delay(2);  // delay to avoid overloading the serial port buffer

I also read somewhere that if you increase the size of resister, it will increase sensitivity,  any body know anything about that?


I'm afraid this circuit screams for an op-amp.  Allot of those piezo buzzers are very narrow banded, but they all pretty much should be able to "hear" something; it just might be extremely weak signal especially the further it is from the centre frequency of the piezo element. I've used one of the cheap rad shack ones that look like the picture for listening to a ticking watch, but it took an op-amp and a comparator to clean it up enough for a micro to really process.  That video with the ants is certainly using large amounts of amplification to get that kind of sensitivity.
Experience, it's what you get when you were expecting something else.


Rod your 2) and 3) won't make any difference... in 2) that just sets the initial value, which gets overridden first time thru the loop, and 3) is just how fast it goes thru the program.

Regarding the resistor, well I'm going to try that now with a bunch of 1M resistors in series and see what happens


I also read somewhere that if you increase the size of resister, it will increase sensitivity,  any body know anything about that?

I'm pretty sure that the resistor is there to bleed off any DC that might try to build up between the sensor and the high impedance input pin.  A bigger resistor will still do that function, but lengthen the time constant allowing for higher signal peaks I think.  The extra amplification benefits will probably taper off fast as the value is increased.
Experience, it's what you get when you were expecting something else.


I thank all who have commented, it all helps me. It helps in joining the Dots
You can probably see by my comments, I am mentally challenged when it comes to Electronics, and forums also for that matter.

I just tried another 1K resistor   and it DID improve the sensitivity.
My objective with my Arduino Knock is to make an peizo digitizing sensor for my DIY cnc  machine. 
I have been experimenting with mechanical digitizing probes, but with the vast amount of make & break contacts,  the points give out at about 30 - 40,000.

So I saw this fellows idea,  but I cant contact him.  I wish I could,  I can probe and  produce Gcode  no problem, we could help each other.
So it's trial and error,  and with the the help from others I hope to finally have some success.


For cleaning up the signal, try


Mar 09, 2013, 10:34 am Last Edit: Mar 09, 2013, 11:11 am by JimboZA Reason: 1
I did a bit of experimenting with thresholds and resistances, didn't seem to make any difference and I stopped when my eyes glazed over.

Maybe my piezo is indeed configured to buzz only, not sense.

Oh, and on the subject of buzzing, here's a big BZZZZZZZZZZZZZZZZZZZZZZZZZZTTTTTTTT to Erdin (representing the Spelling Police) for this unnecessary pedantry:

Please modify the Subject in your first post. Peizo -> Piezo



Mar 09, 2013, 11:03 am Last Edit: Mar 09, 2013, 11:05 am by Erdin Reason: 1


I was thinking that if someone searches the forum for "piezo", this thread would not be found. But also the text of the posts is searched. So it isn't a problem.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131