Sparkfun: Large Piezo Vibration Sensor - With Mass

Jump to: navigation, search

thumb‎ Embedded Linux Class Kevin Geisler RHIT

Overview: 1, Nice overview, but a close up picture of the device would help.
Wiring:   1, What op-amp are you using?  A schematic of your actual circuit would be a big help.
Code:     2
git:      2
Demo:     2
Total:    8/10
Comments: Good start, but more specific details are needed.


The Large Piezo Vibration Sensor is a basic piezo sensor which is often used for flex, touch, vibration and shock measurements. This sensor acts like a small capacitor which discharges up to +/-90V when the film moves back and forth. Some common uses this type of sensor are for impact sensing or as a flexible switch. A larger scale example are piezo sensors that are laid within the road for use of traffic signals.

This sensor can be purchased at SparkFun.

The Technical Manual and datasheet can also be found on Sparkfun's website.

Example alt text
This is and example circuit layout of the piezo vibration sensor using an op amp and the beagle board.


Since the piezo sensor acts like a small capacitor, you can connect on a bread board as such. However an additional resistor is needed in order affect the low frequency of measurement. This is called the "loading effect". Additionally, if the signal from the piezo sensor is too low an op amp may be necessary.

More specific information and circuit diagrams can be found in the Technical Manual on pages 36-40.

Beagle Bone Usage

The value being read from the piezo sensor will be a voltage up to +/-0.5V. This means that an analog pin must be used to read the value from the sensor. The voltage being supplied to the sensor affects how much sensitivity you will receive. Look in the technical manual to find a desired voltage that will work for you. For the example below, I simply used a 5V source.

Example alt text
This is a picture of the layout of the piezo vibration sensor using an op amp and the beagle board.

Reading the Analog Signal

You can simply read the value of the piezo sensor from the terminal by reading the contents of a file in the /sys/devices/platform/omap/tsc/ain# directory. The # is 1 + the number of the analog pin you selected as your analog input. However this method will not allow you to accurately see the change of voltage as the film moves. To do this you will need to write a c program to print the values to the terminal repeatably or plot the voltage over time. The sample code below shows a simple program to print the voltage of the sensor to the screen.

Sample Code

The following code can be found on git hub.

Example Program for the Large Piezo Vibration Sensor - With Mass

This will display the value of the AIN0 Pin directly to the terminal repeatively.

wrtten by Kevin Geisler, 23-Sept-2012
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>

#define SYSFS_AIN1_DIR "/sys/devices/platform/omap/tsc/ain2"

FILE *fp; 

int readanalog(){
	if ((fp = fopen(SYSFS_AIN1_DIR, "r")) == NULL)
		printf("Cannot open value file.\n");

	//Set pointer to begining of the file
	//Write our value of "0" to the file 
	char inString[10];
	fgets(&inString, 10, fp);
//			printf("...value set to 0...\n");	
//	printf(inString);
	return atoi(&inString);

int main(int argc, char** argv)

	//Run an infinite loop - will require Ctrl-C to exit this program

	return 0;