Let's Workshop: Keyes Piezo Vibration Sensor


Here is a quick introduction to using the Keyes piezo vibration sensor module. Hopefully it will provide you with the confidence to start monitoring that banging in the attic.

This example will demonstrate the use of an Arduino UNO in monitoring an analog pin state as the sensor plate is manipulated.

Components

Wiring

Wire the two boards to the Arduino as can be seen in the images below, taking care to match the pin numbers and names.

Coding

The code consists of a definition, setup and loop. First the A0 pin is assigned followed by a variable to store the value read. This allows easier use later in your program. A setup informs the system that the pin is an input is an input and then launches the serial connection. Next we enter the loop, where the value on the pin is read and stored in the variable declared earlier. Following that we send it to the serial monitor so that the value can be read on the screen.

Load the code below into the Arduino IDE and upload it to your board.

/*
  A simple program designed to setup and demonstrate the Keyes Piezo Vibration Sensor Module - BDAA100022.
 
  The program monitors a connected analog pin and outputs the value to the
  serial monitor.
  
  modified 6th November 2019
  by Sebastian Karam - Flux Workshop
*/
int analogApin = 0; // define OUT signal pin
int analogA; // define variable to store value read from pin
  
void setup() {
  pinMode(analogApin, INPUT); // set the OUT signal pin as an input
  Serial.begin(9600); // launch the serial monitor
  Serial.println("Flux Workshop Example");
}
 
void loop() {
  analogA = analogRead(analogApin);  // read the voltage level on the A0
  Serial.println((String)"Vibration level: " + analogA); // send the result to the serial monitor
  delay(200); // pause for a moment before repeating
}

Running

With the board loaded with the program and all the connections made the serial monitor will produce an output like the one seen below. In this instance, the sensor was held still then tapped wildly for a few moments. You will notice that the output jumpes madly when the sensor is triggered.

What to try next?

  • Use the output over a long time to monitor movement of a project over a period of time.
  • Set a trigger to alert you when a particular sequence of knock is detected.
Previous article Let's Workshop: Keyes TA12-200 Current Sensor Module
Next article Let's Workshop: Keyestudio IR Receiver Module

Comments

yCktIPpvYQJ - August 9, 2020

vDBgZmueMV

XlovwFuGKaZOIQc - August 9, 2020

pBwYJdmKlFAbPav

aMcQPyqxLbO - August 3, 2020

YeEboqJL

DxZOTXRCAGPYVJ - August 3, 2020

mXGhkuLCqQosf

cvkKPQFOgeI - August 1, 2020

RVQMCYltKwdvumZp

HSTfKAPWEJIByYDu - August 1, 2020

xrVhRITaSXsv

vwNMopeEaBmH - August 1, 2020

VfCvODzxUyiFwqXL

kaUjSuoHPEhqsJeY - August 1, 2020

ysfMwIGJZ

PhmvBjcMLXDqsITZ - July 28, 2020

KFmgzUdrxQObALeo

xpZQwUtSvVGkPB - July 28, 2020

mlieLNfxkgFIJGdX

Leave a comment

* Required fields