Piezo Vibration Sensor

Last updated: 9 October 2012
Prepared by Marco De Mutiis [marcodemutiis@gmail.com]
URL: https://www.sparkfun.com/products/9196?
Cost per unit: $2.95USD (approx. 23 HKD)


General Information

About Piezoelectronic sensors

A piezoelectric sensor is a device that uses the piezoelectric effect to measure pressure, acceleration, strain or force by converting them to an electrical charge. [...]Piezoelectric sensors have proven to be versatile tools for the measurement of various processes. They are used for quality assurance, process control and for research and development in many different industries. [...]Additionally, piezoelectric technology is insensitive to electromagnetic fields and radiation, enabling measurements under harsh conditions.
(excerpted from a wiki article on piezoelectornic sensors, accessed 9 October 2012).

This basic piezo sensor is often used for flex, touch, vibration and shock measurements. A small AC and large voltage (up to +/-90V) is created when the film moves back and forth. A simple resistor should get the voltage down to ADC levels. Can also be used for impact sensing or a flexible switch.
(excerpted from a sparkfun product page, accessed 9 October 2012).

Features & Specifications

  • - Flexible PVDF Piezo Polymer Film
  • Wide dynamic range
  • Laminated for higher voltage output
  • 0.1" breadboard friendly leads

Getting it to work!

PIN1 of the Piezo connected to GND on Arduino
PIN2 of the Piezo connected to 10M Ohm resistor that goes to AnalogIn pin (example uses A0) on Arduino and to 5V on Arduino (see: Voltage divider).

Example Code

The following example reads the sensor data from the analog pin and writes it to the Serial Port. In Processing the data triggers an mp3 sample to play, whenever the sensor is flexed, or if a strong vibration is detected.

Arduino Code
constint sensorPin = A0;
int value = 0;

void setup(){

void loop(){
value = analogRead(sensorPin);
send data to serial port only if higher than threshold of 700
we divide the value by 4 because Processing gets data range 0-255, and analog in in arduino reads 0-1023

Processing Code
import ddf.minim.*;
import processing.serial.*;

Serial myPort; Create object from Serial class
Minim minim;
AudioSample kick;

int val; Data received from the serial port

void setup()
size(512, 200, P2D);
I know that the first port in the serial list on my mac
is always my FTDI adaptor, so I open Serial.list()[0].
On Windows machines, this generally opens COM1.
Open whatever port is the one you're using.
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600);
minim library settings to create a line out and a sine wave
minim = new Minim(this);
kick = minim.loadSample("http://soundjax.com/reddo/24227%5EMOAN.mp3", 2048);

void draw()

if ( myPort.available() > 0) { If data is available,
val = myPort.read(); read it and store it in val
println(val); prints the sensor data to the console
use the mix buffer to draw the waveforms.
because these are MONO files, we could have used the left or right buffers and got the same data
for (int i = 0; i < kick.bufferSize() - 1; i++)
line(i, 100 - kick.left.get(i)*50, i+1, 100 - kick.left.get(i+1)*50);