A piezoelectric sensor converts mechanical stress into electrical signals using piezoelectric materials like quartz or ceramics. When pressure or vibration is applied, these materials generate a voltage proportional to the force. Widely used in applications such as accelerometers, microphones, and pressure sensors, piezoelectric sensors offer high sensitivity, fast response and durability.
Disc Material | Brass |
---|---|
Piezoceramic Material | PZT (Lead Zirconate Titanate) |
Resonant Frequency | ~4.3 kHz |
Capacitance | ~20–30 nF |
Operating Voltage | ±5 V (output) |
Operating Temperature | -20°C to +70°C |
Max Vibration Acceleration | ~100 g |
Output Type | AC voltage (requires amplification for microcontrollers) |
📄 Piezo element datasheet (90 kB)
A piezo sensor generates a voltage when mechanically deformed, which can be up to 30 V or more. This
could easily damage the connected microcontroller, since it only tolerates 5V or 3.3V. To limit those
voltage spikes a 1MΩ resistor is placed in parallel between Cathode and Anode of the piezo disc.
This helps protecting the microcontroller by dissipating excess voltage. Additionally a 5V (or 3.3V)
Zener diode can also be placed parallel with the resistor to prevent voltage spikes above 5V
(resp.: 3.3V).
The sensitivity of the piezo sensor can be adjusted by selecting different resistor values (~1MΩ to 10MΩ).
A smaller resistor decreases sensitivity.
Mount the piezo sensor mechanically to avoid false readings due to loose connections.
Prevent strong mechanical shocks that could generate excessive voltages.
Connection | Polarity |
---|---|
Inner electrode (PZT ceramic side) | Anode (+) |
Outer electrode (metal/brass side) | Cathode (−), GND |
#define PIN_PIEZO A0
void setup() {
pinMode(PIN_PIEZO, INPUT);
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(PIN_PIEZO);
Serial.println(sensorValue);
delay(25);
}
Another way to interface a piezo sensor with an Arduino is by using an interrupt. However, this method can only detect a binary signal - that is, whether the piezo was triggered or not - but not how strongly it was pressed.
#define PIN_PIEZO 2
#define CUSTOM_DELAY 1000
#define lmillis() ((long)millis())
volatile int pressedSum = 0;
long lastAction;
void setup() {
Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(PIN_PIEZO), handlePiezo, RISING);
lastAction = lmillis() + CUSTOM_DELAY;
}
void loop() {
if (lmillis() - lastAction >= 0) {
lastAction = lmillis() + CUSTOM_DELAY;
Serial.println("Pressed on piezo: " + String(pressedSum) + " times");
}
}
void handlePiezo() {
pressedSum++;
}
#define PIN_PIEZO 13
void setup() {
pinMode(PIN_PIEZO, INPUT);
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(PIN_PIEZO);
Serial.println(sensorValue);
delay(25);
}
After connecting the components and uploading the code to the microcontroller, you can gently tap the piezo disc. Upon opening the serial console or plotter, you should see that the input values change depending on the pressure you apply.