The Sensing Principle and Raw Output Characteristics
A piezoelectric sensor converts mechanical stress into an electrical charge via the piezoelectric effect. When physical force deforms the crystal lattice of the piezoelectric material (typically Lead Zirconate Titanate, or PZT, in ceramic discs, and Polyvinylidene Fluoride, or PVDF, in flexible films), the internal positive and negative charge centers shift. This dipole displacement pushes electrons to the surface electrodes, generating a measurable electrical potential proportional to the applied force.
Unlike resistive sensors (like flex resistors) that output a steady DC voltage when fed a constant current, a raw piezoelectric sensor outputs a high-impedance, high-voltage AC spike. It behaves electrically as a charge source in series with an internal capacitor. When you tap a 27mm PZT disc, it doesn't output a continuous logic-high digital signal or a steady analog voltage; it generates a transient voltage spike that can easily exceed 50V on a hard impact, which then rapidly decays back to 0V. Because the output is a transient analog voltage, it must be clamped to protect your microcontroller and read via an Analog-to-Digital Converter (ADC) to capture the peak amplitude.
Sensor Specifications and ESP32 Wiring Matrix
Selecting the right piezo element depends on your mechanical coupling and sensitivity requirements. Below is a data-dense comparison of the most common hobbyist and industrial piezo elements available in 2026.
| Sensor Type / Model | Internal Capacitance | Resonant Freq. | Typical Sensitivity | Avg. Price (USD) |
|---|---|---|---|---|
| 27mm PZT Ceramic Disc (e.g., Murata 7BB-27-4) | ~20 nF | 4.6 kHz | ~25 pC/N | $0.50 - $1.20 |
| 20mm PZT Ceramic Disc | ~12 nF | 6.2 kHz | ~18 pC/N | $0.30 - $0.80 |
| PVDF Piezo Film (e.g., TE LDT0-028K) | ~300 pF | >10 MHz | ~15 pC/N (Highly directional) | $3.50 - $6.00 |
| PZT Cantilever Bender (with tip mass) | ~50 nF | 100 - 300 Hz | ~400 pC/N (High gain) | $4.00 - $9.00 |
To interface the high-impedance, high-voltage spike to the ESP32's 12-bit ADC (which expects 0V to 3.3V DC), we use a passive signal conditioning network consisting of a bleed resistor and a clamping diode.
| Component / Node | Connection Point | Function & Value |
|---|---|---|
| Piezo Lead 1 (Signal) | ESP32 GPIO 34 (ADC1_CH6) | Carries the analog voltage spike to the MCU. |
| Piezo Lead 2 (Ground) | ESP32 GND | Common ground reference. |
| Load / Bleed Resistor | Parallel across Piezo Leads | 1MΩ to 10MΩ. Discharges the piezo capacitance to establish an RC decay time. |
| Clamp Diode (Zener/Schottky) | Cathode to 3.3V Rail, Anode to Signal | 3.3V Schottky (BAT54) or 3.3V Zener. Shunts overvoltage to the VCC rail. |
| Sensor Supply Range | N/A | Passive sensor. Clamp circuit references the ESP32 3.3V DC rail. |
Signal Conditioning Physics, Interference, and Raw-to-Unit Math
Before writing code, you must understand the physics of the RC decay and the environmental noise that plagues high-impedance piezo circuits.
The RC Time Constant and Resistor Selection
The 1MΩ bleed resistor is not arbitrary; it forms an RC low-pass filter with the piezo's internal capacitance. The time constant (τ) dictates how fast the voltage spike decays. For a 27mm disc with 20nF capacitance and a 1MΩ resistor, τ = R × C = 1,000,000 × 0.00000002 = 0.02 seconds (20ms). This 20ms decay window is slow enough for the ESP32 ADC (sampling at ~5kHz) to reliably capture the peak voltage, but fast enough to reset before a second tap occurs. If you use a 10kΩ resistor, τ drops to 0.2ms, and the ESP32 will likely miss the peak entirely.
Common Interference Sources
- 50/60Hz Mains Hum: The high-impedance piezo acts as an excellent antenna for electromagnetic interference (EMI). Keep the 1MΩ resistor and clamp diode soldered directly to the piezo tabs, not on the breadboard end of a long wire.
- Cable Microphonics (Triboelectric Effect): Moving the unshielded sensor cable generates internal friction between the dielectric and the shield, creating false charge spikes. Use shielded coaxial cable for runs longer than 5cm.
- Acoustic Cross-Talk: PZT discs are highly sensitive to airborne acoustic energy. If mounted on a table, a loud clap or heavy footstep can trigger false positives. Mechanical isolation (mounting on sorbothane or silicone) is required for precision impact detection.
Raw ADC to Physical Unit Math
The ESP32's 12-bit ADC outputs a raw integer between 0 and 4095. To convert this to a physical force measurement (Newtons), we use the sensor's charge sensitivity (pC/N) and its capacitance.
Step 1: Convert Raw ADC to Peak Voltage
Vpeak = (ADCraw / 4095) × 3.3V
Note: The ESP32 ADC is notoriously non-linear near 0V and 3.1V+ (Espressif ADC Documentation). For impact peak-detection in the 0.5V to 2.5V range, this linear approximation is acceptable. For lab-grade precision, apply the ESP-IDF ADC calibration curve.
Step 2: Convert Voltage to Force (Newtons)
The fundamental piezo equation is V = Q / C. Since Q (Charge) = Sensitivity × Force, we substitute to get:
Vpeak = (Sensitivity × Force) / Ctotal
Rearranging to solve for Force:
Force (N) = (Vpeak × Ctotal) / Sensitivity
You tap a 27mm PZT disc (C = 20nF, Sensitivity = 25 pC/N). The ESP32 reads a peak ADC value of 1860.
1. Vpeak = (1860 / 4095) × 3.3V = 1.50V
2. Force = (1.50V × 20 × 10-9 F) / (25 × 10-12 C/N)
3. Force = (30 × 10-9) / (25 × 10-12) = 1.2 Newtons of peak impact force.
Step-by-Step Build and Calibration Routine
Follow these steps to assemble the hardware and empirically calibrate the sensor for your specific mechanical mounting.
- Prep the Sensor: Solder 22 AWG stranded wire to the inner and outer silver tabs of the 27mm PZT disc. Use low-temperature solder (or apply heat for <2 seconds) to avoid depolarizing the PZT crystal or melting the PVDF film.
- Build the Clamp Network: Solder a 1MΩ 1/4W resistor directly across the two sensor leads. Next, solder a 3.3V Schottky diode (like a BAT54) in parallel, with the cathode (stripe) facing the signal wire and the anode facing ground. Schottky diodes are preferred over Zeners here due to their faster response time and lower leakage current (TE Connectivity Sensor Design Notes).
- Wire to ESP32: Connect the signal line to GPIO 34. GPIO 34 is an input-only pin on the ESP32, which lacks internal pull-up resistors that could interfere with the high-impedance piezo signal. Connect the ground line to ESP32 GND.
- Implement Peak-Detection Code: Do not use simple analogRead() delays. Write a tight polling loop that continuously reads the ADC and stores the maximum value over a 50ms window, resetting the peak variable once the signal drops below a noise threshold (e.g., ADC < 150).
- Empirical Drop-Test Calibration: Theoretical math assumes perfect mechanical coupling, which rarely exists. To calibrate, drop a known mass (e.g., a 20g steel bearing) from a fixed height (e.g., 10cm) onto the center of the sensor. Calculate the theoretical impact force using impulse-momentum equations, record the ESP32's peak ADC reading, and derive a custom scaling multiplier in your code to map ADC units directly to your real-world Newtons.
By respecting the high-impedance nature of the piezoelectric output and properly managing the RC decay and EMI vulnerabilities, you can transform a $1 ceramic disc into a highly reliable, high-speed impact and vibration transducer for your embedded projects.






