My electronic drum kit's pads have the same type of piezo in an airtight cylinder. When the pad is hit, the pressure inside the cylinder increases and triggers the piezo, the "brains" then plays the sound associated with that sensor.
@@MarcdeVinck I may have missed you a bit. At the time I was trying this I was using the piezoelectric with the vibration sensor sketch and wiring. I am sorry. I didn't realize the two sketches and wiring were using different signal pins ex. Vibration sensor using pin 9 and Knock sensor using pin A0. Originally was working with vibration sensor module SW420 and wanted to try using a piezo instead to see if sensitivity would increase it didn't until I added the magnets on either side. I then decided to use the knock sketch and realized the difference in wiring and sketch's and realized it is not as effective using it as a knock sensor. Even playing with program sensitivity values didn't make much difference. Anyway I just wanted to clarify that I did make an error in my comment. Sorry.
The piezo is not programmed, it is just a "dumb"sensor, no specific electronics. You can make a capacitive touch sensor with Arduino. That would sense whenever a wire (or anything conductive) is touched. I have a video on that here - ua-cam.com/video/ZqeA1CQsAQM/v-deo.html
Why do you need resistor across Ground and A0? I thought the Piezo just generates a voltage (no more than 5v) and then the aruidno should just read it?
Hi Marc, I followed your wiring and code, but I'm having trouble with the sensitivity. As I change the sensitivity it seems to go from not being able to sense, to being oversensitive and repeating "knock!" without interruption (no new input on the sensor). What could be going on?
Can i measure the amplitude using this element? Lets say im placing multiple piezo elements on a surface and hitting a certian point. Is there a way to tell which element gave the input with the highest amplitude?
In Arduino's IDE, "Examples 02. Digital toneKeyboard" requires 3x force sensing resistors. Can I use one of those force sensing resistors for this Knock Sensor project? If not, why not? Thanks for your guidance.
That example uses a force sensing resistor (FSR). You could use it, but you would have to hit the actual sensor to get a signal, which is analog. A piezo can sense vibration from further away. They are are also less expensive. So, yes you can, but it's not ideal.
Sadly I think I need that for my car! But in all seriousness, you could grab audio waveforms of your engine running and potentially find a "knock" in the audio spectrum.
Great informative video. Hope you can help me. I have a sensitivity of 15 and tried upto 20. But output from piezo is very inconsistent. It registers a value above 20 after 3 to 4 clicks. So I can't get the toggle behavior. What's wrong?
Not sure how you are calculating sensitivity. Might want to try something more binary. Piezo generate an analog electrical signal, you could sense any voltage over 0...or close to zero.
Yes! As a fun test you can hold a through hole LED to the (+) & (-) parts of the piezo and "flick" it with your finger. You will see a difference in the LEDs brightness based on how hard you "flick" it. And you will also most likely kill the LED, so use a spare one that you don't mind burning out.
You could, bu it it would have to be hit to register a signal. If you want higher resolution you might want to consider an inexpensive accelerometer or IMU. For the resistor? The reason is to be able to filter out false positives by always having a path for the electricity to go instead of the analog pin floating when not in use.
Possibly, but it depends on the amplitude and frequency. You can also use an accelerometer for higher frequency and lower amplitude situations, but again, it depends on a lot of factors, including the sensors durability in a high stress situation.
@@MarcdeVinck thanks for your kind reply! Bt i have question regarding this,' if we use piezoelectric vibration sensor then as controller which one we should use arduino or plc..which one more impactful and why?
@@fazrulislam5053 It depends. Which Arduino? Which PIC? They run at different speeds depending on the board. Didn't use to be that way, but a lot has changed in the last 15+ years. I would choose the board that runs fast enough and you are familiar with programming.
@@fazrulislam5053 Again, depends on what you are specifically measuring. You can use board, but I would try to connect with someone locally that can get you a better answer and see your specific needs.
Would someone be able to explain to me how the sensitivity works? I think I understand but I am not 100% sure? I understand that the lower the number on the code, the higher the sensitivity. From what I can understand from the code: when I hit the piezo it generates a voltage. The arduino detects that voltage. The sensitivity changes ONLY the response of the arduino? For example, if it is closer to 0, then the arduino will displace “knock” at a lower piezo voltage (assuming 0.1) compared to being set to 300 which requires the arduino to respond to a much higher voltage (assuming 5)? So the sensitivity does nothing to the piezo itself, just the reaction of the arduino to the amount of voltage released by the piezo?
I would also like to add a little note: when only using the LED pin and ground (red wire connected directly to LED) when the sensitivity was set to 0, the piezo would click at constant intervals and when it was set to 300 the clicking would stop. This is why I asked the question, is the arduino sending a base voltage through the piezo, and does that voltage change/have anything to do with the sensitivity?
Yes, you have the basic concept correct. The piezo generates electricity (the piezo effect) when a mechanical force is applied. No power to the piezo is necessary. The sensitivity is the Arduino reacting via code to the amount of energy created by the force that is applied to the piezo.
No, it won't detect vibrations in the air. For that I would recommend something similar to a speaker. When the speaker diaphragm moves it would generate and electrical current. You could also bounce a UV led off a very flexible surface and measure the movement (or reflectance), and that could give you an idea about air movment.
@@MarcdeVinck thank you, that is actually a smart idea. I also found some sort of an intensity meter which I can use, along with some calculations, to detect the loudness of a sound in dB.
@@omarkhalaf9723 Look up Arduino Decibel Meter, there are tons of resources. Also know that a microphone measures air movement. (basically what I was explaining by using a speaker)
@@Masiyamusic You can easily do that by using a buzzer or speaker. Turn on (or play a tone) through the speaker when a knock is sensed, add a delay for as long as you want, then turn it off. It's an easy project! Good luck and have fun!
The 1 mega ohm resistor limits the travel of almost all the electricity on the pin. It makes the pin very stable, with no fluctuating voltages, and therefore very sensitive to variations you can leverage via code.
@@MarcdeVinck Already switched all components, same behavior. You think it's not soldered alright? Maybe some loose Parts? Yes, I use nearly the same build.
@@MarcdeVinck I solderd it in the first place, without jumpwire before. The soldered places look clean so far. Want to try another input. Already swapped Arduino and Piezo and Inbetriebnahme resistors, same issue :/
You can connect as many sensors as you have available pins. But be aware that vibrations from one sensor could be read by other sensors. All you have to do is change the code to another pin and wire it up. Google it, there is code available online.
My electronic drum kit's pads have the same type of piezo in an airtight cylinder. When the pad is hit, the pressure inside the cylinder increases and triggers the piezo, the "brains" then plays the sound associated with that sensor.
To increase sensitivity you can add a small neodymium to each side of the piezoelectric element. I have found it greatly improved the sensitivity.
I did not know that. Thanks for the tip!
@@MarcdeVinck I may have missed you a bit. At the time I was trying this I was using the piezoelectric with the vibration sensor sketch and wiring. I am sorry. I didn't realize the two sketches and wiring were using different signal pins ex. Vibration sensor using pin 9 and Knock sensor using pin A0. Originally was working with vibration sensor module SW420 and wanted to try using a piezo instead to see if sensitivity would increase it didn't until I added the magnets on either side. I then decided to use the knock sketch and realized the difference in wiring and sketch's and realized it is not as effective using it as a knock sensor. Even playing with program sensitivity values didn't make much difference. Anyway I just wanted to clarify that I did make an error in my comment. Sorry.
@@davidbean5807 No worries. I appreciate the explanation!
So helpful , thank you very much
Thank you for the video! Quick question: Sorry I'm new to electronics... what is the wattage and tolerance of the 1M resistor?
1/4W 1%, but any generic resistor should be fine.
@@MarcdeVinck Thank you very much!
Hi great video btw I have a question is there a way to program the Piezo with the Arduino to make direct contact with the Piezo not just vibration?
The piezo is not programmed, it is just a "dumb"sensor, no specific electronics. You can make a capacitive touch sensor with Arduino. That would sense whenever a wire (or anything conductive) is touched. I have a video on that here - ua-cam.com/video/ZqeA1CQsAQM/v-deo.html
Why do you need resistor across Ground and A0? I thought the Piezo just generates a voltage (no more than 5v) and then the aruidno should just read it?
To stop the pin from floating and giving random numbers.
Hi Marc, I followed your wiring and code, but I'm having trouble with the sensitivity. As I change the sensitivity it seems to go from not being able to sense, to being oversensitive and repeating "knock!" without interruption (no new input on the sensor). What could be going on?
Sounds like you have a floating pin. Double check your resistor is wired properly and the correct value.
That was IT! Thank you. I should probably figure out how to solder so those tiny wires.
thanks very nice video
Thank you!
Can i measure the amplitude using this element? Lets say im placing multiple piezo elements on a surface and hitting a certian point. Is there a way to tell which element gave the input with the highest amplitude?
Yes, that is possible. Just make sure your micro is fast and you can compare response times and amplitude.
In Arduino's IDE, "Examples 02. Digital toneKeyboard" requires 3x force sensing resistors. Can I use one of those force sensing resistors for this Knock Sensor project? If not, why not? Thanks for your guidance.
That example uses a force sensing resistor (FSR). You could use it, but you would have to hit the actual sensor to get a signal, which is analog. A piezo can sense vibration from further away. They are are also less expensive. So, yes you can, but it's not ideal.
how about automotive knock sensor?
Sadly I think I need that for my car! But in all seriousness, you could grab audio waveforms of your engine running and potentially find a "knock" in the audio spectrum.
Would there be any change when you add the piezoelectric vibration module to the sensor?
The sensor is a piezo? Not sure what you are asking?
Great informative video. Hope you can help me. I have a sensitivity of 15 and tried upto 20. But output from piezo is very inconsistent. It registers a value above 20 after 3 to 4 clicks. So I can't get the toggle behavior. What's wrong?
Not sure how you are calculating sensitivity. Might want to try something more binary. Piezo generate an analog electrical signal, you could sense any voltage over 0...or close to zero.
Does the piezos analogue output vary by how hard you knock it? Like would a harder knock cause a stronger electric pulse?
Yes! As a fun test you can hold a through hole LED to the (+) & (-) parts of the piezo and "flick" it with your finger. You will see a difference in the LEDs brightness based on how hard you "flick" it. And you will also most likely kill the LED, so use a spare one that you don't mind burning out.
can i put it behind a door and receive its vibration? and why connect the resistor in parallel with the piezo?
You could, bu it it would have to be hit to register a signal. If you want higher resolution you might want to consider an inexpensive accelerometer or IMU. For the resistor? The reason is to be able to filter out false positives by always having a path for the electricity to go instead of the analog pin floating when not in use.
Can this sensor measure the vibration of machine? Like textile weaving,knitting machine..
Possibly, but it depends on the amplitude and frequency. You can also use an accelerometer for higher frequency and lower amplitude situations, but again, it depends on a lot of factors, including the sensors durability in a high stress situation.
@@MarcdeVinck thanks for your kind reply! Bt i have question regarding this,' if we use piezoelectric vibration sensor then as controller which one we should use arduino or plc..which one more impactful and why?
@@fazrulislam5053 It depends. Which Arduino? Which PIC? They run at different speeds depending on the board. Didn't use to be that way, but a lot has changed in the last 15+ years. I would choose the board that runs fast enough and you are familiar with programming.
@@MarcdeVinck arduino like arduino mega 2560 and PLC like ladder diagram(LD)/ladder logic!
@@fazrulislam5053 Again, depends on what you are specifically measuring. You can use board, but I would try to connect with someone locally that can get you a better answer and see your specific needs.
Would someone be able to explain to me how the sensitivity works? I think I understand but I am not 100% sure? I understand that the lower the number on the code, the higher the sensitivity. From what I can understand from the code: when I hit the piezo it generates a voltage. The arduino detects that voltage. The sensitivity changes ONLY the response of the arduino?
For example, if it is closer to 0, then the arduino will displace “knock” at a lower piezo voltage (assuming 0.1) compared to being set to 300 which requires the arduino to respond to a much higher voltage (assuming 5)?
So the sensitivity does nothing to the piezo itself, just the reaction of the arduino to the amount of voltage released by the piezo?
I would also like to add a little note: when only using the LED pin and ground (red wire connected directly to LED) when the sensitivity was set to 0, the piezo would click at constant intervals and when it was set to 300 the clicking would stop.
This is why I asked the question, is the arduino sending a base voltage through the piezo, and does that voltage change/have anything to do with the sensitivity?
Yes, you have the basic concept correct. The piezo generates electricity (the piezo effect) when a mechanical force is applied. No power to the piezo is necessary. The sensitivity is the Arduino reacting via code to the amount of energy created by the force that is applied to the piezo.
@@MarcdeVinck ok, thank you so much for your reply!
@@selinacervantes7407 No problem, glad I could help!
Can anyone help me create something that detects hits but have it be about .5 inches and wireless and connect it to a phone app with flutter
Can this knock sensor detect vibrations in the air or does it only detect sound waves through solid material?
No, it won't detect vibrations in the air. For that I would recommend something similar to a speaker. When the speaker diaphragm moves it would generate and electrical current. You could also bounce a UV led off a very flexible surface and measure the movement (or reflectance), and that could give you an idea about air movment.
@@MarcdeVinck thank you, that is actually a smart idea. I also found some sort of an intensity meter which I can use, along with some calculations, to detect the loudness of a sound in dB.
@@omarkhalaf9723 Look up Arduino Decibel Meter, there are tons of resources. Also know that a microphone measures air movement. (basically what I was explaining by using a speaker)
can the arduino be set to switch the led off after a set time
Yes! You can easily add a delay and then turn an LED on/off.
@@MarcdeVinck ok thanks
i actually want to switch a siren or buzzer on for a set period , is there a way of doing that please?
@@Masiyamusic You can easily do that by using a buzzer or speaker. Turn on (or play a tone) through the speaker when a knock is sensed, add a delay for as long as you want, then turn it off. It's an easy project! Good luck and have fun!
Nobody explains the 1M resistor and it's function in the circuit .. like what does it do .. why 1M .. what if we take another value ...
The 1 mega ohm resistor limits the travel of almost all the electricity on the pin. It makes the pin very stable, with no fluctuating voltages, and therefore very sensitive to variations you can leverage via code.
Never get 0 out of it. Its always abput 70. after one knock, it holds about 200 for a certain time and slowly reduce itself back to 70
Same piezo? And nothing else wired up? Sounds like a capacitor and/or a floating pin issue? What pin are you using? Same as the video example?
@@MarcdeVinck Already switched all components, same behavior. You think it's not soldered alright? Maybe some loose Parts? Yes, I use nearly the same build.
@@RicoNNect82nd I can't say if it's a solder issue without seeing it. Not sure where you even have solder if you built it the same way?
@@MarcdeVinck I solderd it in the first place, without jumpwire before.
The soldered places look clean so far. Want to try another input. Already swapped Arduino and Piezo and Inbetriebnahme resistors, same issue :/
what are your codes
Watch the video! :) I go over it in detail, including where to find it.
Where is the code
I go over where to find the code in the video -- ua-cam.com/video/X3XXRZMBPO0/v-deo.html
can you please tell that If I want to connect more then 1 piezoelectric sensor to Arduino ..then How can I do it??
You can connect as many sensors as you have available pins. But be aware that vibrations from one sensor could be read by other sensors. All you have to do is change the code to another pin and wire it up. Google it, there is code available online.