







A rather simple, cheap, yet effective way to detect vibrations is by using a piezo element. The piezo element is an electrical component found in many commercial products to detect impacts, vibrations, pressures and also to produce sound.

The piezoelectric effect (as it is known) was discovered in 1880 by French physicists Jacques and Pierre Curie. By definition the piezoelectric effect is the electric charge accumulated in certain solid materials in response to applied mechanical stress. That’s what piezo means in Greek, to stress, squeeze or press. When the materials in the piezo element are pressed, they generate a charge proportional to the applied mechanical stress. And this charge is very useful to us Arduino builders!

So the piezo element has 2 distinctive features and uses. We can either use it as an input source and detect fluctuations in voltage when a pressure is applied to the element; or we can apply a voltage with a certain frequency to produce sound waves (like the buzzer in your UPS and wrist watch).

How it works?

It should be noted that the piezo element works only when the pressure or voltage applied is changing at a particular frequency. This means that if you connect the piezo to a linear 1.5v source, like a battery, it will not produce any sound. Likewise, if you are detecting a press on the piezo, it will detect only the change in pressure. Bottom line “When pressure/voltage are constant the piezo element will not react.”

So how do we use it effectively? As an example we will build a simple vibration sensor which theoretically can detect very small vibrations, even small seismic tremors. The setup is very simple.

Setup

Grab an Arduino and a piezo element. Connect the black wire of the piezo element to Ground and the red wire to analog pin 1. Now place the piezo element on a table and a heavy object on top of it. 500g object resting on the piezo element would be a good start. That’s all, now how do we capture the data.









Data Acquisition and Presentation

The code provided will send out readings from the analog pin between 0 and 1023 to the serial output. To keep things simple, we can display the data in a graph using the plot functionality in the Arduino IDE. Go to Tools > Serial Plotter.

You should see a straight line on value 0. Now try and knock on the table… You should see vibration waves on the serial plotter. The harder you knock the bigger the waves.

Why did we add a weight? The piezo element works when there is change of pressure applied to it. Without weight vibrations on coming from the table will not induce pressure changes to the piezo element. However when adding a weight, the weight vibrates at the same frequency (or so) as the table, on top of the piezo element, inducing substantial pressure changes that can be easily detected.

You can experiment with more or less weight and look at the graph and how differently it behaves.

The Code

int inputPin = A1; void setup() { // put your setup code here, to run once: pinMode(inputPin,INPUT); Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: Serial.println(analogRead(inputPin)); }