Let's Workshop: Keyes 801S Vibration Sensor Module


Here is a quick introduction to using the Keyes 801S based vibration sensor. Hopefully it will provide you with the confidence to integrate knock and vibration sensing into your project.

This example will demonstrate the use of an Arduino UNO in monitoring both an analog and digital pin over a range of vibration levels.

Components

Wiring

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

Coding

The code consists of a definition, setup and loop. First the A0 and D0 pins is assigned followed by a varaiable each to store the values read. This allows easier use later in your program. A setup informs the system that the pins are inputs and then lauches the serial connection. Next we enter the loop, where the value on the pin is read and stored in the variables declared earlier. Following that we send it to the serial monitor so that the values 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 Vibration Sensor Module - BDAA100015 
  The program monitors connected analog and digital pin and outputs the value to the
  serial monitor.
  
  modified 26th September 2019
  by Sebastian Karam - Flux Workshop
*/
int analogpin = 0; // define analog OUT signal pin
int analog; // define variable to store value read from pin
int digitalpin = 2; // define digital OUT signal pin
int digital; // define variable to store value read from pin
  
void setup() {
  pinMode(analogpin, INPUT); // set the OUT signal pin as an input
  pinMode(digitalpin, INPUT); // set the OUT signal pin as an input
  Serial.begin(9600); // launch the serial monitor
  Serial.println("Flux Workshop Example");
}
 
void loop() {
  analog = analogRead(analogpin);  // read the voltage level on the A0
  digital = digitalRead(digitalpin);  // read the voltage level on the D2
  Serial.println((String)"Light level: Analog " + analog + " Digital " + digital ); // 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 case the sensor initially still and then, well, we shake like a polaroid picture. You can then see spikes in the output up.

What to try next?

  • Mount the emitter to a door and record movements through the portal.
  • If you hold it very steady, you can just about make a digital egg for an egg and spoon race.
Previous article Let's Workshop: Keyestudio LM35 Temperature Sensor
Next article Let's Workshop: Keyes IR Detector Module (Black)

Comments

qANGKIuBxMDcevbs - November 7, 2019

VjLnRWutbw

MNzpsyIUnZcKY - November 7, 2019

SwgtJQRfiqhBDU

NhdsocLXKCOqGRFA - November 6, 2019

PYyludjBpGXMhgK

eYarHEFoNp - November 6, 2019

TQyPzWBpFo

HhpOLTKt - November 6, 2019

okuBzORcsT

BlNiLcjFfy - November 6, 2019

gHXojdTEiVWtPC

EgctFXwS - November 6, 2019

WqeKNZgXsof

bVwFZTOzxRIoJuy - November 6, 2019

BOxbnNhUWQjemFZp

ZGVWpNjYbTtgHRQC - November 6, 2019

xHnBmsvwFej

NdJmYvFVA - November 6, 2019

mOCirlZsey

Leave a comment

* Required fields