• Arduino
  • Raspberry Pi
  • Raspberry Pi Pico
  • Micro:Bit

The KY-002 shock and vibration sensor is a precise module for detecting shocks and vibrations. It consists of a conductive outer casing and an internal spring. In the event of shocks, the spring closes the contact to the outer casing and thus generates an electrical signal. This simple design enables reliable and fast detection of vibrations.

Technically speaking, the KY-002 operates in the voltage range from 3.3 V to 5 V. The compact design facilitates integration into a wide variety of projects. Thanks to its robustness and ease of use, the KY-002 is ideal for applications in security systems where vibrations on doors and windows need to be detected, as well as in industrial automation for monitoring machines and systems for unusual vibrations. The sensor can also be used to measure vibrations and shocks in the sports and fitness sector.

Technical Data
Operating voltage 3,3 V - 5 V
Dimensions 18,5 mm x 15 mm

Pin assignment


Arduino Sensor
Pin 10 Signal
5 V +V
GND GND
Arduino Sensor
Pin 13 LED +
GND LED -

Code-Example

This is an example program that lights up an LED when a signal is detected at the sensor. The modules KY-011, KY-016 or KY-029 can, for example, be used as LEDs, for example.

int Led = 13 ;// declaration of the LED output pin
int Sensor = 10 ;// Declaration of the sensor input pin
int val; // Temporary variable
  
void setup ()
{
  pinMode (Led, OUTPUT) ; // Initialize output pin
  pinMode (Sensor, INPUT) ; // Initialize sensor pin
  digitalWrite(Sensor, HIGH) ; // Activate internal pull-up resistor
}
  
void loop ()
{
  val = digitalRead (Sensor) ; // The current signal at the sensor is read out
  
  if (val == HIGH) // If a signal could be detected, the LED is switched on.
  {
    digitalWrite (Led, LOW);
  }
  else
  {
    digitalWrite (Led, HIGH);
  }
}

Example program download

KY002-Arduino.zip

The KY-002 shock and vibration sensor is a precise module for detecting shocks and vibrations. It consists of a conductive outer casing and an internal spring. In the event of shocks, the spring closes the contact to the outer casing and thus generates an electrical signal. This simple design enables reliable and fast detection of vibrations.

Technically speaking, the KY-002 operates in the voltage range from 3.3 V to 5 V. The compact design facilitates integration into a wide variety of projects. Thanks to its robustness and ease of use, the KY-002 is ideal for applications in security systems where vibrations on doors and windows need to be detected, as well as in industrial automation for monitoring machines and systems for unusual vibrations. The sensor can also be used to measure vibrations and shocks in the sports and fitness sector.

Technical Data
Operating voltage 3,3 V - 5 V
Dimensions 18,5 mm x 15 mm

Pin assignment


Raspberry Pi Sensor
GPIO 24 [Pin 18] Signal
3.3 V [Pin 1] +V
GND [Pin 6] GND

Code-Example

This is an example program that prints a console output when as signal is detected at the sensor.

from gpiozero import Button
import time

# The input pin to which the sensor is connected is declared here.
# The button object uses the internal pull-up resistor of the Pi.
sensor = Button(24, pull_up=True)

print("Sensor test [press CTRL+C to end the test]")

# This output function is executed when a signal is detected
def ausgabeFunktion():
    print("Signal recognized")

# When a signal is detected (falling signal edge), the output function is triggered
sensor.when_pressed = ausgabeFunktion

# Main program loop
try:
    while True:
        time.sleep(1)

# Clean-up work after the program has been completed
except KeyboardInterrupt:
    print("Program terminated")

Example program download

KY002-RPi.zip

Start with the command:

sudo python3 KY002-RPi.py

The KY-002 shock and vibration sensor is a precise module for detecting shocks and vibrations. It consists of a conductive outer casing and an internal spring. In the event of shocks, the spring closes the contact to the outer casing and thus generates an electrical signal. This simple design enables reliable and fast detection of vibrations.

Technically speaking, the KY-002 operates in the voltage range from 3.3 V to 5 V. The compact design facilitates integration into a wide variety of projects. Thanks to its robustness and ease of use, the KY-002 is ideal for applications in security systems where vibrations on doors and windows need to be detected, as well as in industrial automation for monitoring machines and systems for unusual vibrations. The sensor can also be used to measure vibrations and shocks in the sports and fitness sector.

Technical Data
Operating voltage 3,3 V - 5 V
Dimensions 18,5 mm x 15 mm

Pin assignment


Micro:Bit Sensor
Pin 1 Signal
3 V +V
GND GND

Code-Example

	
		pins.setPull(DigitalPin.P1, PinPullMode.PullUp)
		basic.forever(function () {
		    serial.writeLine("" + (pins.digitalReadPin(DigitalPin.P1)))
		    if (pins.digitalReadPin(DigitalPin.P1) == 0) {
		        serial.writeLine("Erschütterung")
		    } else {
		        serial.writeLine("Frieden")
		    }
		    serial.writeLine("_____________________________________")
		    basic.pause(1000)
		})
	

Example program download

microbit-KY-002.zip

The KY-002 shock and vibration sensor is a precise module for detecting shocks and vibrations. It consists of a conductive outer casing and an internal spring. In the event of shocks, the spring closes the contact to the outer casing and thus generates an electrical signal. This simple design enables reliable and fast detection of vibrations.

Technically speaking, the KY-002 operates in the voltage range from 3.3 V to 5 V. The compact design facilitates integration into a wide variety of projects. Thanks to its robustness and ease of use, the KY-002 is ideal for applications in security systems where vibrations on doors and windows need to be detected, as well as in industrial automation for monitoring machines and systems for unusual vibrations. The sensor can also be used to measure vibrations and shocks in the sports and fitness sector.

Technical Data
Operating voltage 3,3 V - 5 V
Dimensions 18,5 mm x 15 mm

Pin assignment


Raspberry Pi Pico Sensor
GPIO26 Signal
3.3V +V
GND GND

Code-Example

This is an example program that counts up and outputs text serially when a signal is detected at the sensor.

# Load libraries
from machine import Pin, Timer

# Initialization of GPIO26 as input
sensor = Pin(26, Pin.IN, Pin.PULL_DOWN)

# Create timer
timer = Timer()

# Variables initialization
counter = 0

# Function: Count steps
def step(timer):
    global counter
    counter = counter + 1
    print("Vibration")
    print(counter)

# Function: Vibration
def shake(pin):
    # Debounce function: Set timer
    timer.init(mode=Timer.ONE_SHOT, period=100, callback=step)

# Initialization of the interrupt
sensor.irq(trigger=Pin.IRQ_FALLING, handler=shake)

Example program download

KY002-Pico.zip