Piezoelectric sensor
Piezoelectric sensor is basically a transducer which converts stress applied on it into some electrical energy. It is simply used the principle of energy conversion from one form to another. As in case of piezoelectric sensor, it converts physical stress into electrical energy. Stress can be a force, pressure, acceleration and touching potential. Because these all are kind of stresses and piezoelectric sensor converts such kind of physical forces into electrical form.

How piezoelectric transducer or sensor works?
Whenever any stress is applied to piezoelectric sensors, a potential difference of same magnitude of force is produced across piezoelectric transducer. So it can be easily used to convert mechanical energy into electrical energy. Piezoelectric sensors produced analog output voltage. If you want to understand internal construction and working of this sensor. I recommend you to search it on Google. Because it is not possible for me to cover all the things in one topic. But if you know about basic working of piezoelectric transducer, it is enough to use in your project.
Piezoelectric works with the principle of piezoelectricity. The faces of piezoelectric material, usual quartz, is coated with a thin layer of conducting material such as silver. When stress has applied the ions in the material move towards one of the conducting surface while moving away from the other. This results in the generation of charge. This charge is used for calibration of stress. The polarity of the produced charge depends upon the direction of the applied stress. Stress can be applied in two forms as Compressive stress and tensile stress as shown below.

Piezoelectric sensor interfacing with Arduino Uno R3:
Piezoelectric sensors produce analog voltage at the output. So to interface this sensor with Arduino Uno R3, you should know how to measure analog voltage with Arduino Uno R3. If you don’t know how to measure analog voltage using Arduino, I suggest you to read following article first. So that you can learn piezoelectric sensors interfacing with Arduino properly.
Diagram below shows the hardware connections of piezoelectric sensor interfacing with Arduino. Piezoelectric sensors have two output pins one is positive potential and other is at negative potential (means ground). Positive potential pin is connected with pin 3 analog channel of Arduino and negative potential pin is connected to ground. A resistor of 2 mega ohm is connect between them for protection purpose. A led is connected to pin zero to check working of sensor output.

Code:
int sensoroutput = 4; // the analog pin connected to the sensor
int ledoutput = 0; // pin connected to LED
int THRESHOLD = 100;
void setup()
{
pinMode(ledPin, OUTPUT); // this function is used to declare led connected pin as output
}
void loop()
{
int value = analogRead(sensoroutput); // function to read analog voltage from sensor
if (value >= THRESHOLD) // function to check voltage level from sensor
{
digitalWrite(ledoutput, HIGH);
delay(100); // to make the LED visible
}
else
digitalWrite(ledoutput, LOW);
}
Application:
- As piezoelectric materials cannot measure static values these are primarily used for measuring surface roughness, in accelerometers and as a vibration pickup.
- They are used in seismographsto measure vibrations in rockets.
- In strain gauges to measure force, stress, vibrations etc…
- Used by automotive industries to measure detonations in engines.
- These are used in ultrasonic imagingin medical applications.
Reference:
https://www.americanpiezo.com/knowledge-center/piezo-theory/applications.html